Skip to main content

ADX Strategy

Discover our ADX Strategy PineScript template, designed for traders seeking to use ADX indicator. Easily backtest on TradingView and live execute this template on AlgoTest.
Adjusting inputs like ADX Length, ADX Threshold, target points, and stop loss points to suit your trading preferences.

ADX Indicator Pinescript​

//@version=5
strategy("ADX Strategy", overlay=true)

// Input parameters
adx_length = input.int(14, title="ADX Length")
adx_threshold = input.int(25, title="ADX Threshold")

target_points = input.int(100, title="Target Points")
stop_loss_points = input.int(50, title="Stop Loss Points")

[PDI, NDI, adx] = ta.dmi(adx_length, adx_threshold)

// Strategy logic
long_condition = adx > adx_threshold and ta.crossover(PDI, NDI)
short_condition = adx > adx_threshold and ta.crossunder(PDI, NDI)

// Plot ADX
plot(adx, color=color.blue, title="ADX")

// Strategy entry and exit
if long_condition
strategy.entry("Long", strategy.long)
if short_condition
strategy.entry("Short", strategy.short)

// Calculate target and stop loss levels
long_target = strategy.position_avg_price + target_points
long_stop_loss = strategy.position_avg_price - stop_loss_points
short_target = strategy.position_avg_price - target_points
short_stop_loss = strategy.position_avg_price + stop_loss_points

// Strategy exit
strategy.exit("Long Exit", "Long", limit=long_target, stop=long_stop_loss)
strategy.exit("Short Exit", "Short", limit=short_target, stop=short_stop_loss)

Understanding the ADX Indicator​

History of the ADX Indicator​

Developed by J. Welles Wilder Jr. in 1978, the Average Directional Index (ADX) is part of a system that includes the ADX, the Minus Directional Indicator (-DI), and the Plus Directional Indicator (+DI). Originally intended to quantify trend strength in commodities, the ADX is a widely used technical analysis tool that measures the strength of a trend, regardless of its direction.

What is the ADX Indicator?​

The ADX indicator is a component of the Directional Movement System and is used to assess the strength of a trend. It is composed of three lines: the ADX line, which indicates trend strength, and two Directional Indicator lines (+DI and -DI) that highlight the trend's direction. The ADX line itself does not show direction; rather, it quantifies the strength of the trend, whether up or down. The value of the ADX typically ranges from 0 to 100, where higher values signify a stronger trend.

Best Use Cases for the ADX Indicator​

  1. Determining Trend Strength: The primary use of the ADX is to determine the strength of a current trend. A value above 25 generally indicates a strong trend, while values below 20 suggest a weak or non-trending market.

  2. Identifying Potential Entry or Exit Points: Traders often use the crossing of +DI and -DI lines as potential signals for entry or exit points. For instance, when the +DI line crosses above the -DI line, it may suggest a buy signal, whereas a cross below may indicate a sell signal.

  3. Combining with Other Indicators: The ADX works well when combined with other indicators to confirm whether the market is trending. Common pairings include the RSI (Relative Strength Index) and MACD (Moving Average Convergence Divergence) to confirm the trend strength and potential reversals.

Frequently Asked Questions​

What does the ADX indicator tell you?​

The ADX helps traders determine the strength of a trend. High ADX values, typically above 25, confirm that the market is trending strongly in one direction.

How do you calculate the ADX?​

The ADX is calculated as a moving average of the expanding range between +DI and -DI. It incorporates a smoothing technique, which Wilder explained in his book, to render the ADX an effective gauge of trend strength.

What is the best time frame for the ADX?​

The ADX can be applied to any trading time frame, such as daily, hourly, or even minute charts. The best time frame depends on the trading strategy and the trader's analytical preferences.

Which indicator works best with ADX?​

Combining ADX with volume indicators like RSI or price oscillators like MACD can provide a more comprehensive picture of market conditions, helping to confirm the ADX signals.

Is ADX indicator good for day trading?​

Yes, the ADX can be used for day trading, but it's important to combine it with other indicators to confirm trading signals due to the ADX's lagging nature.

To use ADX strategy for trading, visit AlgoTest Signals.