ความผันผวน VolatilityRisk SizingFilter มีใน Builder

Average True Range (ATR)

ATR

ATR measures how far an instrument typically travels in one bar, including the gaps between bars. It says nothing about direction — which is exactly why it is the standard way to size stops, set breakout distances, and tell a calm market from a violent one.

Default period
14
Direction
None
Units
Price
OverboughtOversoldCentreline 50Divergence

ภาพประกอบ — ข้อมูลสังเคราะห์ ไม่ใช่ราคาจริง

What ATR tells you

ATR answers one question: how much room does this instrument need right now? It averages the true range of recent bars — the full distance travelled, gaps included — and returns it in price units. A rule built on ATR adapts to the market instead of assuming a fixed pip distance is always right.

  • Rising ATR: bars are getting larger — volatility is expanding
  • Falling ATR: the market is compressing, not necessarily reversing
  • ATR has no direction — it never says up or down
  1. 1 Measure each bar's true range
  2. 2 Smooth it over the chosen period
  3. 3 Read the result in price units
แสดงสูตรและรายละเอียดการคำนวณ

ATR is built from true range, which is deliberately larger than the visible bar when the market gaps:

  1. For each bar, take the largest of three distances: high minus low, the absolute distance from the previous close up to this high, and the absolute distance from the previous close down to this low. That is the bar’s true range.
  2. Average true range over the chosen period.
  3. Read the result in the instrument’s own price units — 0.0012 on a 5-digit FX pair, 4.10 on an index.

Including the previous close is the whole point of the “true” in true range: a market that gaps 40 pips overnight and then trades in a narrow band has moved 40 pips, even though the bar itself looks small. A plain high-minus-low average would miss that entirely.

Step 2 hides a platform detail that is worth stating plainly, because Wilder’s own ATR and MetaTrader’s are not the same average. Wilder smooths: each bar updates a running value that never forgets anything, only decays it. ATR.mq5, bundled with the terminal under Indicators/Examples, rolls a window instead:

Wilder     ATR[i] = (ATR[i-1] * (N-1) + TR[i]) / N
MetaTrader ATR[i] =  ATR[i-1] + (TR[i] - TR[i-N]) / N     <- a simple moving average

The recurrence in the second line looks like a smoothing, but subtracting the true range from N bars ago is what a rolling window does. Both are linear filters whose weights sum to one, so their long-run averages agree — measured over 2,700 bars at period 20, 9.571 against 9.573 pips. The difference is timing: on a series whose volatility tripled at a fixed bar, MetaTrader’s version reached 90% of the new level in 19 bars and Wilder’s took 59. Matching the period does not merge them either; the closest iATR period to Wilder’s ATR at 20 was measured at 32–33, not the 39 that matching the centre of mass predicts. Where this matters most is any indicator that uses ATR as a width — the Keltner Channel page follows that consequence through.

In MQL5 the call is iATR(symbol, period, ma_period) and it returns a handle to a single buffer. There is no applied-price argument — true range is already defined from the high, the low and the previous close. It is also written in an unfamiliar but equivalent form in the source: max(high, close_prev) - min(low, close_prev), which is the same quantity as the maximum of the three distances above — measured across 44,985 gapped bars the two forms differ by exactly zero. J. Welles Wilder introduced ATR in 1978, alongside RSI.

สัญญาณ

สัญญาณที่ backtest ได้ของ ATR — และสภาวะตลาดที่เหมาะสมกับแต่ละสัญญาณ

Volatility Contraction

พร้อมใช้ใน Builder
เงื่อนไข
ATR falls to a local low relative to a longer ATR
สภาวะที่ดีที่สุด
Pre-breakout
การใช้งานทั่วไป
Wait for expansion rather than trading the quiet

Volatility Expansion

พร้อมใช้ใน Builder
เงื่อนไข
A short ATR rises above a long ATR
สภาวะที่ดีที่สุด
Breakouts
การใช้งานทั่วไป
Confirm a break is happening on real range, not a single wick

