Skip to main content

ATR Indicator

ATR (Average True Range) measures market volatility only: how much price moves on average per candle. It says nothing about direction, which is exactly what makes it useful for stops and position sizing.

What is the ATR Indicator?​

Developed by J. Welles Wilder Jr. (the same creator of RSI and Parabolic SAR) and introduced in his 1978 book New Concepts in Technical Trading Systems, ATR breaks down the price range of an asset over a given period, typically derived from a 14-period moving average of the true range.

How to Read ATR​

  • High ATR: the market is moving a lot per candle; wider stops and smaller position sizes are usually warranted
  • Low ATR: the market is calm; tighter stops and larger position sizes may be appropriate
  • ATR does not indicate direction, only magnitude of movement

Best Use Cases​

  1. Trailing Stops: a stop placed N × ATR away adapts automatically: wider in volatile markets, tighter in calm ones.
  2. Position Sizing: higher ATR suggests smaller position size to keep risk constant across trades.
  3. Entry/Exit Timing: some traders wait for price to move by an ATR multiple before entering, to avoid false breakouts.

How to Automate an ATR-Based Strategy on Signals AI (No Code)​

You don't need TradingView, PineScript, or a webhook to build ATR-based logic. Signals AI is AlgoTest's no-code strategy builder. Describe your strategy in plain English, or build it visually on the Canvas, and it handles backtesting, paper trading, and live execution with your broker.

ATR parameters on Signals AI:

ParameterDefaultDescription
period14Shorter (e.g., 5) reacts faster to volatility changes; longer (e.g., 20) is smoother

Example strategy: SMA entry with ATR trailing stop

Condition
EntryClose crosses above SMA(20)
ExitClose crosses below (SMA(20) − 2 × ATR(14)), a volatility-adjusted trailing stop

To build this:

  1. Open Signals AI and tell the AI Agent something like: "Create a strategy on NIFTY 5-minute spot where entry is Close crossing above SMA(20), and exit is Close crossing below SMA(20) minus 2 times ATR(14)." Or build it manually on the Canvas using a Comparison Node with ATR on one side.
  2. Preview the signal on the chart to confirm the ATR-adjusted stop behaves as expected across different volatility regimes.
  3. Connect a trade and backtest it on historical data.
  4. Forward test it with paper money, then go live once you're satisfied.

→ Full click-by-click walkthrough: Quickstart: Your First Signal in 10 Minutes

ATR PineScript for TradingView​

Prefer TradingView? Here's a ready-to-use ATR strategy template. Paste it into the Pine Editor, adjust the ATR Length, multiplier, target, and stop loss to your preference, and backtest it.

info

To learn how to add this pinescript in TradingView, click here.

warning

This strategy is for demonstration purposes only and is not intended for actual trading. AlgoTest is not responsible for any profit or loss arising from the use of this sample strategy.

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

// Input parameters
atr_length = input.int(14, title="ATR Length")
atr_multiplier = input.float(2.0, title="ATR Multiplier")

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

// Calculate ATR
atr = ta.atr(atr_length)

// Strategy logic
long_condition = close > ta.sma(close, atr_length) + atr_multiplier * atr
short_condition = close < ta.sma(close, atr_length) - atr_multiplier * atr

// Plot ATR
plot(atr, color=color.blue, title="ATR")

// 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)

Once you've backtested it on TradingView, you can connect the alert to AlgoTest to automate execution, or skip the PineScript and webhook setup entirely by rebuilding the same logic directly in Signals AI above.

FAQ​

How do you use the ATR indicator?​

The ATR indicator is primarily used to measure the volatility of a stock, commodity, or other assets. It can be applied to set more effective stop loss orders and adjust position sizes according to market conditions.

What is the best ATR setting?​

While the default setting for ATR calculation is typically 14 periods, adjusting the period count can provide more or less sensitivity depending on the trader's needs and the asset's typical volatility.

Is ATR a good indicator for day trading?​

Yes, the ATR can be extremely useful for day traders who need to understand the volatility and potential price movements of an asset within very short time frames.

How do you use ATR for trailing stop loss?​

To use ATR as a trailing stop loss, calculate a multiple of the ATR to set the stop loss level. For example, setting a stop loss at 1.5 times the ATR below the current price can allow for a buffer during normal market fluctuations.

What are ATR bands?​

ATR bands are similar to Bollinger Bands but use ATR values instead of standard deviation. These bands can provide dynamic support and resistance levels that adapt to changes in volatility.

To automate ATR-based strategies without writing code, visit AlgoTest Signals AI.