Indicators

Get Average directional index indicator Code That Actually Works

Describe your idea → AI generates code → built-in compiler fixes errors → one-click copy. Working average directional index indicator in under 30 seconds.

4.9/5 Rating
10,000+ Traders
Free Forever Plan

The Problem

You've spotted a killer ADX strategy for spotting trend strength, but coding the +DI, -DI, and smoothed ADX lines in Pine Script throws cryptic errors like 'rma undeclared' or smoothing mismatches. Hours wasted debugging, only for the indicator to repaint or fail backtests. Or worse, paid scripts don't match your exact Average Directional Index tweaks and leave you guessing.

The Solution

With HorizonAI's chat interface, just type 'Build an ADX indicator with +DI, -DI, customizable smoothing, and alerts for crossovers above 25'—get working Pine Script in 30 seconds. Our built-in compiler auto-checks and fixes every error, delivering flawless code ready for one-click copy-paste into TradingView. No more broken ADX scripts; trade strong trends confidently.

Why Traders Choose HorizonAI for Average directional index indicator

Everything you need to build trading tools without writing a single line of code

Guaranteed Working Code

Built-in compiler auto-detects and fixes errors before delivery—20,000+ scripts generated for 5,000+ traders without a single failure. Your ADX indicator works first time, every time.

30-Second Generation

Skip weeks learning Pine Script or days waiting for freelancers. Type your ADX idea, get copy-paste code instantly—no delays.

Chat-Based Refinement

Generated your ADX? Chat to tweak lengths, add divergence, or volume filters. Iterate until your Average Directional Index is perfect.

Trend Strength Alerts

Get phone alerts when ADX crosses 25 for strong trends, combined with SuperTrend or volume profile—spot entries like a pro.

How It Works

From idea to working code in three simple steps

1

Describe It

Tell the AI exactly what you want your average directional index indicator to do. Plain English, no code knowledge needed.

2

Generate & Fix

AI writes the code and auto-compiles it. Any errors are fixed automatically before you see it.

3

Copy & Trade

One-click copy. Paste into TradingView or MT5. Your average directional index indicator is live in under a minute.

Try It Now — It's Free

See What You'll Get

Real, production-ready code generated by HorizonAI — ready to copy and use

Average directional index indicator — Pine Script

This ADX indicator plots trend strength with +DI/-DI lines, customizable thresholds, background colors for quick visual cues, and alerts for crossovers—expect reliable signals to filter strong trends and avoid chop.

Pine Script
//@version=5
indicator(title="Average Directional Index (ADX) Indicator", shorttitle="ADX", overlay=false)

// Input parameters
adx_length = input.int(14, title="DI Length", minval=1)
adx_smooth = input.int(14, title="ADX Smoothing", minval=1)
show_di = input.bool(true, title="Show +DI and -DI")
show_thresholds = input.bool(true, title="Show Threshold Lines")
threshold_20 = input.float(20.0, title="Weak Threshold")
threshold_25 = input.float(25.0, title="Strong Threshold")
threshold_50 = input.float(50.0, title="Very Strong Threshold")

// Directional Movement calculations
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)

// True Range and smoothing
truerange = ta.rma(ta.tr, adx_length)
plus_di = fixnan(100 * ta.rma(plusDM, adx_length) / truerange)
minus_di = fixnan(100 * ta.rma(minusDM, adx_length) / truerange)

// DX and ADX calculations
dx = 100 * math.abs(plus_di - minus_di) / (plus_di + minus_di)
adx = ta.rma(dx, adx_smooth)

// Plots
plot(adx, color=color.new(color.orange, 0), linewidth=2, title="ADX")
plot(show_di ? plus_di : na, color=color.new(color.green, 0), title="+DI")
plot(show_di ? minus_di : na, color=color.new(color.red, 0), title="-DI")

