# MTF Moving Average Indicator for MT5

> 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.

## At a glance

- What it is: A free Indicator for MetaTrader 5, written in MQL5.
- 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: 8 inputs
- Lab check: Compiled with MetaEditor build 6333 for MT5 on 1 Dec 2026: 0 errors, 0 warnings.
- Price: Free to download
- Page: https://hub.fxnook.com/mtf-moving-average-indicator-for-mt5
- Download (compiled): https://hub.fxnook.com/download/960639e0-30c6-48ea-85d4-e9eaad648b52/compiled
- Download (source): https://hub.fxnook.com/download/960639e0-30c6-48ea-85d4-e9eaad648b52/source

## About

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

| 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

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 (inputs)

| Input | Type | Default | Note |
|---|---|---|---|
| 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 |
| 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) |

Tags: moving-average, mtf, multi-timeframe, ema, sma, trend, indicator

Shared code is the author's work, not financial advice. Test on a demo account first.
