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
Timeframewith 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
| Input | Default | What it does |
|---|---|---|
| Timeframe | H4 | Timeframe the average is calculated on |
| Period | 50 | Moving average period in higher-timeframe bars |
| Method | EMA | SMA, EMA, SMMA or LWMA |
| Price | Close | Price used |
| Drawing mode | Steps | Steps or smoothed line |
| Colour | Orange | Line colour |
| Width | 2 | Line width (1-5) |
| Chart bars to draw | 5000 | Limit for speed (0 = all) |
How to use it
- In MetaTrader open File > Open Data Folder.
- MT4: copy
FXN_MTFMovingAverage.mq4intoMQL4/Indicators. MT5: copyFXN_MTFMovingAverage.mq5intoMQL5/Indicators. - 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.
- 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
| Input | Type | Default | Note |
|---|---|---|---|
| InpSep1 | string | === Moving average === | ---- Moving average ---- |
| InpTimeframe | ENUM_TIMEFRAMES | PERIOD_H4 | Higher timeframe to take the average from |
| InpPeriod | int | 50 | Moving average period (in higher-timeframe bars) |
| InpMethod | ENUM_MA_METHOD | MODE_EMA | Moving average type |
| InpPrice | ENUM_APPLIED_PRICE | PRICE_CLOSE | Price used |
| InpSep2 | string | === Display === | ---- Display ---- |
| InpDrawMode | ENUM_MTF_DRAW | MTF_STEP | Drawing mode |
| InpColor | color | clrOrange | Line colour |
| InpWidth | int | 2 | Line width (1-5) |
| InpMaxBars | int | 5000 | Chart bars to draw (0 = all bars) |
How to use it
- Download the compiled file (or the source and compile it in MetaEditor).
- Put it in MetaTrader: File → Open Data Folder → MQL4 → Indicators, then refresh the Navigator.
- Test it on a demo account before any real money.
- Want changes? Open a copy in your Lab and ask for them in plain words.