// Threshold lines
plot(show_thresholds ? threshold_20 : na, color=color.new(color.gray, 50), title="20")
plot(show_thresholds ? threshold_25 : na, color=color.new(color.blue, 50), title="25")
plot(show_thresholds ? threshold_50 : na, color=color.new(color.purple, 50), title="50")

// Background coloring for trend strength
bgcolor(adx > threshold_25 ? color.new(color.green, 90) : adx > threshold_20 ? color.new(color.yellow, 95) : na, title="Trend Strength BG")

// Alert conditions
alertcondition(ta.crossover(adx, threshold_25), title="ADX Strong Trend Up", message="ADX crossed above 25 - Strong trend detected!")
alertcondition(ta.crossunder(adx, threshold_25), title="ADX Weak Trend Down", message="ADX crossed below 25 - Trend weakening")
alertcondition(ta.crossover(plus_di, minus_di), title="+DI Bullish Cross", message="+DI crossed above -DI - Bullish signal")
alertcondition(ta.crossunder(plus_di, minus_di), title="-DI Bearish Cross", message="-DI crossed above +DI - Bearish signal")

// Table for current values (optional display)
if barstate.islast
    var table info_table = table.new(position.top_right, 2, 4, bgcolor=color.white, border_width=1)
    table.cell(info_table, 0, 0, "ADX", text_color=color.black)
    table.cell(info_table, 1, 0, str.tostring(adx, "#.##"), text_color=color.orange)
    table.cell(info_table, 0, 1, "+DI", text_color=color.green)
    table.cell(info_table, 1, 1, str.tostring(plus_di, "#.##"), text_color=color.green)
    table.cell(info_table, 0, 2, "-DI", text_color=color.red)
    table.cell(info_table, 1, 2, str.tostring(minus_di, "#.##"), text_color=color.red)
    table.cell(info_table, 0, 3, "Trend", text_color=color.black)
    table.cell(info_table, 1, 3, adx > 25 ? "Strong" : adx > 20 ? "Moderate" : "Weak", text_color=adx > 25 ? color.green : adx > 20 ? color.orange : color.red)

This is just one example. Generate any indicator or strategy you can imagine.

Generate Your Own Code
"I kept getting Pine errors coding ADX with +DI crossovers—total waste of evenings. Typed my idea into HorizonAI, boom, perfect code in 20 seconds with auto-fixed compiler magic. Now alerts hit my phone on strong trends, caught a 30% move last week."
T
Verified Trader
HorizonAI User
10K+
Traders
50K+
Scripts Generated
30s
Avg Generation
Free
To Start

Frequently Asked Questions

Everything you need to know to get started

Will the average directional index indicator code actually work?

Absolutely—our built-in compiler auto-checks and fixes every error before delivery, so your ADX code pastes perfectly into TradingView. 5,000+ traders have generated 20,000+ flawless scripts. No debugging headaches, just working indicators.

How is this different from asking ChatGPT?

HorizonAI is trained on the full Pine Script manual and trading concepts like ADX calculations, plus our auto-compiler fixes errors ChatGPT misses. Generic AIs spit out broken code; we deliver TradingView-ready ADX scripts that actually compile.

Can I customize the average directional index indicator after generating it?

Yes, our chat interface lets you refine endlessly—'Add volume profile to ADX' or 'Change smoothing to 20'—AI iterates instantly. It's a conversation with a trading expert, not a one-shot tool.

How long does it take to get my average directional index indicator code?

Under 30 seconds: describe your ADX setup, AI generates and compiles, one-click copy to TradingView. Beats learning code (weeks) or freelancers (days)—start trading your indicator minutes from now.

Is HorizonAI free?

Yes—you can start generating code right now for free, no credit card required. The free tier gives you access to the AI chat, code generation, and the auto-compiler. Over 5,000 traders are already using it.

Ready to Build Your Trading Tools?

Join thousands of traders who use HorizonAI to create custom indicators and strategies without coding. Start free today.

Start Building — It's Free

No credit card required. Free forever plan available.

Related Guides