Confusing the state with the event
Testing whether the fast EMA is above the slow one is true for the entire trend. Testing whether it crossed requires the previous bar as well, and the difference between the two is one entry versus dozens.
A moving average that weights recent prices more heavily than older ones, so it turns sooner than a simple average. EA trend filters and crossover entries are built on it more often than on any other indicator.
also: EMA, exponential MA
Updated · Reviewed
An average of recent prices that pays more attention to what just happened than to what happened a while ago. It turns faster than a plain average, which makes it more useful in a trend and more talkative in a range.
The EMA is the default building block of EA trend logic: it supplies the direction that indicators like ADX deliberately do not. It is also the most over-used and most over-optimised component in retail EAs, because a crossover rule is easy to write and its two periods are easy to tune until any history looks profitable.
| Setting | Typical value | Note |
|---|---|---|
| Fast / slow pair, short term | 8 / 21 | Reacts quickly; produces many crossings, most of which are not trends. |
| Fast / slow pair, medium term | 50 / 200 | The widely watched pair. Few signals, and the ones it gives arrive late. |
| Single trend filter | EMA 200 on the entry timeframe | Used as a directional gate rather than as an entry. |
| Applied price | Close | Typical and stable. Median or typical price smooths further and changes every backtest result. |
| Signal bar | the last completed bar | Reading the forming bar produces crossings that appear and disappear intrabar. |
The difference between reading a state and reading an event, which is the single most common EMA bug in EA code.
Both versions look profitable in a strong trend during testing. Only one of them is the strategy that was intended.
Calculation if (fast[2] <= slow[2] && fast[1] > slow[1]) → cross up
Result One entry per crossing instead of one per bar
An EMA rule is easy to write and easy to fit. Everything worth checking is about whether the parameters survive being moved.
| Range | What it means |
|---|---|
| Result collapses when a period moves by 10% | Fitted to the test window. A robust setting has neighbours that also work. |
| A broad range of period pairs works similarly | The effect is likely structural rather than fitted, which is what a plateau in an optimisation surface means. |
| Crossover with no regime filter | Signals fire in ranges too, where they mostly fail. This is what ADX or a volatility filter is usually added to fix. |
| Read on the forming bar | Not reproducible. The same market produces different entries depending on tick timing. |
The `/indicators` page for moving averages covers the calculation and the SMA comparison; this entry is about how the EMA is wired into EA logic.
Testing whether the fast EMA is above the slow one is true for the entire trend. Testing whether it crossed requires the previous bar as well, and the difference between the two is one entry versus dozens.
Two free parameters on a smooth surface will always produce an impressive backtest. The value that matters is whether neighbouring pairs behave similarly, which is the difference between an effect and a fit.
Moving averages cross constantly in ranges, and nearly all of those crossings lose. The filter is not an optimisation of the strategy — it is what makes the strategy applicable.
It is faster to react, which cuts both ways: earlier entries in real trends, more false signals in noise. Which is preferable depends on the strategy, and the difference is smaller than the choice of period.
Fourteen EAs are published here with their full closed-trade records. Not one takes its direction from an exponential moving average.
| Direction mechanism | EAs | What it is |
|---|---|---|
| Ichimoku Tenkan/Kijun cross | 5 | Kestrel Hover, Orrery, Peregrine, Tessera, Zerqon |
| Stacked simple moving averages | 1 | Lanternfish — SMA 25/50/75 on M30, entries on M5 |
| An exponential moving average | 0 | — |
| Something other than a cross | 8 | RSI extremes, envelope fades, candle patterns |
Those five kept the crossing and dropped the tuning: Tenkan/Kijun periods come from the indicator’s definition, not a grid search. All five read a closed bar, and Orrery and Peregrine act only when the signal bar’s body beats a multiple of its recent average — the regime filter a bare crossover needs. Their profit factors run 1.27 to 1.46, the same band as the rest of the catalogue.
The Strategy Tester’s Inputs tab takes a Start, Step and Stop per period. Read the whole result set, not its top row: a plateau of neighbouring pairs is an effect, a lone peak is a fit. That is overfitting in practice, and why a filter such as ADX comes before another period is tuned.