ATR Levels mtf dragan
- 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.3
- Attivazioni: 5
**ATR Levels MTF Dragan** draws the volatility levels of a higher-timeframe candle on the chart you trade from. The moment a candle of the selected timeframe opens, the indicator fixes its open price as a base line and places two ATR levels above it and two below it. The lines stay exactly where they are until the candle closes, so what you see during the candle is what you would have seen at its open — nothing is recalculated afterwards and nothing repaints. A sixth, dotted line follows the middle of the candle while it forms.
**How the levels are built**
- Base line = open of the current candle of the selected timeframe.
- Upper 1 = Open + M1 × ATR, Upper 2 = Open + M2 × ATR.
- Lower 1 = Open − M1 × ATR, Lower 2 = Open − M2 × ATR.
- ATR = average True Range of the last N closed candles of that timeframe, i.e. the value the standard ATR shows on the previous candle. Because only closed candles are used, all five levels are known in the first second of the new candle.
- Middle = (High + Low) / 2 of the candle: for the current candle it moves with every new high or low, for a closed candle it is the final middle.
**Key features**
- Multi-timeframe: pick any timeframe equal to or higher than the chart (for example H1 levels on an M5 chart, D1 levels on an M15 chart). The lines of the current candle run from its open to its close time, so you always see how much of the candle is left.
- No repainting: levels are fixed at the candle open; the only moving line is the middle of the candle, and it moves by definition.
- Two adjustable multipliers with separate colors for each of the four ATR levels, adjustable width and style; the base line and the middle line have their own color, width and style.
- History: the lines of the last N closed candles stay on the chart as shortened segments, so you can review how price behaved around the levels; the length of these segments is adjustable.
- Price labels next to the current bar: open and ATR value, the four levels and the middle.
- Hidden buffers for Expert Advisors: the same levels and the ATR for every chart bar, plus the middle of the candle as it stood at that bar, so the values can be read with CopyBuffer or iCustom and used in the Strategy Tester.
- Light on resources: the levels are calculated once per candle, on other ticks the indicator only updates the middle line and the labels.
**How it can be used**
- Volatility breakout: a move beyond Upper 1 or Lower 1 shows that the candle is already travelling one ATR from its open; Level 2 marks an unusually large candle.
- Targets and stops: Level 1 or Level 2 as a take profit for intraday entries, the base line or the opposite level as a stop reference.
- Mean reversion: distance from the base line in ATR units, with the middle of the candle as a trailing reference for exits.
- Context for lower-timeframe setups: trade M5 or M15 signals only when they line up with the H1 or H4 levels.
**Inputs**
Timeframe and ATR
- Candle timeframe — PERIOD_CURRENT uses the chart timeframe; a lower timeframe than the chart is replaced by the chart timeframe. Default H1.
- ATR period — closed candles of that timeframe, default 14.
- Multiplier 1 — inner levels, default 1.0.
- Multiplier 2 — outer levels, default 2.0.
Lines
- Keep the lines of the last N closed candles — default 30 (0 = current candle only).
- Closed candles: line length in % of the candle duration — default 50.
- Current candle: extend the lines to the right edge — default off (the lines end at the candle close time).
- Draw the base line, base line color and width; colors of Upper 1, Upper 2, Lower 1, Lower 2; width and style of the ATR levels.
Middle of the candle
- Sixth line: middle of the current candle — default on; middle line also for the closed candles — default on; color, width, style.
Labels
- Price labels at the current bar — default on; font size; object name prefix (change it to run several copies of the indicator on one chart).
Buffers
- Candles of the selected timeframe to fill into the hidden buffers — default 500 (0 = whole history).
**Buffers (for Expert Advisor developers)**
- 0 — base line (open of the candle)
- 1 — Upper 1
- 2 — Upper 2
- 3 — Lower 1
- 4 — Lower 2
- 5 — ATR used for the levels
- 6 — middle of the candle as it stood at that bar (running high/low from the candle open)
Buffers 0–5 hold the same value for every chart bar of one candle. Buffer 6 changes from bar to bar within the candle; on the current bar it is the current middle.
Example — reading the H1 levels from an EA on any chart:
```
int handle = iCustom(_Symbol, _Period, "Market\\ATR Levels MTF Dragan MT5", PERIOD_H1);
double up1[], dn1[], mid[];
if(CopyBuffer(handle, 1, 0, 1, up1) == 1 && CopyBuffer(handle, 3, 0, 1, dn1) == 1 && CopyBuffer(handle, 6, 0, 1, mid) == 1
&& up1[0] != EMPTY_VALUE)
{
// up1[0] / dn1[0] are the H1 levels of the current candle, mid[0] its current middle
}
```
**Notes**
- The levels are built from the candles of the selected timeframe, so they are identical to what you would see 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.
