EMA crossover
Two moving averages of the same price, one fast and one slow. When the fast one climbs above the slow one, the trend may be turning up; when it drops below, down. This guide builds the two signals and charts them next to the price.
New to the editor? Do Getting started first.
The idea
An exponential moving average (EMA) smooths a price by averaging it over a window of bars, with the latest bars counting most. A short window follows the price closely. A long one moves slowly.
Move the sliders to see how the two windows change the signals.
▲ 2 up and ▼ 3 down in 200 bars of sample prices, the grey line. In the shaded first 25 bars the slow EMA has no value yet.
Short windows react fast and cross often, including on noise. Long windows cross rarely and late. Common pairs:
| Fast | Slow | Character |
|---|---|---|
| 9 | 21 | Reactive, many signals |
| 12 | 26 | The pair used by MACD |
| 50 | 200 | Slow, only major trend changes |
The formula
With a window of bars the smoothing factor is , and each bar updates the average:
where is the price at bar . The first bars have no value.
Build it
Start from a strategy with a Cryptocurrency module, which the Crypto template gives you. Reusing your first strategy? Delete the modules you no longer need: click each one and press Delete. Then follow the three steps.
On the Cryptocurrency module, set Symbol to BTC/USDT and Period to 1d.
Save. The two red outputs are the signals:
| Output | Is true on the bar where |
|---|---|
| CrossOver | the fast EMA moves above the slow EMA |
| CrossUnder | the fast EMA moves below the slow EMA |
On every other bar they are false. They are empty at the start, while the slow EMA has no value yet.
Chart it
Add three charts on the dashboard:
- A Candlestick chart of the Cryptocurrency module, to see the price.
- A Line chart with the EMA output of both EMA modules, to see where they cross.
- A Bar chart with the CrossOver and CrossUnder outputs. A signal draws as 1 when true, so a bar marks every cross.
With Auto-execute on, each new chart starts a run. The slow EMA is empty for its first 25 bars, so set the start date a month or two before the dates you want to study.
An AI assistant can put all of it in one chart: candles, both EMAs and an arrow on every cross.
What the result tells you
A crossover is a description of the past, not a forecast. Moving averages do well in long trends and badly in sideways markets, where the two lines cross back and forth. Look at how many signals a run gives and what the price did after each one before you trust a pair of windows.