Relative Volume & Volume Spikes in Pine Script
A bar's volume as a multiple of its recent average, so a print at 2 or 3 times normal stands out as the moment when participation changed.
Definition
Relative volume (RVOL) is the volume of a bar divided by the average volume of the bars before it. It belongs to the volume-reading family, where the question is not the direction of volume but its size. A reading of 1 is a normal bar, 2 is twice the recent average and 0.5 is half of it. A volume spike is a bar whose relative volume clears a threshold, usually 2 or more, and it marks the moment when more participants than usual decided to act.
Volume is the one input a chart cannot fake. Price can drift on a few contracts, but a bar with 3 times average volume needed real buyers and real sellers to meet. That is why the ratio confirms other signals: a breakout on high relative volume has the participation to travel, while a breakout on thin volume is more likely a probe. The same spike carries the opposite meaning after a long move, when a volume climax often shows the last buyers arriving as the sellers who have waited take the other side.
There is no single author. The idea comes from the tape-reading tradition, where the size of a print mattered as much as its price, and it became a ratio once intraday volume was available on charts. The common settings are an average of 20 bars and a spike threshold of 2 times that average. Scanners that rank stocks by relative volume use the same ratio, often measured against the same time of day on previous sessions rather than against a rolling average.
On the chart expect most bars to sit between about 0.5 and 1.5, with spikes clustered at the open, on news and at the close. A rolling average on an intraday chart includes the quiet middle of the day, so the first bars of a session read as spikes almost every morning; that is a feature of the window, not a signal. On daily bars the ratio is cleaner, and a daily spike after weeks of quiet is one of the clearest tells that something has changed.
Reading the chart
The number means little on its own; read it together with the bar's range, its close and where it sits in the move.
- Pick the reference window. A 20-bar average is the default; on intraday charts consider a longer window, or compare against the same time of day, so the open is not measured against the lunch lull.
- Set the threshold. A spike at 2 times average is a meaningful bar on most markets; 3 times or more is rare enough to treat as an event on its own.
- Read the spike bar's range and close. A wide bar closing near its extreme in the direction of the move is expansion; a wide bar closing in the middle or against the move is a fight.
- Locate the spike in the move. Out of a base or a range it is breakout volume; after an extended run it is more often climax volume, and the same number means the opposite.
- Check the next few bars. Follow-through on decent volume confirms a breakout; an immediate return inside the range on falling volume says the spike absorbed the buyers rather than launched them.
- Check the calendar. Expiries, index rebalances, earnings and contract rolls produce spikes with no directional meaning, and a spike on a known event is usually the event, not a signal.
The maths
Relative volume is the bar's volume divided by a simple average of recent volume, and a spike is any bar whose ratio clears the chosen multiple.
The implementation averages the last 20 bars including the current one, so a huge bar lifts its own average slightly; the effect is small and a real spike still clears 2 easily.
Time-of-day relative volume compares the bar with the same minute on previous sessions. It removes the morning bias of a rolling window but needs several days of history and an exchange session to align to.
The script colours the volume columns by the candle's direction and marks a spike as long on an up bar and short on a down bar. The mark records who was active, not a prediction of the next bar.
Some feeds report tick count rather than traded size, notably spot forex. The ratio still shows activity, but the words climax and absorption mean less without real size.
Inputs that matter
| Input | Typical | What changing it does |
|---|---|---|
| Average length | 20 | A longer window steadies the average and makes spikes rarer; a shorter one adapts faster but lets one big bar inflate the average and hide the next spike. |
| Spike multiple | 2 | Raising it to 3 keeps only the exceptional bars; lowering it to 1.5 catches the build-up before a move but marks many ordinary bars. |
| Reference | rolling average | A same-time-of-day average removes the open and close bias on intraday charts, at the cost of needing more history. |
In practice
- As breakout confirmation: a close beyond a range on 2 times average volume or more has the participation to continue; the same close on below-average volume is treated as unconfirmed until it is retested.
- As a climax warning: after an extended move, a spike bar with a wide range that closes away from its extreme is read as exhaustion, and the trade is tightened rather than added to.
- As a scan: rank a watchlist by relative volume at the same time of day to find where the activity is, then read the chart for the reason.
- As an event marker: a spike on a down bar into support is absorption if the next bars hold; a spike on an up bar into resistance is distribution if they fail.
- As a filter for other signals: an entry from a crossover or a pattern is only taken when the signal bar's relative volume clears the threshold.
- As context for gaps: the volume of the first bar after a gap decides whether it is a breakaway with sponsorship or a common gap likely to fill.
Where it goes wrong
- Reading every spike as bullish. Volume shows activity, not direction; the close and the location decide the meaning, and a spike at the top of a run is often the sellers arriving.
- Measuring the open against a rolling intraday average. The first bars always look like spikes; use a longer window, a same-time-of-day comparison or the daily chart.
- Ignoring scheduled events. Expiry, rebalance and earnings bars print huge volume with no information about the next day; check the date before reading the bar.
- Trusting the ratio on tick-volume feeds. Without real size the numbers show activity only; treat spot forex readings as a rough guide.
Compared with
On-Balance Volume. OBV accumulates volume with the sign of each bar's close to show the trend of participation over weeks; relative volume looks at one bar and asks whether its size is unusual. OBV is cumulative and directional, RVOL is instantaneous and unsigned.
Money Flow Index. MFI weights price changes by volume and bounds the result between 0 and 100 to read overbought and oversold; relative volume never touches price and has no bounds. MFI asks where the money is pushing, RVOL asks how much of it showed up.
VWAP. VWAP uses volume as a weight to find the average price of the session; relative volume uses it as the subject. A spike bar drags VWAP towards its price, which is one reason the two are read together.
Average True Range. ATR measures how far price moves per bar; relative volume measures how much trades. A wide-range bar on normal volume and a normal-range bar on 3 times volume are different events, and reading both keeps them apart.
Build it in Quant
Type one of these in the Quant desk, or click it. A request that fits a checked template is assembled on the spot without a credit; anything beyond the blanks goes to the copilot, which edits on top of the checked script.
Questions
What counts as high relative volume?
Above 2 times the average is the usual line for a spike; between 1.5 and 2 is elevated; 3 or more is rare and worth reading on its own. On a daily chart of a large stock, 3 times average volume almost always has a news reason behind it, so check the reason before reading the bar.
Why do the opening bars always show a spike?
Because a rolling average of the last 20 intraday bars includes the quiet middle of the previous session. The open is busy every day, so it clears the threshold every day. Lengthen the window, compare against the same time on earlier sessions, or judge opening bars against other opens.
How do I tell breakout volume from climax volume?
By location and by the close. Breakout volume appears as price leaves a base or a range and the bar closes near its extreme in the direction of the move. Climax volume appears after an extended run, often on the widest bar of the move, and the close pulls back from the extreme as sellers absorb the last buyers.
Does a low-volume breakout always fail?
No, but it fails more often, and it gives no evidence that large participants were involved. Treat a thin breakout as unconfirmed: wait for the retest to hold or for volume to expand on the second push. Some strong moves start quietly, so the low reading is a reason for caution, not for shorting.
Can I use relative volume on crypto and forex?
On crypto, yes, provided the venue reports real traded size, and note that the average shifts over the weekend. On spot forex most feeds give tick counts rather than size, so the ratio measures activity, which still rises around news and session opens but cannot show absorption.
What does the long or short mark on a spike mean?
It records the direction of the spike bar: long for a close above the open on a spike, short for a close below it. It is a note about who was active, not an entry signal, and the script raises an alert with the multiple so you can read the bar in context before acting.