Category
Technical
Difficulty
Beginner
Used in
Strategy designRisk managementMT5 operation

Average True Range

A volatility indicator measuring the average size of recent price movement, in price units. EAs use it to set stop distances and position sizes that adapt to current conditions instead of assuming yesterday's.

also: ATR, True Range

Updated

In plain English

How far this market usually travels in one bar, averaged over the recent past. It has no opinion about direction — it is a ruler for distance, and almost everything an EA measures in pips is better measured in these units.

Why it matters

Every distance inside an EA — the stop, the target, the trailing step, the breakout threshold — is a number of pips chosen by somebody. ATR is what turns those fixed numbers into ratios that keep meaning the same thing when the market speeds up or slows down.

  • It is the practical form of volatility. An EA cannot easily compute a standard deviation of returns on each tick, but it can read ATR from one indicator handle.
  • It is in price units, so it converts directly into a stop distance without any statistical step in between.
  • It makes a strategy comparable across symbols and periods. Two pips is a wide stop on one instrument and inside the noise on another; two ATRs is the same statement everywhere.
  • It includes gaps, which a simple high-minus-low range does not — True Range measures against the previous close as well as the current bar.

In MetaTrader 5

Where it appears in MT5

  • Insert → Indicators → Oscillators → Average True Range — added to a chart with a period parameter
  • Navigator → Indicators → Average True Range — drag onto a chart for the same result
  • The indicator draws in a separate window because its scale is price distance, not price
  • Strategy Tester → Inputs — an EA's ATR period and multiplier are inputs, and both are easy to over-optimise

How EAs use it

  • Create the handle once in OnInit — iATR(_Symbol, PERIOD_CURRENT, 14) — and read values with CopyBuffer, rather than creating handles inside OnTick.
  • Stop distance = multiplier × ATR at entry, so the stop is placed outside ordinary movement instead of at a round number of pips.
  • Position size = risk amount ÷ (stop distance × pip value), which makes lot size fall automatically when volatility rises.
  • Trailing distance is the same idea applied continuously — the trail widens in fast markets and tightens in calm ones.
  • Read ATR from a completed bar (index 1) rather than the forming bar (index 0), whose value changes with every tick.
  • Do not assume iATR is Wilder's ATR. MetaTrader's bundled ATR rolls a fixed window where Wilder smooths. The two therefore react on different clocks: after volatility tripled, we measured 19 bars against 59 to reach 90% of the new level.

Typical settings

Setting Typical value Note
Period 14 The conventional default. Shorter periods (7–10) react faster; longer (20–30) are smoother and suit daily systems.
Stop multiplier 1.5–2.5 × ATR Below about 1.5 the stop sits inside ordinary movement for most instruments.
Trailing multiplier 2–3 × ATR Usually wider than the entry stop, so normal retracement does not end a trend trade.
Target multiplier 2–4 × ATR Keeps the risk/reward ratio stable as conditions change.
Timeframe read from the strategy's own An M5 ATR and a D1 ATR describe different questions; mixing them silently changes every distance.

Common operational problems

  • Creating the indicator handle inside OnTick leaks handles and eventually fails — the handle belongs in OnInit.
  • CopyBuffer returning fewer values than requested at startup, before enough history has loaded, which yields a zero ATR and therefore a zero-distance stop.
  • Reading the forming bar's ATR, so the stop distance depends on when in the bar the signal fired.
  • Points and pips confusion: ATR is returned in price units, and a 5-digit quote means 0.00120 rather than 12 — multiplying it as if it were pips produces stops a hundred times too wide or too narrow.
  • Optimising the ATR period and the multiplier together on the same window, which fits the pair to that window's particular retracements.

Related MT5 functions

iATR(symbol, timeframe, ma_period)
Creates the indicator handle; call it once in OnInit and keep the handle.
CopyBuffer(handle, 0, start, count, array)
Reads ATR values out of buffer 0 — the only buffer the indicator has.
SymbolInfoDouble(symbol, SYMBOL_POINT)
Converts the price-unit ATR into points, which is what stop distances are expressed in.
NormalizeDouble(price, _Digits)
Rounds a computed stop level to the symbol's precision before it is sent.

Example

The same risk rule, applied in two volatility regimes. Nothing in the EA changes — the ruler it measures with does.

