Explainers / Support and Resistance (High Volume Boxe
Support and Resistance (High Volume Boxes) by ChartPrime, explained from the source
Support and Resistance (High Volume Boxes) is an open-source TradingView script by ChartPrime, about 46,300 boosts, last updated in June 2024. On the chart it is called "SR Breaks and Retests". It draws green and red boxes at turning points, shades them by volume, marks "holds" with small diamonds and prints "Break Sup" and "Break Res" labels. This page walks through its published code in order, says what each part does, and ends with where it fails. It does not say what any box or mark will do next.
The surprise: the volume on the box is not the volume at the level
The description says the boxes come from pivot points and volume. In the code, the volume test is made on the bar that confirms the pivot, which with the default setting is the bar 20 bars after the turning point. The "Vol:" number printed in the box is that later bar's volume, not the volume traded at the level. So a box does not tell you that heavy volume met price at that price.
Step 1: the turning points
The script looks for a pivot low and a pivot high in the closing price, not in the wicks. A pivot low is a close lower than the 20 closes before it and the 20 closes after it (the "Lookback Period", default 20). A turning point can only be confirmed 20 bars later, because the script needs those 20 later closes to exist. On a live chart the box therefore appears 20 bars after the turn, and is drawn starting back at the turn.
Step 2: what "volume" means here
Each bar gets a signed volume: its volume counted as positive if it closed above its open, negative if it closed below. A bar that closed exactly at its open takes the sign of the last bar that did not. The function is named as a delta volume, but its two running totals are reset to zero on every bar, so the result is simply the current bar's volume with a plus or minus sign. Nothing is added up across bars.
Step 3: the filter that keeps a box
A support box is kept when a pivot low is confirmed and the signed volume of the confirming bar is above the higher of its own value and the previous bar's value, each divided by 2.5. With the default length of 2, that test passes whenever the confirming bar closed up and its volume beats 40% of the previous bar's volume, and it always passes when the previous bar closed down. A resistance box needs the mirror image: a pivot high and a confirming bar that closed down. In practice the filter mostly asks one question: did the bar 20 bars after the turn close in the right direction?
Step 4: the boxes
A support box runs from the pivot's close down by one 200-bar Average True Range (times "Adjust Box Width", default 1). A resistance box runs from the pivot's close up by the same amount. Its left edge is at the turning point and it keeps stretching right until a new box of the same colour replaces it. The shade comes from the confirming bar's volume compared with the largest signed volume of the last 25 bars. Because of the 200-bar ATR, boxes cannot get a height until 200 bars of history exist.
Step 5: holds, breaks and labels
A support "hold" is the bar where the low crosses back above the top of the support box. A support "break" is the bar where the high crosses below the bottom of the box; the box then turns red with a dashed border, and on the first such break a "Break Sup" label is placed on the previous bar. Resistance is the mirror image. Once a box has been broken and not yet held, the next break in the same direction gets a diamond for the old level holding in its new role instead of a label. All four diamond plots are drawn with an offset of minus one, so each diamond sits on the bar before the one where its condition became true.
What the settings change
"Lookback Period" (20) sets how many closes on each side make a pivot, and so how late each box appears. "Delta Volume Filter Length" (2) is the window for the volume test; a larger number drops more boxes. "Adjust Box Width" (1) multiplies the 200-bar ATR used for box height. The ATR length of 200, the divisor of 2.5 and the 25-bar shading window are fixed in the code and are not settings.
What we checked in Python
We ported the box-making logic to Python and ran it on invented random-walk prices, with volume drawn at random and with no link to price direction (20,000 bars, three seeds). With the default settings, 46% to 53% of the pivots became boxes, about 15 boxes per 1,000 bars. The pivots that became boxes had their own bar volume at 1.01 to 1.04 times the average pivot, so the filter did not pick out turning points where more volume traded. The confirming bars of kept boxes had 0.88 to 1.09 times the volume of the confirming bars of dropped ones. Raising the filter length to 10 kept 29% to 35% of pivots and the confirming bars' volume rose to 1.2 to 1.4 times, but the turning points' own volume stayed at 0.97 to 1.04 times average. These figures describe the code on invented data, not any market.
Where it fails
- The volume is from a different bar. The test and the printed "Vol:" number use the bar that confirms the pivot, 20 bars after the turn by default. On invented prices, kept turning points had the same volume as all turning points.
- The filter is mostly a candle colour. With the default length, a support box survives when its confirming bar closed up, and a resistance box when it closed down. On invented prices about half of all pivots passed.
- Twenty bars late. A box can only appear after 20 more closes. On a scrolled-back chart it sits at the turn, which makes it look as if it was there at the time. It was not.
- Diamonds are drawn one bar early. Every hold diamond is plotted on the bar before the bar where the cross happened. Reading a diamond as an entry on its own bar uses a bar that had already closed.
- Closes, not wicks. The levels come from closing prices. A wick that went further than the box is not part of the level.
- Only one box of each colour is live. Holds and breaks are checked only against the newest support box and the newest resistance box. Older boxes stop being tested once a new one appears.
- Box height is a 200-bar ATR. The height has nothing to do with where price traded around the pivot, and there is no box height at all in the first 200 bars.
- No alerts and no backtest. The code defines no alert conditions and measures nothing after a hold or a break.
- Not checked on a chart. The 50-box limit and how the volume shading looks were read from the code only.
- Open and licensed. The code carries a Mozilla Public License 2.0 notice and credits ChartPrime; this page describes it in our own words and pastes none of it.
Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Support and Resistance (High Volume Boxes) is by ChartPrime on TradingView and carries a Mozilla Public License 2.0 notice; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script trades.
Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Trendline Breakouts With Targets by Char, Breakout Finder by LonesomeTheBlue
Get the next teardown by email
One short email when a new teardown or free tool goes live, about twice a month. No signals, no hype. Unsubscribe in one click.
Almost done. Check your inbox and click the confirmation link.
Sent with Kit. Your address is used only for these emails. Privacy
No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.