Trend Following
EMA Crossover
Two exponential moving averages — buy when the fast crosses above the slow, exit when it crosses back.
The EMA crossover is the textbook trend-following strategy. A fast EMA (typically 9–13) reacts to recent price; a slow EMA (21–50) tracks the broader trend. The crossover marks a regime change. It captures large directional moves in trending markets and fails predictably in chop — making it easy to layer with a regime filter.
ema-crossover.pinePine Script v5
//@version=5
strategy("EMA Crossover 9/21", overlay=true)
fast_ema = ta.ema(close, 9)
slow_ema = ta.ema(close, 21)
if ta.crossover(fast_ema, slow_ema)
strategy.entry("Long", strategy.long)
if ta.crossunder(fast_ema, slow_ema)
strategy.close("Long")Deploy EMA Crossover as a Live Bot
Backtest on real data, then run it 24/7 on your MT5 account.
Get Started Free