The moving average crossover alert indicator does the classic two-average cross and adds a readable slow line. A 12 period average crosses a 50 period reference, and the crossing bar gets an arrow. The slow line changes colour with its own slope, so you can tell at a glance whether a cross agrees with the longer trend or fights it.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 4: MA Up, MA Down, Buy Signal, Sell Signal |
| Alerts | popup, push notification, email, sound |
| Inputs | 12 |
What the Moving average crossover alert Indicator draws on the chart
MA Up shows the slow reference line in dodger blue while its slope points upward.
MA Down shows the same line in tomato when the slope turns down.
Buy Signal drops a lime arrow under the bar where the fast average crosses above the slow one.
Sell Signal places a red arrow above the bar on the opposite cross.
- MA Up: line, dodger blue, width 2
- MA Down: line, tomato, width 2
- Buy Signal: arrow, lime, width 3, arrow code 233
- Sell Signal: arrow, red, width 3, arrow code 234

How the Moving average crossover alert Indicator calculates its values
Building the averages by hand
This build does not call iMA. It reads a price series into src through a switch over `AppliedPrice`, covering open, high, low, median, typical and weighted as well as close. Then it computes the averages itself: kFast is 2.0 / (FastPeriod + 1.0), the standard exponential factor, with kSlow the equivalent for the slow leg. `MethodMA` selects between the exponential recursion, an SMA path and a Hull path through HMA_AsSeries.
Seeding rather than starting from zero
A recursive average that starts at zero drags a false line across the early chart. The code avoids that with fastSeedIdx at rates_total – FastPeriod and slowSeedIdx at rates_total – SlowPeriod. At the seed bar it takes a simple average through SMA_AsSeries, and only from the next bar does the exponential recursion take over.
Colouring by slope and marking the cross
slope_up holds when SlowMA[i] sits at or above SlowMA[i + 1], with prev_up doing the same one bar back. Comparing the two lets `ColorFlip` switch the line between UpBuf and DnBuf at the exact bar the slope turns, writing both buffers at the junction so the line has no gap. Separately, prev_diff and curr_diff track FastMA minus SlowMA, and a sign change between them places an arrow `ArrowOffsetPts` clear of the candle.
How to read the signals
A blue slow line with a lime arrow means the cross agrees with the slower trend.
A tomato line under a lime arrow is the awkward case: the cross fights the slope.
The colour flip and the arrow are separate events and often land on different bars.
Because the averages are seeded rather than zeroed, the leftmost bars of the chart carry no line at all.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
Four channels ship here: popup, push notification, email and sound. Note that `EnableSound` starts `true` in this build alongside `EnablePopup`, so you get an audible cue out of the box, with `SoundFile` set to `”alert.wav”`. Push and email start off, and the guard allows one message per closed bar.
Every Moving average crossover alert Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
FastPeriod |
Fast MA period. Length of the crossing average, default `12`. | 12 |
SlowPeriod |
Slow MA reference period. Length of the reference average, default `50`. This is also the line that gets the slope colouring. | 50 |
MethodMA |
Smoothing method. Smoothing choice, default `MA_EMA`. The Hull option reacts faster at the cost of more crosses. | MA_EMA |
AppliedPrice |
Applied price. Which price feeds both averages, default `PRICE_CLOSE`. Typical or weighted smooth out noisy opens. | PRICE_CLOSE |
Display settings
| Setting | What it does | Default |
|---|---|---|
ColorFlip |
Color flip on direction change. Set it `false` to keep one colour and read the line by position alone. | on |
ArrowOffsetPts |
Arrow offset (points). Distance between candle and arrow, default `20` points. | 20 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
(see inputs panel) | on |
EnablePopup |
(see inputs panel) | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
(see inputs panel) | off |
EnableSound |
(see inputs panel) | on |
SoundFile |
(see inputs panel) | alert.wav |

Settings that fit your chart
A 12 against 50 cross is a middle-of-the-road trend read that suits H1 and H4 on the majors. EURUSD H1 is the reference chart. On the daily the pair crosses only a few times a year, which suits position traders. Below M15 the cross fires often enough that the slope colour becomes the more useful half of the tool.
When the Moving average crossover alert Indicator fails
Crossover systems whipsaw in ranges. A 12 and 50 pair reduces that compared with a faster combination but never removes it.
The slope colour reads only the last two values of the slow line, so a single flat bar in a strong trend can flip the colour and flip straight back.
The Hull option overshoots after a sharp move, which shows up as a cross that unwinds within a few bars.
Copy the compiled Moving average crossover alert Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.
Download the Moving average crossover alert Indicator for MT4 and MT5
The zip holds the compiled Moving average crossover alert Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.
Download this indicator free
Enter your email and the file is yours. You also get the full MT4 and MT5 library.
FAQ
Why does MethodMA compute the averages instead of calling iMA?
Because `MethodMA` offers a Hull option, which MetaTrader’s own moving average does not provide. Writing the recursion by hand lets exponential, simple and Hull share one code path and one seeding rule. The exponential result matches iMA with MODE_EMA on the same period and applied price.
What does ColorFlip actually change?
It switches the slow line between the MA Up and MA Down buffers as its slope turns. The code compares SlowMA[i] against SlowMA[i + 1] and writes both buffers at the junction bar so the line stays continuous. Set it `false` and the line keeps a single colour, leaving you to read direction from its shape.
Do the Buy Signal arrows and the colour change happen together?
Usually not. The arrow comes from FastMA crossing SlowMA, which the code tracks through prev_diff and curr_diff. The colour comes from the slow line’s own slope. A fast average can cross while the slow line is still falling, and that mismatch is worth noticing rather than smoothing away.
Which AppliedPrice setting should I use?
`PRICE_CLOSE` is the default and the usual choice. PRICE_TYPICAL averages high, low and close, which calms instruments that gap at the open. PRICE_WEIGHTED leans on the close while still using the range. All seven options feed both averages, so changing it moves the cross as well as the line.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Moving average crossover alert Indicator as one input. Always backtest before trading live.
Category: this is part of our Trend collection. Browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- The core method is documented in Market moving information on Wikipedia.
- Additional market context is at Average True Range Percent Atrp at StockCharts ChartSchool.
