Pine Script v5 · Strategy
Volatility Range Breakout Strategy [wbburgin]
A Pine Script v5 strategy built on Highest (source, length), Lowest (source, length) and Crossover (high, hb1). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 5 settings; defaults include Average Length 100, Volatility Length 100 and Volatility Source close.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does Volatility Range Breakout Strategy [wbburgin] repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
- How did Volatility Range Breakout Strategy [wbburgin] do on BTCUSDT 1D with default settings?
- +294.92%
- From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- What alerts does Volatility Range Breakout Strategy [wbburgin] have?
- 4
- Volatility Long Entry Signal; Volatility Long Exit Signal; Volatility Short Entry Signal; Volatility Short Exit Signal.
- Does Volatility Range Breakout Strategy [wbburgin] run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 5 before, 4 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Volatility Range Breakout Strategy [wbburgin] use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
BTCUSDT · 1D · default settings
- Weighted Volatility Moving Average
- Volatility Reversal Band - Top
- Volatility Reversal Band - Bottom
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +294.92%
- $29,492.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 5
- 3 won · 2 lost
- Profitable
- 60.0%
- of closed trades
- Profit factor
- 2.99
- gross profit ÷ gross loss
- Max drawdown
- 109.75%
- −$16,602.10
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
ta.crossover(high, hb1) ignores the settings line 30
Line 30 hard-codes high where line 38 uses “Exit Source”. Changing those settings moves one band but not this one.
ta.crossover(high,hb1)ta.crossover(cross_type, hb1) -
Likely bug
ta.crossunder(low, lb1) ignores the settings line 31
Line 31 hard-codes low where line 35 uses “Exit Source”. Changing those settings moves one band but not this one.
ta.crossunder(low,lb1)ta.crossunder(cross_type, lb1) -
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Average Length | 100 | int | hb1 lb1 |
| Volatility Length | 100 | int | volatility |
| Volatility Source | close | source | volatility |
| Exit Source | close | source | vlong_exit vshort_exit |
| Exit Type | Volatility MA | string · options ["Volatility MA","Range Crossover"] | vlong_exit vshort_exit |
What it calculates
- Highestsource, length
h · line 15 - Lowestsource, length
l · line 16 - Crossoverhigh, hb1
upcross · line 30 - Crossunderlow, lb1
dncross · line 31
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | vlong | On | 41 |
| Close Long | vlong_exit | On | 43 |
| Open Short short | vshort | On | 45 |
| Close Short | vshort_exit | On | 47 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Alerts
| Alert | Call | Message | Line |
|---|---|---|---|
| Volatility Long Entry Signal | alertcondition | no message | 51 |
| Volatility Long Exit Signal | alertcondition | no message | 52 |
| Volatility Short Entry Signal | alertcondition | no message | 53 |
| Volatility Short Exit Signal | alertcondition | no message | 54 |
Does it repaint?
No
No repainting patterns in the source, and the live replay matched history.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +294.9% | +102.5% | 5 | 60% | 2.99 | 109.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +91.9% | +5.5% | 2 | 50% | 13.47 | 11.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −8.6% | +9.8% | 1 | 0% | 0.00 | 10.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +3.7% | +8.4% | 3 | 67% | 12.12 | 1.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.3% | +16.7% | 1 | 0% | 0.00 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.1% | +21.5% | 6 | 50% | 3.05 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −7.1% | +148.3% | 5 | 20% | 0.12 | 9.3% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +2.7% | +17.1% | 3 | 100% | — | 0.1% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 2 | 50% | $5,127.76 |
| Sideways market | 0 | — | $0.00 |
| Falling market | 3 | 67% | $24,364.30 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
34.9%
The 95th percentile of the worst drawdown when the same 5 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 28.8% to 34.9%; the tick is what actually happened, 28.8%. Order luck alone moves it this much.
All 5 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 11 Nov 2024 80,370.00 | 12 Feb 2025 95,778.20 | 93 | $15,408.20 |
| long | 17 Dec 2024 106,059.00 | 12 Feb 2025 95,778.20 | 57 | −$10,280.40 |
| short | 19 Nov 2025 92,960.80 | 17 Apr 2026 75,154.30 | 149 | $17,806.60 |
| short | 2 Dec 2025 86,286.00 | 17 Apr 2026 75,154.30 | 136 | $11,131.70 |
| short | 7 Feb 2026 70,580.30 | 17 Apr 2026 75,154.30 | 69 | −$4,574.02 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Volatility Range Breakout Strategy [wbburgin] this page | — | v5 strategy | +294.9% | 5 | 109.7% |
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
| Average Highest High and Lowest Low Swinger Strategy by exlux99 | lowest highest | v4 strategy | +6.4% | 20 | 49.6% |
| Highest High and Lowest Low Channel Strategy by ceyhun | highest lowest | v5 strategy | −3.7% | 26 | 7.9% |
| Donchian Channels System [racer8] by racer8 | highest lowest | v4 strategy | −3.2% | 36 | 43.6% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 5 before, 4 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © wbburgin-//@version=5+//@version=6strategy("Volatility Range Breakout Strategy [wbburgin]", shorttitle = "VRB Strategy [wbburgin]", overlay=true,⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 19 ms | Yes 1,000 bars in 334 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © wbburgin//@version=5strategy("Volatility Range Breakout Strategy [wbburgin]", shorttitle = "VRB Strategy [wbburgin]", overlay=true, pyramiding=20,max_bars_back=2000,initial_capital=10000)wma(float priceType,int length,float weight) => norm = 0.0 sum = 0.0 for i = 0 to length - 1 norm := norm + weight sum := sum + priceType[i] * weight sum / norm// This definition of volatility uses the high-low range divided by the average of that range.volatility(source,length) => h = ta.highest(source,length) l = ta.lowest(source,length) vx = 2 * (h - l) / (h + l) vxvm1 = input.int(100,"Average Length")volLen = input.int(100,"Volatility Length")vsrc = input.source(close,"Volatility Source")cross_type = input.source(close,"Exit Source")exit_type = input.string("Volatility MA",options=["Volatility MA","Range Crossover"],title="Exit Type")volatility = volatility(vsrc,volLen)highband1 = close + (close * volatility)lowband1 = close - (close * volatility)hb1 = wma(highband1,vm1,volatility)lb1 = wma(lowband1,vm1,volatility)hlavg = math.avg(hb1,lb1)upcross = ta.crossover(high,hb1) //Crossing over the high band of historical volatility signifies a bullish breakoutdncross = ta.crossunder(low,lb1) //Crossing under the low band of historical volatility signifies a bearish breakoutvlong = upcrossvshort = dncrossvlong_exit = switch exit_type == "Volatility MA" => ta.crossunder(cross_type,hlavg) exit_type == "Range Crossover" => ta.crossunder(cross_type,hb1)vshort_exit = switch exit_type == "Volatility MA" => ta.crossover(cross_type,hlavg) exit_type == "Range Crossover" => ta.crossover(cross_type,lb1)if vlong strategy.entry("Long",strategy.long)if vlong_exit strategy.close("Long")if vshort strategy.entry("Short",strategy.short)if vshort_exit strategy.close("Short")plot(hlavg,color=color.white,title="Weighted Volatility Moving Average")t = plot(hb1,color=color.new(color.red,50),title="Volatility Reversal Band - Top")b = plot(lb1,color=color.new(color.green,50),title="Volatility Reversal Band - Bottom")alertcondition(vlong,"Volatility Long Entry Signal")alertcondition(vlong_exit,"Volatility Long Exit Signal")alertcondition(vshort,"Volatility Short Entry Signal")alertcondition(vshort_exit,"Volatility Short Exit Signal")fill(t,b,color=color.new(color.aqua,90))