To reduce lag in the ADX/DMI indicators I replaced the moving averages, which are a significant source of lag, with the UltimateSmootherFilter.
The screenshot below compares the standard ADX/DMI indicators to this reduced lag ADX/DMI indicator.
On both lower indicators, the dashed gray line is the ADX = 25 line.
The image shows that the reduced lag ADX/DMI captures ADX values that are above 25 (trending) at times when the lagging ADX indicator reports the ADX to be < 25 (not trending). Perhaps this approach to ADX/DMI will help you.
Here is the code:
The screenshot below compares the standard ADX/DMI indicators to this reduced lag ADX/DMI indicator.
On both lower indicators, the dashed gray line is the ADX = 25 line.
The image shows that the reduced lag ADX/DMI captures ADX values that are above 25 (trending) at times when the lagging ADX indicator reports the ADX to be < 25 (not trending). Perhaps this approach to ADX/DMI will help you.
Here is the code:
CSS:
# Reduces the lag of ADX/DMI by replacing MovingAverages with UltimateSmootherFilters
declare lower;
input length = 14;
def hiDiff = high - high[1];
def loDiff = low[1] - low;
def plusDM = if hiDiff > loDiff and hiDiff > 0 then hiDiff else 0;
def minusDM = if loDiff > hiDiff and loDiff > 0 then loDiff else 0;
def ATR = UltimateSmootherFilter(TrueRange(high, close, low), length);
plot DIp = 100 * UltimateSmootherFilter( plusDM, length) / ATR;
plot DIm = 100 * UltimateSmootherFilter( minusDM, length) / ATR;
def DX = if (DIp + DIm > 0) then 100 * AbsValue(DIp - DIm) / (DIp + DIm) else 0;
plot ADX = UltimateSmootherFilter( DX, length);
DIp.SetDefaultColor(Color.DARK_GREEN);
DIm.SetDefaultColor(Color.DARK_RED);
ADX.SetDefaultColor(Color.BLACK);
ADX.SetLineWeight(2);
addCloud(DIp,DIm,Color.DARK_GREEN,Color.DARK_RED);
plot CenterLine = 25;
CenterLine.HideBubble();
CenterLine.AssignValueColor(Color.GRAY);
CenterLine.SetStyle(Curve.SHORT_DASH);
CenterLine.setLineweight(2);