Stop and Target Sizing

พร้อมใช้ใน Builder
เงื่อนไข
Stop distance set as a multiple of current ATR
สภาวะที่ดีที่สุด
Any
การใช้งานทั่วไป
Keep risk per trade constant as volatility changes

Regime Classification

ตรรกะขั้นสูง
เงื่อนไข
ATR relative to its own long-run distribution
สภาวะที่ดีที่สุด
Any
การใช้งานทั่วไป
Switch strategy behaviour between calm and violent regimes

การทำงานจริงใน MT5

สิ่งที่ MetaTrader 5 คำนวณและวาดจริง — เกณฑ์อ้างอิงของทุกกฎในหน้านี้

บัฟเฟอร์

ดัชนี บัฟเฟอร์ MT5 วาดเป็น เก็บค่าอะไร
0 MAIN_LINE Line The smoothed average of true range, in the instrument's price units. Always positive; it has no zero line and no upper bound.

ข้อสังเกตของแพลตฟอร์ม

ทำงานได้ดีที่สุด / ใช้อย่างระมัดระวัง

ไม่มีอินดิเคเตอร์ใดที่ได้เปรียบในทุกสภาวะ นี่คือจุดที่ ATR ช่วยได้ — และจุดที่มันทำให้เข้าใจผิด

ทำงานได้ดีที่สุด

  • Sizing stops and targets
  • Confirming breakouts
  • Comparing regimes on one instrument
  • As a filter on top of a directional signal

ใช้อย่างระมัดระวัง

  • As a directional signal
  • Comparing raw ATR across instruments
  • Fixed pip thresholds on ATR
  • Very short periods on low timeframes

สร้างกลยุทธ์ ATR

เชื่อมสัญญาณเข้ากับกฎการเปิดและปิดออเดอร์ จากนั้นส่งออก EA MT5 ที่คอมไพล์ได้ — ไม่ต้องเขียนโค้ด

  1. Fast ATR (14)
  2. Slow ATR (50)
  3. Fast ATR above slow ATR
  4. Price breaks the upper fractal → Open Buy · SL 50 / TP 100
  5. Price breaks the lower fractal → Open Sell

รวม ATR กับอินดิเคเตอร์อื่น

อินดิเคเตอร์เดี่ยวแทบไม่เพียงพอ การจับคู่เหล่านี้ครอบคลุมจุดบอดของ ATR

ATR + DeMarker

  1. ATR below its value 20 bars ago
  2. DeMarker below 0.3
  3. Buy
เหตุผล
Use ATR the other way round — not to confirm expansion but to require contraction, so an exhaustion reading is only faded once the market has stopped making genuinely new ground
สภาวะที่ดีที่สุด
Ranging
สร้างกลยุทธ์นี้ →

ATR + Fractals

  1. Fast ATR above slow ATR
  2. Price breaks the last fractal
  3. Buy
เหตุผล
Only take a swing-level breakout when volatility is genuinely expanding, so a break on a dead bar never triggers the trade
สภาวะที่ดีที่สุด
Breakout
สร้างกลยุทธ์นี้ →

ATR + Moving Average

  1. Fast MA crosses slow
  2. ATR sets the stop distance
  3. Buy
เหตุผล
Take the direction from the trend and the distance from volatility, so the same rule behaves the same way in calm and violent markets
สภาวะที่ดีที่สุด
Trend

No single-flow template pairs ATR with a moving average. Start from MA Crossover and add an ATR node feeding a risk-based lot or a stop node.

เปิด Builder →

ATR + Bollinger Bands

  1. Bands narrow
  2. ATR at a local low
  3. Wait for expansion
เหตุผล
Cross-check a band squeeze against a falling ATR, since both describe compression but measure it differently
สภาวะที่ดีที่สุด
Pre-breakout

No single-flow template pairs ATR with Bollinger Bands. Start from Bollinger Bounce and add ATR nodes with a Compare between a fast and a slow period.

