Refine OBV
- Indicadores
- Versão: 1.0
Refine OBV
Cumulative volume flow, read against its own adaptive signal line – with a color-coded spread and non-repainting divergence detection.
Raw On Balance Volume answers one question: is volume being credited to the buyers or the sellers? That is useful, but on its own it is a single wandering line with no reference point. Refine OBV adds the reference – an EMA of the flow itself. The distance between the two, the spread, is drawn as a color-coded cloud, so you can see at a glance which side holds the flow and whether that side is still pressing or already backing off.
On top of that, confirmed swing pivots in price are compared against the flow at the same bars. When price makes a new extreme that the flow refuses to confirm, the divergence is drawn and labelled.
Three things you are meant to read from it:
- Which side owns the flow – cloud above or below its signal
- Whether conviction is intact – bright or dark shade of the cloud
- Whether price is lying – divergence lines
What you see
Flow spread – the histogram cloud
| Shade | State | Reading |
|---|---|---|
| Bright green | Accumulation building | Flow is above its signal and the gap is still widening – the bid side is pressing. |
| Dark green | Accumulation fading | Flow is still above its signal, but the gap is narrowing – buyers are losing conviction. |
| Bright red | Distribution building | Flow is below its signal and falling further away – the offer side is pressing. |
| Dark red | Distribution fading | Flow is still below its signal, but the gap is closing – selling pressure is draining. |
The shade is the early part. The side changes only when the cloud crosses; the shade changes while it is still on the same side, which is what makes it a warning rather than a confirmation.
Lines and markers
- OBV (solid blue) – cumulative volume flow, the upper edge of the cloud.
- Signal (dashed gold) – the adaptive EMA of the flow, the lower edge of the cloud.
- Divergence lines – drawn across the two pivots that disagree, tagged Bear Div or Bull Div at the confirming end.
Bear Div – price printed a higher high, the flow printed a lower high. The advance is being sold into.
Bull Div – price printed a lower low, the flow printed a higher low. The decline is being absorbed.
Inputs
| Group | Parameter | Default | Description |
|---|---|---|---|
| Flow Settings | Volume Source | Tick | Tick volume or real volume. Most FX and CFD venues do not publish real volume; the indicator detects this and handles it – see Behavior that is not an input. |
| Flow Settings | Signal Line Period (EMA) | 21 | Smoothing period of the signal line. Valid 2–1000. Lower reacts faster and crosses more often; higher holds a side longer. Values outside the range are rejected at load with a message in the journal. |
| Divergence | Mark Flow Divergence | true | Master switch for the divergence layer. Off means no scanning, no lines, no divergence alerts. |
| Divergence | Pivot Lookback (bars to the left) | 5 | How many bars to the left a bar must dominate to count as a swing. Valid 1–50. Larger values keep only the more significant swings. |
| Divergence | Pivot Confirmation (bars to the right) | 3 | How many closed bars must form to the right before a pivot is accepted. Valid 1–50. This is what makes the layer non-repainting – and also why a divergence appears a few bars after the actual high or low. Larger is safer and slower. |
| Divergence | Minimum Bars Between Compared Pivots | 5 | Two pivots closer together than this are not compared. Filters out noise inside a single congestion. |
| Divergence | Maximum Bars Between Compared Pivots | 60 | Two pivots further apart than this are not compared, so swings from different legs are never connected. Must be greater than the minimum; upper bound 5000. |
| Divergence | History Depth Scanned for Divergence | 500 | How far back the divergence scan runs when the indicator loads. Valid 100–20000. Raise it to study older history, lower it to keep the window clean and loading fast. |
| Divergence | Bearish Divergence Color | Orange Red | Color of bearish divergence lines and labels. |
| Divergence | Bullish Divergence Color | Aqua | Color of bullish divergence lines and labels. |
| Alerts | Popup Alert | false | Delivery channel. Independent of the others and off by default. |
| Alerts | Push Notification | false | Delivery channel. Requires MetaQuotes ID to be configured in the terminal. |
| Alerts | false | Delivery channel. Requires the terminal mail settings. | |
| Alerts | Alert on Flow Reversal | true | Whether a confirmed crossing counts as an event. Decides what qualifies; the three channels above decide whether it is delivered. |
| Alerts | Alert on Divergence | true | Whether a confirmed divergence counts as an event. |
| Alerts | Bars to Confirm Reversal | 2 | How many closed bars the flow must hold its new side before a reversal is announced. Valid 1–10; 1 fires on the cross itself. See the note below. |
Why the confirmation default is 2. This is measured, not guessed. On GOLD H1 and US100 H1 the raw cross fires around 3.8 times a day and roughly half of those crossings unwind within two bars. Requiring two bars of hold cuts the message count in half and materially improves how often the new side is still intact five bars later. Three bars adds delay without adding accuracy.
How to read it
The cloud tells you who owns the flow right now. The shade tells you whether that ownership is strengthening or decaying. A bright cloud that turns dark while price is still moving your way is the earliest thing this indicator gives you – the move is continuing on thinner participation.
A cross of the cloud through the lines is a change of control. With the default two-bar confirmation it is deliberately late by two bars, because the immediate cross is unreliable.
A divergence is the strongest statement the indicator makes, and it is a statement about disagreement, not about timing. Price has made a new extreme and the flow behind it has not. That is a reason to tighten risk, to stop adding, or to wait for a structure break – it is not, on its own, a reason to take a position in the opposite direction.
Nothing here is a standalone entry system. It measures participation behind price. Use it to qualify a setup you already have.
Behavior that is not exposed as an input
These run automatically. They are documented because they change what you see, and you should not have to read them out of the behavior.
Volume source fallback
If you select real volume on a symbol that does not publish any, the indicator would otherwise draw a flat, dead line. Instead it checks the last 200 bars once, and if nothing was traded it switches to tick volume, writes one line to the journal, and updates its short name to show Tick – so the window header always reflects what is actually being counted.
Signal line seeding
The signal line is seeded with a simple average of the flow over the first period, then rolled forward as an EMA. Seeding on a single bar – the common shortcut – leaves the line drifting for roughly a hundred bars before it settles.
Hidden warm-up
Until the seed exists there is no honest value to show, so the first bars are left blank rather than filled with a placeholder. An empty area at the far left of the window is the warm-up, not a fault.
Non-repainting divergence
A pivot is only judged once the required number of bars has closed to its right, and the live bar is never counted. A divergence line, once drawn, is never withdrawn or moved. This was verified by feeding the same history two ways – all at once, and bar by bar – and confirming both produce an identical set of divergences.
Alerts are armed, not replayed
When you attach the indicator, past divergences are drawn so you can see the context, but no alerts are sent for them. Only events that complete while the indicator is running are announced. Alerts are also silent in the Strategy Tester and during optimization.
Chart cleanup
Drawings are removed when the indicator is removed. On load, the indicator also sweeps anything left behind by a previous session on the same chart – after a crash, a forced close or a recompile – so orphaned lines cannot accumulate.
Limitations you should know
The absolute flow value is not meaningful
Cumulative volume has no natural zero. It starts counting at the oldest bar loaded on the chart, so the same bar reads a completely different number depending on how much history is loaded – on GOLD H1 the same bar measured −726,541 with 1000 bars loaded and −121,052 with 400. This is inherent to cumulative volume and is equally true of the standard OBV.
What is stable is everything you actually trade from: the spread between the flow and its signal, the color, the crossings and the divergences are all identical regardless of history depth. Read the shape and the relationship, never the raw number, and do not build a threshold on the absolute level.
Divergence is context, not a trigger
Measured over roughly six weeks of GOLD H1 and US100 H1, price was in the expected direction ten bars after a divergence about half the time. That sample is small and ten bars is an arbitrary horizon, but the conclusion is the honest one: divergence marks disagreement between price and participation. It does not predict when, or whether, price resolves that disagreement. Treat it as a risk-management input.
Real volume
Real volume is only meaningful on venues that publish exchange volume – typically futures and stocks. On FX and CFDs the fallback described above applies.
Quick start
- Attach to any symbol and timeframe. The defaults are usable as they are.
- Watch the cloud color and shade rather than the line values.
- Turn on Popup Alert if you want to be told about reversals and divergences; leave the confirmation at 2 unless you have measured a reason to change it.
- If the window looks empty at the far left, that is the hidden warm-up.
