ADX Enhanced with labels and slope calculations to identify trend strength
- Strongly Bullish = slope > +1.5 (DARK_GREEN)
- Moderately Bullish = +0.5 to +1.5 (GREEN)
- Neutral = -0.5 to +0.5 (YELLOW)
- Moderately Bearish = -1.5 to -0.5 (PINK)
- Strongly Bearish = slope < -1.5 (RED)
https://tos.mx/!sDhXEORz (I did change the colors of my lines)
ADX Enhanced with labels and slope calculations to identify trend strength
Code:
# Modified by antwerks 08/20/2025
#YOUTUBE_CHANNEL# ###DAYTRADING FOR SUCCESS#
declare lower;
input length = 14;
input averageType = AverageType.WILDERS;
input Show_Signal_lines_for_DMI_Cross = yes;
input Sound_AudibleAlert_for_DMI_Cross = yes;
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 = MovingAverage(averageType, TrueRange(high, close, low), length);
plot "DI+" = 100 * MovingAverage(averageType, plusDM, length) / ATR;
plot "DI-" = 100 * MovingAverage(averageType, minusDM, length) / ATR;
def DX = if ("DI+" + "DI-" > 0) then 100 * AbsValue("DI+" - "DI-") / ("DI+" + "DI-") else 0;
plot ADX = MovingAverage(averageType, DX, length);
plot SIGNAL = "DI+" - "DI-";
"DI+".SetDefaultColor(GetColor(1));
"DI-".SetDefaultColor(GetColor(8));
ADX.SetDefaultColor(GetColor(5));
SIGNAL.SetDefaultColor(GetColor(3));
# Smoothed Trend-Weighted Signal
#plot SmoothedFastSignal = ExpAverage((("DI+" - "DI-") / #ADX)*10, 2);
#SmoothedFastSignal.SetDefaultColor(Color.MAGENTA);
#SmoothedFastSignal.SetLineWeight(2);
# === NEW: ADX Slope Calculation ===
def ADX_Slope = ADX - ADX[1];
# Classify slope intensity
def strongBull = ADX_Slope >= 1.5;
def moderateBull = ADX_Slope >= 0.5 and ADX_Slope < 1.5;
def neutral = ADX_Slope > -0.5 and ADX_Slope < 0.5;
def moderateBear = ADX_Slope <= -0.5 and ADX_Slope > -1.5;
def strongBear = ADX_Slope <= -1.5;
# Label slope with intensity
AddLabel(yes,
"ADX Slope: " + Round(ADX_Slope,2) +
(if strongBull then " (Strong Bullish Slope)"
else if moderateBull then " (Moderate Bullish Slope)"
else if neutral then " (Neutral)"
else if moderateBear then " (Moderate Bearish Slope)"
else if strongBear then " (Strong Bearish Slope)"
else ""),
if strongBull then Color.DARK_GREEN
else if moderateBull then Color.GREEN
else if neutral then Color.YELLOW
else if moderateBear then Color.PINK
else if strongBear then Color.RED
else Color.GRAY);
# --- Existing ADX Trend Labels ---
AddLabel(ADX > 25, if "DI+" > "DI-" then "ADX > 25 / Up Trend" else "ADX > 25 / Down Trend", if "DI+" > "DI-" then Color.GREEN else Color.RED);
AddLabel(ADX < 20, "ADX < 20 / No Trend", Color.YELLOW);
AddLabel(ADX >= 20 and ADX <=25, if "DI+" > "DI-" then "ADX = " + Round(ADX,2) + " ... Possible New Up Trend?" else "ADX = " + Round(ADX,2) + " ... Possible New Down Trend?", if "DI+" > "DI-" then Color.GREEN else Color.RED);
# --- Alerts ---
def BullishAlertLines = if Show_Signal_lines_for_DMI_Cross then "DI+" crosses above "DI-" and ADX > 20 else no;
AddVerticalLine(BullishAlertLines, "Bullish DMI cross with ADX > 20", Color.DARK_GREEN, Curve.SHORT_DASH);
def BearishAlertLines = if Show_Signal_lines_for_DMI_Cross then "DI+" crosses below "DI-" and ADX > 20 else no;
AddVerticalLine(BearishAlertLines, "Bearish DMI cross with ADX > 20", Color.DARK_RED, Curve.SHORT_DASH);
plot zerobase = 0;
plot loerlimit = 20;
plot upperlimit = 25;
# --- DI+ / DI- Position Labels ---
AddLabel(yes,
"DI+ = " + Round("DI+", 1) + " | DI- = " + Round("DI-", 1) +
(if "DI+" > "DI-" then " → Bulls in Control"
else if "DI-" > "DI+" then " → Bears in Control"
else " → Neutral"),
if "DI+" > "DI-" then Color.GREEN
else if "DI-" > "DI+" then Color.RED
else Color.YELLOW);
Last edited by a moderator: