On Balance Volume
OBV
OBV adds the bar's volume to a running total when price closes up and subtracts it when price closes down. It is the simplest way to ask whether a move has participation behind it — but on a retail forex chart the volume it counts is tick volume, which is not the same thing as money.
- Period
- None
- Volume used
- Tick
- Zero line
- None
ภาพประกอบ — ข้อมูลสังเคราะห์ ไม่ใช่ราคาจริง
What OBV tells you
OBV keeps one running total. Every bar that closes higher adds that bar's volume; every bar that closes lower subtracts it. The idea is that participation should lead price — if the total keeps climbing while price stalls, buyers are still arriving. What it cannot tell you is how much was traded, because on most retail forex feeds the number being accumulated is a count of price changes, not a quantity.
- Rising OBV: up-closing bars are carrying more volume than down-closing ones
- Falling OBV: the reverse
- The absolute value means nothing — only the direction does
- 1 Compare this close with the previous one
- 2 Add the bar's volume if up, subtract if down
- 3 Carry the running total forward
แสดงสูตรและรายละเอียดการคำนวณ
On Balance Volume is a running total with one rule per bar:
- Compare this bar’s close with the previous bar’s close.
- If it closed higher, add this bar’s volume to the total. If it closed lower, subtract it. If they are equal, leave the total alone.
- Carry the result forward to the next bar.
OBV = OBVprev ± Volume, and that is the whole calculation. There is no period, no smoothing and no scaling, which is why the indicator has no settings to tune and why its output has no bounds.
The reasoning behind it is that volume should lead price: if the total keeps rising while price moves sideways, buying is being absorbed and the move is more likely to resolve upward. That reasoning depends entirely on the volume series meaning what it is supposed to mean. On an exchange-traded instrument it does. On a retail forex pair the terminal reports tick volume — the number of quote updates in the bar — so OBV there accumulates activity rather than money, and a burst of small updates counts the same as genuine size.
In MQL5 the call is iOBV(symbol, period, applied_volume) where period is the timeframe and applied_volume is VOLUME_TICK or VOLUME_REAL. There is no applied-price argument — the direction comes from comparing closes internally, and the only thing you choose is which volume series to accumulate. The Builder’s generated code passes VOLUME_TICK.
สัญญาณ
สัญญาณที่ backtest ได้ของ OBV — และสภาวะตลาดที่เหมาะสมกับแต่ละสัญญาณ
Breakout Confirmation
พร้อมใช้ใน BuilderDivergence from Price
ตรรกะขั้นสูงOBV Trendline Break
ตีความด้วยตนเองการทำงานจริงใน MT5
สิ่งที่ MetaTrader 5 คำนวณและวาดจริง — เกณฑ์อ้างอิงของทุกกฎในหน้านี้
บัฟเฟอร์
| ดัชนี | บัฟเฟอร์ | MT5 วาดเป็น | เก็บค่าอะไร |
|---|---|---|---|
| 0 | MAIN_LINE | Line | The running total itself. It has no upper or lower bound and no natural origin — the value depends on how far back the chart's history goes, so only its direction and its relation to its own earlier values carry information. |
ข้อสังเกตของแพลตฟอร์ม
ทำงานได้ดีที่สุด / ใช้อย่างระมัดระวัง
ไม่มีอินดิเคเตอร์ใดที่ได้เปรียบในทุกสภาวะ นี่คือจุดที่ OBV ช่วยได้ — และจุดที่มันทำให้เข้าใจผิด
ทำงานได้ดีที่สุด
- Confirming a breakout rather than initiating one
- Instruments where the broker supplies real volume
- Higher timeframes, where tick counts are less erratic
- Comparisons against OBV's own recent values
ใช้อย่างระมัดระวัง
- Any absolute threshold on the value
- Comparing OBV across instruments or brokers
- Treating tick volume as traded volume
- Divergence read by eye without a defined rule
สร้างกลยุทธ์ OBV
เชื่อมสัญญาณเข้ากับกฎการเปิดและปิดออเดอร์ จากนั้นส่งออก EA MT5 ที่คอมไพล์ได้ — ไม่ต้องเขียนโค้ด
- OBV read at the current bar
- A second OBV node read 20 bars back
- Compare the two — rising means accumulation
- Price crosses the upper Bollinger band and OBV is rising → Open Buy · SL 50 / TP 150
- Price crosses the lower band and OBV is falling → Open Sell
- Stop then trails behind the recent swing
รวม OBV กับอินดิเคเตอร์อื่น
อินดิเคเตอร์เดี่ยวแทบไม่เพียงพอ การจับคู่เหล่านี้ครอบคลุมจุดบอดของ OBV
OBV + Bollinger Bands
- Price crosses the upper band
- OBV above its value 20 bars ago
- Buy
OBV + Moving Average
- Price above the EMA
- OBV rising
- Buy
No single-flow template pairs OBV with a moving average. Start from OBV Confirmation + Bollinger Breakout and swap the band cross for an MA node with a Compare against price.
เปิด Builder →OBV + MFI
- OBV rising
- MFI below 20
- Buy
No single-flow template pairs OBV with MFI. Start from OBV Confirmation + Bollinger Breakout and add an MFI node with a Compare at 20, replacing the band condition.
เปิด Builder →OBV + Force Index
- OBV above its value 20 bars ago
- Force Index crosses above zero
- Buy
No single-flow template pairs the two. Start from OBV Confirmation + Bollinger Breakout and swap the band cross for a Force Index node crossed against a Constant of 0 — Force Index has a zero to cross, which OBV does not.
เปิด Builder →OBV + Chaikin Oscillator
- OBV above its value 20 bars ago
- Chaikin above zero
- Buy
No single-flow template pairs the two. Start from OBV Confirmation + Bollinger Breakout and swap the band cross for a Chaikin node compared against a Constant of 0 — Chaikin has a zero to compare against, which OBV does not.
เปิด Builder →พารามิเตอร์
ค่าเริ่มต้นสำหรับตรวจสอบบนคู่และกรอบเวลาของคุณเอง — ไม่ใช่การตั้งค่าที่รับประกัน
| พารามิเตอร์ | ค่าเริ่มต้น | ช่วงที่แนะนำให้ทดสอบ | หน้าที่ |
|---|---|---|---|
| Applied volume | Tick volume | — | iOBV's only real argument besides symbol and timeframe. MQL5 accepts VOLUME_TICK or VOLUME_REAL, but the Builder's generated code fixes it to tick volume, which is the series retail forex feeds actually populate. |
| Period | — | — | There is none. Unlike almost every other indicator, OBV has no averaging window — it is a running total from the start of the loaded history, so there is nothing here to optimise. |
| Shift | 0 | 0–30 | Which bar back the node reads the buffer from. Because OBV has no threshold to compare against, two nodes at different shifts are the normal way to express 'is it rising' — that is exactly what the template does with 0 and 20. |
ค่าตั้งต้นเริ่มต้น
ตัวอย่างในตลาด
ที่ OBV ทำงานได้ ที่มันล้มเหลว และตัวกรองเปลี่ยนผลลัพธ์อย่างไร
Break with flow behind it
Price clears the upper band and OBV is already well above where it sat twenty bars earlier — participation arrived before the break and continued after it.
Break on nothing
The same band break happens but OBV is flat or lower than it was. Price pokes through and falls back, which is the case the confirmation exists to filter.
The confirmation blocks the trade
A cluster of band touches in a quiet stretch is skipped entirely because the running total never turns up, and the account avoids a series of small losses.
อินดิเคเตอร์ที่เกี่ยวข้อง
FAQ
- Is the volume in MT5 real volume?
- On retail forex, no. There is no central exchange for spot FX, so the terminal reports tick volume — how many times the quote changed during the bar. It correlates with activity and is genuinely useful as a participation proxy, but it is a count of updates, not a quantity traded. MQL5 does define VOLUME_REAL for instruments where the broker supplies it, and iOBV accepts it, but the Builder's generated code passes VOLUME_TICK.
- What period should I use for OBV?
- There is no period. OBV is a running total with no averaging window, which is unusual and is the reason there is nothing to optimise on the indicator itself. The number you choose is the comparison distance — how far back you look to decide whether the total is rising — and that lives in your rule, not in iOBV.
- Why can't I just use a threshold like 'OBV above 100,000'?
- Because the value depends on where the chart's history starts. Load more bars and every OBV reading changes. Two terminals on the same pair can show totals that differ by orders of magnitude, so a fixed level is meaningless and will behave differently on your broker than in a backtest with different history depth.
- How do I read OBV divergence in an EA?
- You have to define it first. Divergence means the sequence of price extremes disagrees with the sequence of OBV extremes, which needs swing detection on both series and memory across many bars. The node palette expresses single-bar comparisons, so the slope check is buildable today and divergence needs custom MQL5.
- Can I build an OBV EA without coding?
- Yes, as a confirmation. The OBV Confirmation + Bollinger Breakout template places two OBV nodes — one at the current bar, one twenty bars back — compares them to establish direction, and requires that agreement before acting on a band break. The lookback distance and the band settings are all EA inputs.
- 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. Be aware that OBV's input is your broker's tick count, so results are more broker-dependent than for a price-only indicator — a backtest on one feed's tick data does not transfer as cleanly as usual. Hold back data the search never saw and prefer settings that stay profitable across periods.
บทความที่เกี่ยวข้อง
Glossary