Zero Lag Moving Average Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

Most smoothing accepts lag as the price of a smooth curve. The zero lag moving average indicator attacks it first: before averaging anything it builds a de-lagged price series, then runs the average over that. The curve you see is coloured by slope and can mark two different events.

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: ZLEMA Up, ZLEMA Down, Buy, Sell
Alerts popup, push notification, email, sound
Inputs 10

What the build actually draws

Four plots, all on the price chart.

`ZLEMA Up` traces deep sky blue at width 2.

`ZLEMA Down` traces orange red at the same width.

`Buy` prints lime using arrow 233.

`Sell` prints red using arrow 234.

Both arrows stand `ArrowGap` `12` points clear.

  • ZLEMA Up: line, deep sky blue, width 2
  • ZLEMA Down: line, orange red, width 2
  • Buy: arrow, lime, width 2, arrow code 233
  • Sell: arrow, red, width 2, arrow code 234
zero lag moving average indicator: The two-colour curve with a crossing mark, EURUSD H1.
The two-colour curve with a crossing mark, EURUSD H1.

What the formula does

Removing the lag first

One expression does it. Twice the current close minus the close from half a window back, which projects the recent move forward before any smoothing touches it.

Then averaging

`ZlemaPeriod` `34` runs an exponential pass over that projected series. A plain average seeds it at the warm-up boundary, so the curve starts clean rather than climbing out of zero.

Two ways to signal

`UsePriceCross` watches the close crossing the curve. `UseSlopeFlip` watches the curve turning. Both ship on, so an arrow can come from either.

Reading the output

Blue means the curve rose against the previous bar.

Orange red means it fell.

The colour changes before a crossing usually does.

Leave one signal switch on to cut the arrow count.

A projected price series overshoots at turns.

Warm-up needs thirty-four closed bars.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

Either signal source can speak, and `EnableAlerts` decides whether one does. `EnablePopup` already puts it in a terminal box; the mobile relay, the mail pass and the desktop knock behind `SoundFile` all begin switched off. One message per closed bar.

Every Zero Lag Moving Average Indicator input

Core settings

Setting What it does Default
ZlemaPeriod ZLEMA period (Ehlers zero-lag EMA). Length of the exponential pass, `34`. 34
UsePriceCross Signal on price / ZLEMA cross. Signal when the close crosses the curve, `true`. on
UseSlopeFlip Signal on ZLEMA slope flip. Signal when the curve itself turns, `true`. on

Display settings

Setting What it does Default
ArrowGap Arrow gap from price (points). Gap between a mark and its candle in points, `12`. 12

Alert settings

Setting What it does Default
EnableAlerts Decides whether a signal speaks, `true`. on
EnablePopup Puts it in a terminal box, `true`. on
EnablePushNotify Relays it to the mobile app, `false`. off
EnableEmail Passes it to mail, `false`. off
EnableSound Knocks it out on the desktop, `false`. off
SoundFile Clip behind that, `”alert.wav”`. alert.wav
zero lag moving average indicator: Inputs panel, ZlemaPeriod above the two signal switches.
Inputs panel, ZlemaPeriod above the two signal switches.

Where the settings fit

Thirty-four bars of smoothing with the lag pulled out lands somewhere between fast and slow. EURUSD H1 is the reference chart, where the colour holds for half a session at a time. M15 turns it choppy. H4 makes each colour run span a week.

Known weak points

Projecting price forward overshoots at every turn.

Zero lag is a goal in the name, not a result.

Two signal sources together double the arrow count.

A curve coloured by slope flips on the smallest change.

Copy the compiled Zero Lag Moving Average 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.

Related on forexmt4systems.com: Moving Average Crossover Strategy.

Download the Zero Lag Moving Average Indicator for MT4 and MT5

The zip holds the compiled Zero Lag Moving Average 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.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What feeds ZlemaPeriod 34 before it averages?

A projected price series. The code doubles the current close and subtracts the close from half a window back, so the averaging pass starts from figures already leaning in the current direction.

Should UsePriceCross and UseSlopeFlip both stay on?

Only if you want every event marked. They fire on different things, so running both roughly doubles the arrows. Turning the slope flip off leaves the more conventional crossing signal alone.

When does ZLEMA Up hand over to ZLEMA Down?

The moment the curve falls against the previous bar. Both buffers carry the same value; the code writes it into whichever one matches the slope, and that swap is what produces the two-colour line.

Why seed ZlemaPeriod 34 with a plain average?

Because an exponential pass starting from zero would draw a spike climbing out of the left edge. Seeding at the warm-up boundary with a simple average makes the first drawn value a real price.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Zero Lag Moving Average 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

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment