The awesome ADX For ThinkOrSwim

antwerks

Well-known member
VIP
VIP Enthusiast


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)
These ranges are arbitrary but usually used with slope calcs of ADX. You can add lower limit at 20 and upper limit lines at 25 if you want
1755740748227.png

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:


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)
These ranges are arbitrary but usually used with slope calcs of ADX. You can add lower limit at 20 and upper limit lines at 25 if you want
View attachment 25515
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);
Excellent! Thanks for sharing
 
@antwerks , I've been using and testing above indicator.. I think ADX slope labels are displayed incorrectly.. Please check.

  • 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)
 
@antwerks , I've been using and testing above indicator.. I think ADX slope labels are displayed incorrectly.. Please check.

  • 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)
This is measuring the ADX line the yellow line in the chart above not the DI+ or DI- or even the overall signal. Just the ADX. If I am still missing something let me know..
1755806133936.png
 
Got it.. thanks
This is just a trend strength indicator (ADX) some people me included do use the cross of the DI-and DI + as validators of buy and sell zones - team them with momentum and volume and price action and supply and demand zones and you will have a decent idea of where to buy and sell - the ADX and slope tell us trend strength direction and how “excited” the trend is
 
  • Like
Reactions: dog

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
759 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top