MA MTF midlle
- Indicadores
-
Dragan Joksimovic
MQL4 / MQL5 Expert Advisor and Indicator Developer
I develop and test Expert Advisors, indicators and trading utilities for MetaTrader 4 and MetaTrader 5 based on clearly defined trading rules.
My work includes:
• Expert Advisors for MT4 and MT5
• Custom indicators - Versão: 1.0
- Ativações: 5
**MA MTF Middle** puts the standard Moving Average of a higher timeframe on the chart you trade from — for example the H1 moving average on an M5 chart — with exactly the inputs you know from the built-in Moving Average: period, shift, method (simple, exponential, smoothed, linear weighted) and the price it is applied to, plus the timeframe. Next to it the indicator draws a second line: the middle of the current candle of that timeframe, the price halfway between its high and its low.
**How it works**
- The moving average is calculated on the candles of the selected timeframe with the same algorithms as the built-in Moving Average, so its values are identical to the standard indicator on that timeframe's own chart. On a lower chart it is drawn as steps — one value per candle — or, optionally, smoothed between the candles. The value of the current candle changes with price until the candle closes, exactly as on the candle's own chart.
- The middle line is a horizontal segment from the open of the current candle to its close time. It moves with every new high or low of the candle, so at any moment it shows where the middle of the candle in progress is. When the next candle opens a new segment starts; the middle of the last closed candles can stay on the chart as shortened segments.
**Key features**
- Multi-timeframe: any timeframe equal to or higher than the chart, on any symbol.
- Same inputs as the standard Moving Average, so settings you already use can be copied one to one.
- Steps or smoothed line; adjustable colors, width and style of the moving average and of the middle line.
- History of the middle of closed candles, with adjustable length of the segments.
- Price labels next to the current bar for the moving average and the middle.
- Hidden buffers for Expert Advisors: the moving average as drawn, the exact moving average of the candle, the middle of the candle as it stood at every bar and a state value (+1 middle above the average, −1 below), so the indicator can be read with CopyBuffer or iCustom and used in the Strategy Tester.
- Light on resources: the average is calculated once per candle, the other ticks only move the middle line and the labels.
**How it can be used**
- Trend filter from a higher timeframe: trade lower-timeframe signals only in the direction of the higher-timeframe average.
- Crossing of the candle middle over the average as a signal that the whole candle — not just its close — has moved to the other side of the trend line.
- Dynamic support and resistance from a higher timeframe without switching charts.
**What you can adjust**
Timeframe, period, shift, method, apply to; steps or smoothed line; colors, width and style of both lines; middle line on/off, number of closed candles kept, length of their segments, extension of the current segment to the right edge; labels and font size; object name prefix (to run several copies on one chart); depth of history filled into the buffers.
**Buffers (for Expert Advisor developers)**
- 0 — moving average as drawn (steps or smoothed)
- 1 — moving average of the candle (exact value, one per candle)
- 2 — middle of the candle as it stood at that bar
- 3 — state: +1 middle above the average, −1 below, 0 equal or no data
Example — reading the H1 average and the middle from an EA on any chart:
```
int handle = iCustom(_Symbol, _Period, "Market\\MA MTF Middle MT5", PERIOD_H1);
double ma[], mid[];
if(CopyBuffer(handle, 1, 0, 1, ma) == 1 && CopyBuffer(handle, 2, 0, 1, mid) == 1 && ma[0] != EMPTY_VALUE)
{
// ma[0] is the H1 moving average of the current candle, mid[0] its current middle
}
```
**Notes**
- The average is built from the candles of the selected timeframe, so it is identical to the standard Moving Average on that timeframe's own chart.
- The indicator draws with chart objects (prefix adjustable) and cleans them up when it is removed.
- The indicator does not open trades and does not use any DLL or external files.