Quiet regime — ATR(14)
12 pips
A 2 × ATR stop is 24 pips.
Volatile regime — ATR(14)
34 pips
The same 2 × ATR stop is 68 pips.
Risk per trade
1% of $10,000 = $100
Lot size, quiet / volatile
0.42 / 0.15
Same money at risk, different distance, therefore different size.

Widening the stop without shrinking the lot would have tripled the money at risk. ATR only helps when both halves move together.

Calculation 100 ÷ (24 × 10) = 0.42 · 100 ÷ (68 × 10) = 0.15

Result One risk rule producing two stop distances and two position sizes

How it is used

ATR is a distance, not a signal. It tells an EA how far to place things — never whether to place them.

Range What it means
Current ATR far below the backtest average Targets defined in ATR shrink accordingly, so the strategy takes smaller wins while costs stay fixed.
Current ATR near the backtest average The conditions the settings were tuned in. Published expectations apply.
Current ATR well above the backtest average Fixed-pip stops are now inside the noise; ATR-based ones widen, and position size must fall to compensate.
ATR used as an entry signal A misuse. It is directionless — a high reading says the market is moving, not which way.
  • Express every distance in the EA as a multiple of ATR, then optimise the multiple rather than the pip count. The result transfers between symbols and regimes far better.
  • Never compare raw ATR values across symbols. Forty pips on GBP/JPY and forty on EUR/USD are different levels of activity; divide by price if a comparison is needed.
  • Match the ATR period to the holding period. A scalper reading a daily ATR is sizing for a move it will never be in for.
  • Check the multiplier is stable across neighbouring values. A stop that works at 2.0 × ATR but not at 1.8 or 2.2 is fitted to the test window.

The [full ATR indicator page](/en/indicators/atr) covers the calculation and the settings in detail. It includes our measurement that MetaTrader's iATR is a rolling window, not Wilder's smoothing. This entry is about the role ATR plays inside an EA's risk rules.

Common mistakes

Treating ATR as a direction signal

It measures distance travelled, not which way. A rising ATR means the market is moving more — which happens in trends, in crashes and in violent ranges alike.

Widening the ATR stop without reducing the lot

The whole point of an adaptive stop is that risk per trade stays constant. If the distance triples and the size does not fall, the loss has tripled instead.

Confusing price units with pips

iATR returns a price distance — 0.00120 on a 5-digit EUR/USD, not 12. Code that treats it as pips places stops a hundred times too far or too near, and the error is easy to miss in testing because the results are simply bad rather than broken.

Reading ATR from the forming bar

Index 0 changes on every tick, so the same signal produces a different stop depending on the moment it fires. Use the last completed bar for anything that must be reproducible.

Frequently asked questions

What ATR period should an EA use?
Fourteen is the conventional default and a reasonable starting point. Shorter periods of seven to ten react faster to a change in conditions but are noisier; twenty to thirty are smoother and suit strategies working on daily bars. What matters more than the exact value is that it stays stable across neighbouring settings when tested.
How do I turn ATR into a stop-loss distance?
Multiply it. A stop at 2 × ATR sits two average bar ranges away from entry, which is outside ordinary movement for most instruments. The essential second step is to compute the lot size from that distance and your risk limit, so a wider stop means a smaller position rather than a larger loss.
Is ATR better than a fixed pip stop?
For an EA running unattended over years, generally yes, because a fixed distance means different things in different volatility regimes while an ATR multiple means the same thing throughout. The trade-off is one more parameter to keep from being over-optimised.
Is MT5's ATR the same as Wilder's ATR?
Not exactly, and it matters when you port a setting. Wilder smooths true range so every past bar keeps decaying inside the value; MetaTrader's bundled ATR rolls a fixed window instead, which is a simple moving average. Both are linear filters whose weights sum to one, so their long-run levels agree — we measured 9.571 against 9.573 pips over 2,700 bars at period 20. What differs is the response: after volatility tripled at one bar, MetaTrader's version reached 90% of the new level in 19 bars and Wilder's took 59. A 2 x ATR stop therefore widens sooner on MT5 than the same rule did on a Wilder-based platform. Matching the period does not merge them either: the closest iATR period to Wilder's 20 measured at 32-33.
Does ATR tell me the trend direction?
No. It is a pure distance measure and has no directional component at all. ADX is the usual companion for trend strength, and a moving average or price structure for direction.

Related articles