All Strategies
Trend Following

ATR Trend Follow

Volatility-adjusted trend following — trail stops by ATR multiples.

A simple EMA trend with ATR-based exits. Stop and trailing stop scale with the asset's realised volatility, so the same code works on quiet EUR/USD and wild Bitcoin. ATR multipliers (typically 2-3×) are the only parameter you need to tune per market.

atr-trend-follow.pinePine Script v5
//@version=5
strategy("ATR Trend Follow", overlay=true)

ema_len = input.int(21, "EMA Length")
atr_len = input.int(14, "ATR Length")
atr_mult = input.float(2.5, "ATR Multiplier")

ema = ta.ema(close, ema_len)
atr = ta.atr(atr_len)

long_stop = close - atr * atr_mult

if close > ema and close[1] <= ema[1]
    strategy.entry("Long", strategy.long)

if strategy.position_size > 0
    strategy.exit("Trail", from_entry="Long", stop=long_stop)

Deploy ATR Trend Follow as a Live Bot

Backtest on real data, then run it 24/7 on your MT5 account.

Get Started Free

We use cookies for analytics and ads measurement. See our privacy policy.