เปิด Builder →

ATR + Supertrend

  1. ATR expanding
  2. Supertrend flips up
  3. Buy
เหตุผล
Supertrend is ATR turned into a direction: its band sits a fixed multiple of this reading from each bar's midpoint, so the width you see here is literally the room the trend is being given. Reading them together shows why a flip happened — through a band that had widened, or through one that volatility had collapsed onto price
สภาวะที่ดีที่สุด
Trending

The Supertrend Flip template already trails its stop at 3 × ATR(10), the same width its band uses. To require the width to be expanding as well, add two ATR nodes at different shifts with a Compare between them.

เปิด Builder →

พารามิเตอร์

ค่าเริ่มต้นสำหรับตรวจสอบบนคู่และกรอบเวลาของคุณเอง — ไม่ใช่การตั้งค่าที่รับประกัน

พารามิเตอร์ ค่าเริ่มต้น ช่วงที่แนะนำให้ทดสอบ หน้าที่
Period 14 5–50 How many bars of true range are smoothed. Wilder's 14 is the standard; shorter reacts to a single violent bar, longer describes the session rather than the moment.
Shift 0 0–3 Which bar back the value is read from. Reading shift 1 compares against a fully closed bar, which some rules prefer over the forming one.
Multiple (your rule) 1.5–2.0 1.0–4.0 Not an indicator input — the factor your strategy multiplies ATR by to get a stop or breakout distance. Listed here because it is the number that actually needs testing.

ค่าตั้งต้นเริ่มต้น

Reactive 7 Follows single-bar shocks
Standard 14 Wilder's default baseline
Regime 50 Describes the session, not the bar

ตัวอย่างในตลาด

ที่ ATR ทำงานได้ ที่มันล้มเหลว และตัวกรองเปลี่ยนผลลัพธ์อย่างไร

ทำงานได้

Expansion confirms the break

A range resolves and ATR rises with it; the breakout has real range behind it rather than a single stretched wick.

ล้มเหลว

Fixed stop in a violent session

The same fixed pip stop that survived a quiet week is taken out by ordinary noise once bars double in size — the loss ATR sizing exists to avoid.

ถูกกรอง

Contraction suppresses the trade

The directional signal fires but ATR is at a local low, so the entry is skipped and the market goes on to drift sideways.

FAQ

What ATR period should I use?
14 is Wilder's default and the right starting point. Shorter periods react to a single violent bar and make stop distances jump around; longer periods describe the session rather than the current moment. Treat 14 as a documented baseline to re-validate on your pair and timeframe, not as portable truth.
Does ATR tell me which way price will go?
No, and it cannot. True range is a distance, so ATR is always positive and carries no sign. It tells you how much room a move needs; something else has to tell you the direction. Any strategy that appears to trade ATR directionally is really trading whatever is feeding it the direction.
Why does ATR have no applied-price setting?
Because true range is already defined from three prices: the current high, the current low, and the previous close. There is no single series to pick, so MQL5's iATR takes only a period. An applied-price input on an ATR is a sign the indicator is not the standard one.
How many ATRs should my stop be?
There is no correct multiple, only a trade-off: a tighter stop is hit by noise more often, a wider one costs more when it is hit. 1.5 to 2 ATR is a common starting band. Test the multiple like any other parameter, and remember that changing it changes position size if your lot is risk-based.
Can I build an ATR EA without coding?
Yes, as a filter and as a sizing input. The Fractal Breakout template uses two ATR nodes with different periods and a Compare to require expanding volatility, and the Builder's risk-based lot node can take a volatility-derived distance. Classifying volatility against its own long-run distribution is the exception and needs custom MQL5.
How should I validate settings before going live?
Backtest on quality tick data first, then run the EA on a demo account before risking money. When optimising, hold back data the search never saw and prefer settings that stay profitable across periods over the single in-sample peak — chasing that peak is overfitting the noise. No default or preset here is a performance promise; every value is a starting point to re-validate on your own pair and broker.