Skip to content
FXNook HubBeta

Alex / MTF Moving Average Indicator for MT4

MetaTrader 4IndicatorMITCompiled · build 2425
AlexFirst version.build 2425v1.01 day ago1 version
README

Overview

Draws a moving average from a higher timeframe (for example the H4 or D1 EMA) on a lower-timeframe chart, as clean steps or a smoothed line.

What it is
A free Indicator for MetaTrader 4, written in MQL4.
What it does
Draws a moving average from a higher timeframe (for example the H4 or D1 EMA) on a lower-timeframe chart, as clean steps or a smoothed line.
Shared by
Alex
Licence
MIT
Version
1.0 (1 Dec 2026)
Settings
10 inputs
Lab check
Compiled with MetaEditor build 2425 for MT4 on 1 Dec 2026: 0 errors, 0 warnings.
Price
Free to download

Watching the H4 or daily moving average while you trade M15 normally means switching charts. This indicator draws a moving average calculated on a higher timeframe directly on your current chart, so you can see the bigger trend line and its level while you work on the lower timeframe.

How it works

  • The moving average is calculated on the chosen Timeframe with the chosen period, type (SMA, EMA, SMMA, LWMA) and price, using the terminal's built-in moving average.
  • Each chart bar is matched to the higher-timeframe bar that contains it.
  • Steps mode: every chart bar shows the value of its higher-timeframe bar, so the line is flat for one higher-timeframe bar and then steps to the next value. This is exactly what the higher-timeframe chart shows.
  • Smoothed mode: the line runs straight from the previous higher-timeframe value to the current one across the chart bars of that period, based on how much of the higher-timeframe bar has passed.
  • Only the chart bars inside the forming higher-timeframe bar are recalculated on each tick.
  • If the chosen timeframe is lower than the chart timeframe, the chart timeframe is used instead.

Inputs

InputDefaultWhat it does
TimeframeH4Timeframe the average is calculated on
Period50Moving average period in higher-timeframe bars
MethodEMASMA, EMA, SMMA or LWMA
PriceClosePrice used
Drawing modeStepsSteps or smoothed line
ColourOrangeLine colour
Width2Line width (1-5)
Chart bars to draw5000Limit for speed (0 = all)

How to use it

  1. In MetaTrader open File > Open Data Folder.
  2. MT4: copy FXN_MTFMovingAverage.mq4 into MQL4/Indicators. MT5: copy FXN_MTFMovingAverage.mq5 into MQL5/Indicators.
  3. Right-click Indicators in the Navigator and choose Refresh (or restart the terminal). The file compiles on first use; you can also open it in MetaEditor and press Compile.
  4. Drag the indicator onto a chart and set the inputs.

Popular choices are the H4 EMA 50 on M15-H1 charts and the D1 SMA 200 on H1-H4 charts. You can attach it several times with different settings, for example H4 EMA 50 and D1 EMA 200. Many traders only take trades in the direction of the higher-timeframe average or use it as a dynamic level.

Good to know

  • The current higher-timeframe value moves until that bar closes, exactly like the average on the higher-timeframe chart. All earlier values are fixed.
  • In smoothed mode, history bars inside a higher-timeframe period lean towards that period's final value, which was not known at the time. Use smoothed mode for a cleaner picture and steps mode when you want what was really visible live.
  • The higher-timeframe history must be available. On a fresh terminal the line appears once that history has loaded (usually after the next tick).
  • It draws a line only; it does not generate signals or trade.

Trading carries risk. Test on a demo account first; past results do not predict future results.

Settings read from the code

InputTypeDefaultNote
InpSep1string=== Moving average ===---- Moving average ----
InpTimeframeENUM_TIMEFRAMESPERIOD_H4Higher timeframe to take the average from
InpPeriodint50Moving average period (in higher-timeframe bars)
InpMethodENUM_MA_METHODMODE_EMAMoving average type
InpPriceENUM_APPLIED_PRICEPRICE_CLOSEPrice used
InpSep2string=== Display ===---- Display ----
InpDrawModeENUM_MTF_DRAWMTF_STEPDrawing mode
InpColorcolorclrOrangeLine colour
InpWidthint2Line width (1-5)
InpMaxBarsint5000Chart bars to draw (0 = all bars)

How to use it

  1. Download the compiled file (or the source and compile it in MetaEditor).
  2. Put it in MetaTrader: File → Open Data Folder → MQL4 → Indicators, then refresh the Navigator.
  3. Test it on a demo account before any real money.
  4. Want changes? Open a copy in your Lab and ask for them in plain words.