EMA Cross
A moving average crossover strategy with commission and slippage set to realistic values.
EMA Cross tests one of the simplest trend rules: buy when a short exponential moving average crosses above a longer one, and leave when it crosses back below. It is written as a reference, a plain strategy with realistic costs that shows how such signals have behaved on this symbol.
How it works
Two exponential moving averages (EMA) are calculated, a fast one over 9 bars and a slow one over 21. An EMA gives more weight to recent closes, so the fast one turns sooner after price changes direction.
A long position opens on the bar after the fast EMA crosses above the slow EMA, and closes on the bar after it crosses back below. There is no stop and no target: the position is held for as long as the fast average stays above the slow one.
Commission (0.1% per side) and slippage (0.05%) are set in the code, so that the test results are not more favourable than real trading would be.
Reading the chart
The strategy draws its trades rather than lines.
- A buy marker shows the bar on which each position opened.
- An exit marker shows the bar on which it closed.
- The two averages themselves are not drawn. To see them next to the trades, you can add EMA 9 and EMA 21 from the indicator list.
Settings
- Fast
- 9
- The length of the fast moving average.
- Slow
- 21
- The length of the slow moving average. It should be longer than the fast one.
Limits and points to note
- A crossover appears after a move has started, and the exit comes after it has turned, so each trade misses part of the move at both ends.
- In sideways markets the averages cross often and trades are short; costs weigh more heavily on such trades.
- The strategy only takes long positions and uses the whole account for each trade. EMA Cross Risk is the same rule with every trade sized by risk.
- Test results describe the past. They are not a forecast and do not indicate future results.
EMA Cross en sade trend kurallarından birini sınar: kısa vadeli üstel hareketli ortalama uzun vadeli olanı yukarı kestiğinde al, yeniden aşağı kestiğinde çık. Bir başvuru örneği olarak yazılmıştır: bu tür sinyallerin bu sembolde geçmişte nasıl davrandığını gösteren, gerçekçi maliyetli sade bir strateji.
Nasıl çalışır
İki üstel hareketli ortalama (EMA) hesaplanır: 9 barlık hızlı ve 21 barlık yavaş ortalama. EMA son kapanışlara daha fazla ağırlık verir; bu yüzden hızlı ortalama, fiyat yön değiştirdikten sonra daha erken döner.
Hızlı EMA yavaş EMA'yı yukarı kestikten sonraki barda long pozisyon açılır, yeniden aşağı kestikten sonraki barda kapanır. Zarar-durdur ve kâr-al yoktur: pozisyon, hızlı ortalama yavaş ortalamanın üstünde kaldığı sürece tutulur.
Komisyon (her yön için %0,1) ve kayma (%0,05) kodda tanımlıdır; böylece test sonuçları gerçek işlemden daha olumlu görünmez.
Grafiği okuma
Strateji çizgi değil, işlemlerini çizer.
- Alış işareti, her pozisyonun açıldığı barı gösterir.
- Çıkış işareti, pozisyonun kapandığı barı gösterir.
- İki ortalamanın kendisi çizilmez. İşlemlerin yanında görmek isterseniz gösterge listesinden EMA 9 ve EMA 21 ekleyebilirsiniz.
Ayarlar
- Fast
- 9
- Hızlı hareketli ortalamanın uzunluğu.
- Slow
- 21
- Yavaş hareketli ortalamanın uzunluğu. Hızlı ortalamadan uzun olmalıdır.
Sınırlar ve dikkat edilecekler
- Kesişim hareket başladıktan sonra, çıkış da hareket döndükten sonra gelir; bu yüzden her işlem hareketin iki ucundan da bir kısmını kaçırır.
- Yatay piyasalarda ortalamalar sık kesişir ve işlemler kısa sürer; maliyetler bu işlemlerde daha ağır basar.
- Strateji yalnız long işlem açar ve her işlemde hesabın tamamını kullanır. EMA Cross Risk, her işlemi riske göre boyutlayan aynı kuraldır.
- Test sonuçları geçmişi anlatır; bir öngörü değildir ve gelecekteki sonuçlara işaret etmez.
strategy("EMA Cross")commission(0.1)slippage(0.05)fast = ema(close, input.int(9, "Fast"))slow = ema(close, input.int(21, "Slow"))enterLong(crossover(fast, slow))exit(crossunder(fast, slow))
strategy("EMA Cross")commission(0.1)slippage(0.05)fast = ema(close, input.int(9, "Fast"))slow = ema(close, input.int(21, "Slow"))enterLong(crossover(fast, slow))exit(crossunder(fast, slow))
Version 119 Oct 2026Latest
First release
There are no community posts about this strategy yet. You can write the first post about it.


