MA Channel MTF midlle
- Indicatori
-
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 - Versione: 1.0
- Attivazioni: 5
**MA Channel MTF Middle** draws a moving-average channel of a higher timeframe on the chart you trade from: the upper line is the moving average of the candle highs, the lower line the moving average of the candle lows. The inputs are the ones you know from the built-in Moving Average — period, shift and method — plus the timeframe. A third line marks the middle of the current candle of that timeframe, the price halfway between its high and its low.
**How it works**
- Both averages are calculated on the candles of the selected timeframe with the same algorithms as the built-in Moving Average applied to High and to Low, so the channel is identical to two standard averages on that timeframe's own chart. On a lower chart the lines are drawn as steps — one value per candle — or, optionally, smoothed between the candles. The values of the current candle change with price until the candle closes.
- 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. When the next candle opens a new segment starts; the middle of the last closed candles can stay on the chart as shortened segments.
- Price inside the channel is between the average high and the average low of the last candles; a candle whose middle is above the channel has moved beyond the recent highs, one whose middle is below it beyond the recent lows.
**Key features**
- Multi-timeframe: any timeframe equal to or higher than the chart, on any symbol.
- Same inputs as the standard Moving Average, applied to highs and lows.
- Steps or smoothed lines; separate colors for the upper and the lower line, adjustable width and style; own color, width and style for the middle line.
- History of the middle of closed candles, with adjustable length of the segments.
- Price labels next to the current bar for both channel lines and the middle.
- Hidden buffers for Expert Advisors: both lines as drawn, the exact values of the candle, the middle of the candle as it stood at every bar and a state value (+1 middle above the channel, −1 below, 0 inside), readable with CopyBuffer or iCustom and usable in the Strategy Tester.
- Light on resources: the averages are calculated once per candle, the other ticks only move the middle line and the labels.
**How it can be used**
- Breakout trading: the middle of the candle leaving the channel upwards or downwards.
- Trend filter from a higher timeframe: long setups only above the channel, short setups only below it, no trades inside.
- Dynamic support and resistance band from a higher timeframe without switching charts.
**What you can adjust**
Timeframe, period, shift, method; steps or smoothed lines; colors, width and style of the channel lines and of the middle line; 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 — upper line as drawn
- 1 — lower line as drawn
- 2 — upper moving average of the candle (exact value)
- 3 — lower moving average of the candle (exact value)
- 4 — middle of the candle as it stood at that bar
- 5 — state: +1 middle above the channel, −1 below, 0 inside
Example — reading the H1 channel and the middle from an EA on any chart:
```
int handle = iCustom(_Symbol, _Period, "Market\\MA Channel MTF Middle MT5", PERIOD_H1);
double up[], dn[], mid[];
if(CopyBuffer(handle, 2, 0, 1, up) == 1 && CopyBuffer(handle, 3, 0, 1, dn) == 1 && CopyBuffer(handle, 4, 0, 1, mid) == 1
&& up[0] != EMPTY_VALUE)
{
// up[0] / dn[0] are the H1 channel lines of the current candle, mid[0] its current middle
}
```
**Notes**
- The channel is built from the candles of the selected timeframe, so it is identical to the standard Moving Average applied to High and to Low 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.
