Pine Script v4 · Strategy
Super Auto Breakout Day Trade Volatile stocks
A Pine Script v4 strategy built on Stdev (inter, 30), SMA (volume, 130) and EMA (vfi, 5). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 6 settings; defaults include VFI length 130, Coef 0.2 and Max. vol. cutoff 2.5.
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 Super Auto Breakout Day Trade Volatile stocks repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 15 of 15 trades.
- How did Super Auto Breakout Day Trade Volatile stocks do on BTCUSDT 1D with default settings?
- −6.07%
- From 26 Jan 2024 to 21 Oct 2026, over 51 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Super Auto Breakout Day Trade Volatile stocks be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does Super Auto Breakout Day Trade Volatile stocks use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Super Auto Breakout Day Trade Volatile stocks run in Zeal Terminal?
- Yes
- It compiles in 17 ms and runs 1,000 bars in 76 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- UB
- LB
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −6.07%
- −$6,071.86
- Buy and hold
- +102.5%
- same period
- Closed trades
- 51
- 16 won · 35 lost
- Profitable
- 31.4%
- of closed trades
- Profit factor
- 0.90
- gross profit ÷ gross loss
- Max drawdown
- 29.06%
- −$37,423.70
One run with the author's default settings, $100,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
sma(source, 20) ignores the settings line 45
Line 45 hard-codes 20 where line 32 uses “VFI length”. Changing those settings moves one band but not this one.
sma(source, 20)sma(source, length) -
Likely bug
sma(source, 20) ignores the settings line 52
Line 52 hard-codes 20 where line 32 uses “VFI length”. Changing those settings moves one band but not this one.
sma(source, 20)sma(source, length) -
Likely bug
ema(close, 20) ignores the settings line 40
Line 40 hard-codes 20 where line 38 uses “Signal Length”. Changing those settings moves one band but not this one.
ema(close,20)ema(close, signalLength) -
Likely bug
ema(close, 50) ignores the settings line 41
Line 41 hard-codes 50 where line 38 uses “Signal Length”. Changing those settings moves one band but not this one.
ema(close,50)ema(close, signalLength) -
Likely bug
ema(diff, 20) ignores the settings line 43
Line 43 hard-codes 20 where line 38 uses “Signal Length”. Changing those settings moves one band but not this one.
ema(diff,20)ema(diff, signalLength) -
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.
-
Check
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
4 settings have no label
In the settings dialog coef (line 7), signalLength (line 9), pre (line 11), trade_session (line 12) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses iff(), which v5 removed line 34
iff() on line 34, 36, 36. v5 writes it as the ternary c ? a : b.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames min → math.min, max → math.max, sma → ta.sma, log → math.log, stdev → ta.stdev, sum → math.sum, ema → ta.ema, barssince → ta.barssince.
v4 → v5
DiffersTrades differ: 51 before, 51 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 11: input(type = input.session) → input.session()
- Line 12: input(type = input.session) → input.session()
- Line 23: min → math.min
- Line 25: max → math.max
- Line 27: sma → ta.sma
16 more edits
- Line 29: log → math.log
- Line 29: log → math.log
- Line 30: stdev → ta.stdev
- Line 32: sma → ta.sma
- Line 34: iff(c, a, b) → (c ? a : b)
- Line 36: iff(c, a, b) → (c ? a : b)
- Line 36: iff(c, a, b) → (c ? a : b)
- Line 37: sum → math.sum
- Line 38: ema → ta.ema
- Line 40: ema → ta.ema
- Line 41: ema → ta.ema
- Line 43: ema → ta.ema
- Line 45: sma → ta.sma
- Line 46: stdev → ta.stdev
- Line 52: sma → ta.sma
- Line 58: barssince → ta.barssince
⋯// © beststockalert-//@version=4+//@version=5strategy(title="Auto Breakout", shorttitle = "Autotrade BB-BO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)⋯// session -pre = input( type=input.session, defval="0400-0930")+pre = input.session( defval="0400-0930")-trade_session = input( type=input.session, defval="0940-1700")+trade_session = input.session( defval="0940-1700")use_trade_session = true⋯float preLow = na-preLow := preSession ? preNew ? low : min(preLow[1], low) : preLow[1]+preLow := preSession ? preNew ? low : math.min(preLow[1], low) : preLow[1]float preHigh = na-preHigh := preSession ? preNew ? high : max(preHigh[1], high) : preHigh[1]+preHigh := preSession ? preNew ? high : math.max(preHigh[1], high) : preHigh[1]// vfi 9lazybear -ma(x,y) => 0 ? sma(x,y) : x+ma(x,y) => 0 ? ta.sma(x,y) : xtypical=hlc3-inter = log( typical ) - log( typical[1] )+inter = math.log( typical ) - math.log( typical[1] )-vinter = stdev(inter, 30 )+vinter = ta.stdev(inter, 30 )cutoff = coef * vinter * close-vave = sma( volume, length )[1]+vave = ta.sma( volume, length )[1]vmax = vave * vcoef-vc = iff(volume < vmax, volume, vmax) //min( volume, vmax )+vc = (volume < vmax ? volume : vmax) //min( volume, vmax )mf = typical - typical[1]-vcp = iff( mf > cutoff, vc, iff ( mf < -cutoff, -vc, 0 ) )+vcp = ( mf > cutoff ? vc : ( mf < -cutoff ? -vc : 0 ) )-vfi = ma(sum( vcp , length )/vave, 3)+vfi = ma(math.sum( vcp , length )/vave, 3)-vfima=ema( vfi, signalLength )+vfima=ta.ema( vfi, signalLength )//ema diff-ema20 = ema(close,20)+ema20 = ta.ema(close,20)-ema50 = ema(close,50)+ema50 = ta.ema(close,50)diff = (ema20-ema50)*100/ema20-ediff = ema(diff,20)+ediff = ta.ema(diff,20)//-basis = sma(source, 20)+basis = ta.sma(source, 20)-dev = 1.5 * stdev(source, 20)+dev = 1.5 * ta.stdev(source, 20)upper = basis *1.014⋯ lower = basis - 0.5-sma20 = sma(source, 20)+sma20 = ta.sma(source, 20)/// bar color⋯///-if (isinsession and ( close[3]>upper and close>sma20 and vfi[3]>0 and vfi>0 and vfi>vfi[5] and barssince(sell)>5 ) or close>open*1.04)+if (isinsession and ( close[3]>upper and close>sma20 and vfi[3]>0 and vfi>0 and vfi>vfi[5] and ta.barssince(sell)>5 ) or close>open*1.04) strategy.entry("Long", strategy.long)⋯Clean v5
VerifiedSame 51 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 6: input() → input.int()
- Line 7: input() → input.float()
- Line 8: input() → input.float()
- Line 9: input() → input.int()
⋯source = close-length = input(130, title="VFI length")+length = input.int(130, title="VFI length")-coef = input(0.2)+coef = input.float(0.2)-vcoef = input(2.5, title="Max. vol. cutoff")+vcoef = input.float(2.5, title="Max. vol. cutoff")-signalLength=input(5)+signalLength=input.int(5)// session ⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L27:C11: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © beststockalert-//@version=5+//@version=6strategy(title="Auto Breakout", shorttitle = "Autotrade BB-BO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)⋯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 |
|---|---|---|---|
| VFI length | 130 | int | vave vfi |
| Coef (no label in the script) | 0.2 | float | cutoff |
| Max. vol. cutoff | 2.5 | float | vmax |
| Signal Length (no label in the script) | 5 | int | vfima |
| Pre (no label in the script) | 0400-0930 | session | preNew preSession |
| Trade session (no label in the script) | 0940-1700 | session | isinsession |
What it calculates
- Stdev (
stdev,ta.stdevin v5)inter, 30vinter · line 30 - SMA (
sma,ta.smain v5)volume, VFI length (130)vave · line 32 - EMA (
ema,ta.emain v5)vfi, Signal Length (5)vfima · line 38 - EMA (
ema,ta.emain v5)close, 20ema20 · line 40 - EMA (
ema,ta.emain v5)close, 50ema50 · line 41 - EMA (
ema,ta.emain v5)diff, 20ediff · line 43 - SMA (
sma,ta.smain v5)source, 20basis · line 45 - Stdev (
stdev,ta.stdevin v5)source, 20dev · line 46 - SMA (
sma,ta.smain v5)source, 20sma20 · line 52
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 | (isinsession and ( close[3]>upper and close>sma20 and vfi[3]>0 and vfi>0 and vfi>vfi[5] and barssince(sell)>5 ) or close>open*1.04) | On | 59 |
| Close Long | (sell ) | On | 61 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
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 | −6.1% | +102.5% | 51 | 31% | 0.90 | 29.1% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +7.0% | +5.5% | 13 | 23% | 2.64 | 3.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −40.3% | +9.8% | 83 | 30% | 0.65 | 59.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +1.5% | +8.4% | 16 | 13% | 1.17 | 5.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +32.0% | +16.7% | 117 | 37% | 1.10 | 41.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.3% | +21.5% | 14 | 21% | 0.98 | 6.8% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −18.1% | +148.3% | 51 | 22% | 0.74 | 31.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +4.3% | +17.1% | 11 | 27% | 3.16 | 2.0% | 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 | 24 | 33% | $85.26 |
| Sideways market | 17 | 35% | $1,793.51 |
| Falling market | 10 | 20% | −$7,950.63 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
32.7%
The 95th percentile of the worst drawdown when the same 51 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 16.3% to 32.7%; the tick is what actually happened, 28.2%. Order luck alone moves it this much.
All 51 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 41,823.50 | 10 Feb 2024 47,132.80 | 14 | $12,694.50 |
| long | 15 Feb 2024 51,795.20 | 18 Feb 2024 51,642.60 | 3 | −$331.87 |
| long | 27 Feb 2024 54,476.50 | 29 Feb 2024 62,432.10 | 2 | $16,409.20 |
| long | 5 Mar 2024 68,245.70 | 6 Mar 2024 63,724.00 | 1 | −$8,531.93 |
| long | 12 Mar 2024 72,078.10 | 13 Mar 2024 71,452.00 | 1 | −$1,044.45 |
| long | 18 Mar 2024 68,393.50 | 19 Mar 2024 67,610.00 | 1 | −$1,365.42 |
| long | 21 Mar 2024 67,840.50 | 22 Mar 2024 65,501.30 | 1 | −$4,062.93 |
| long | 25 Mar 2024 67,210.00 | 3 Apr 2024 65,464.00 | 9 | −$2,955.49 |
| long | 4 May 2024 62,882.00 | 7 May 2024 63,165.20 | 3 | $499.01 |
| long | 16 May 2024 66,206.50 | 17 May 2024 65,235.20 | 1 | −$1,633.01 |
| long | 21 May 2024 71,446.60 | 22 May 2024 70,148.30 | 1 | −$1,992.99 |
| long | 16 Jul 2024 64,724.10 | 18 Jul 2024 64,088.00 | 2 | −$1,058.26 |
| long | 20 Jul 2024 66,660.00 | 24 Jul 2024 65,936.00 | 4 | −$1,158.09 |
| long | 9 Aug 2024 61,686.00 | 10 Aug 2024 60,838.00 | 1 | −$1,449.89 |
| long | 24 Aug 2024 64,037.20 | 27 Aug 2024 62,834.00 | 3 | −$1,954.47 |
| long | 14 Sep 2024 60,498.00 | 15 Sep 2024 59,993.00 | 1 | −$851.92 |
| long | 15 Oct 2024 66,084.00 | 16 Oct 2024 67,074.10 | 1 | $1,516.46 |
| long | 7 Nov 2024 75,572.00 | 8 Nov 2024 75,857.90 | 1 | $388.64 |
| long | 11 Nov 2024 80,370.00 | 12 Nov 2024 88,648.00 | 1 | $10,620.90 |
| long | 16 Nov 2024 91,032.10 | 17 Nov 2024 90,588.00 | 1 | −$554.87 |
| long | 22 Nov 2024 98,317.10 | 24 Nov 2024 97,672.40 | 2 | −$742.20 |
| long | 28 Nov 2024 95,863.10 | 29 Nov 2024 95,644.00 | 1 | −$257.01 |
| long | 12 Dec 2024 101,125.00 | 13 Dec 2024 100,004.00 | 1 | −$1,243.27 |
| long | 16 Jan 2025 100,497.00 | 17 Jan 2025 99,987.30 | 1 | −$563.05 |
| long | 18 Jan 2025 104,077.00 | 20 Jan 2025 101,332.00 | 2 | −$2,912.12 |
| long | 3 Mar 2025 94,270.00 | 4 Mar 2025 86,221.20 | 1 | −$9,175.46 |
| long | 12 Mar 2025 82,933.00 | 13 Mar 2025 83,680.10 | 1 | $885.48 |
| long | 20 Mar 2025 86,845.90 | 21 Mar 2025 84,223.40 | 1 | −$2,994.87 |
| long | 10 Apr 2025 82,615.20 | 11 Apr 2025 79,607.30 | 1 | −$3,501.82 |
| long | 12 Apr 2025 83,423.80 | 13 Apr 2025 85,276.90 | 1 | $2,058.66 |
| long | 23 Apr 2025 93,443.00 | 24 Apr 2025 93,691.10 | 1 | $251.52 |
| long | 9 May 2025 103,262.00 | 10 May 2025 102,972.00 | 1 | −$266.42 |
| long | 10 Jun 2025 110,263.00 | 11 Jun 2025 110,274.00 | 1 | $9.77 |
| long | 24 Jun 2025 105,334.00 | 25 Jun 2025 106,083.00 | 1 | $673.67 |
| long | 11 Jul 2025 116,010.00 | 30 Jul 2025 117,951.00 | 19 | $1,596.05 |
| long | 3 Dec 2025 91,277.90 | 4 Dec 2025 93,429.90 | 1 | $2,287.03 |
| long | 14 Jan 2026 95,414.00 | 15 Jan 2026 96,951.80 | 1 | $1,600.24 |
| long | 7 Feb 2026 70,580.30 | 8 Feb 2026 69,289.40 | 1 | −$1,845.23 |
| long | 26 Feb 2026 67,988.00 | 27 Feb 2026 67,485.20 | 1 | −$732.54 |
| long | 3 Mar 2026 68,830.10 | 4 Mar 2026 68,338.00 | 1 | −$702.81 |
| long | 5 Mar 2026 72,666.80 | 6 Mar 2026 70,891.00 | 1 | −$2,385.25 |
| long | 24 Mar 2026 70,906.40 | 25 Mar 2026 70,556.70 | 1 | −$469.64 |
| long | 8 Apr 2026 71,924.20 | 9 Apr 2026 71,069.90 | 1 | −$1,125.45 |
| long | 14 Apr 2026 74,418.00 | 15 Apr 2026 74,131.60 | 1 | −$360.39 |
| long | 8 Jun 2026 63,332.00 | 9 Jun 2026 63,086.00 | 1 | −$362.30 |
| long | 15 Jul 2026 65,044.00 | 16 Jul 2026 64,756.30 | 1 | −$410.95 |
| long | 20 Aug 2026 69,334.80 | 21 Aug 2026 73,027.00 | 1 | $4,925.56 |
| long | 22 Aug 2026 78,338.00 | 23 Aug 2026 77,074.90 | 1 | −$1,570.76 |
| long | 4 Sep 2026 81,270.40 | 5 Sep 2026 79,660.80 | 1 | −$1,898.35 |
| long | 19 Sep 2026 80,883.90 | 20 Sep 2026 81,250.00 | 1 | $425.28 |
| long | 22 Sep 2026 86,620.00 | 23 Sep 2026 86,208.60 | 1 | −$448.28 |
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 |
|---|---|---|---|---|---|
| Super Auto Breakout Day Trade Volatile stocks this page | — | v4 strategy | −6.1% | 51 | 29.1% |
| Volume Weighted Bollinger Bands Strategy by Ankit_1618 | ema sma stdev | v4 strategy | +10.0% | 15 | 27.5% |
| BB21_MA200_Strategy by mohanee | ema sma stdev | v4 strategy | No trades on this market | ||
| Super Breakout day trading by beststockalert | stdev sma ema | v4 strategy | No trades on this market | ||
| VFI strategy [based on VFI indicator published by UTS] by mohanee | sma stdev ema | v4 strategy | +181.4% | 8 | 154.2% |
| McClellan Oscillator Strategy by sparrow_hawk_737 | ema sma stdev | v3 strategy | No trades on this market | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 17 ms | With a workaround 1,000 bars in 76 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“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. PineTS runs Pine Script v5 and v6 only.
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/// © beststockalert//@version=4strategy(title="Auto Breakout", shorttitle = "Autotrade BB-BO",default_qty_type = strategy.percent_of_equity,default_qty_value = 100, overlay=true)source = closelength = input(130, title="VFI length")coef = input(0.2)vcoef = input(2.5, title="Max. vol. cutoff")signalLength=input(5)// session pre = input( type=input.session, defval="0400-0930")trade_session = input( type=input.session, defval="0940-1700")use_trade_session = trueisinsession = use_trade_session ? not na(time('1', trade_session)) : trueis_newbar(sess) => t = time("D", sess) not na(t) and (na(t[1]) or t > t[1])is_session(sess) => not na(time(timeframe.period, sess))preNew = is_newbar(pre)preSession = is_session(pre)float preLow = napreLow := preSession ? preNew ? low : min(preLow[1], low) : preLow[1]float preHigh = napreHigh := preSession ? preNew ? high : max(preHigh[1], high) : preHigh[1]// vfi 9lazybear ma(x,y) => 0 ? sma(x,y) : xtypical=hlc3inter = log( typical ) - log( typical[1] )vinter = stdev(inter, 30 )cutoff = coef * vinter * closevave = sma( volume, length )[1]vmax = vave * vcoefvc = iff(volume < vmax, volume, vmax) //min( volume, vmax )mf = typical - typical[1]vcp = iff( mf > cutoff, vc, iff ( mf < -cutoff, -vc, 0 ) )vfi = ma(sum( vcp , length )/vave, 3)vfima=ema( vfi, signalLength )//ema diffema20 = ema(close,20)ema50 = ema(close,50)diff = (ema20-ema50)*100/ema20ediff = ema(diff,20)//basis = sma(source, 20)dev = 1.5 * stdev(source, 20)upper = basis *1.014lower = basis *.985if close >19.9 upper = basis + 0.65 lower = basis - 0.5sma20 = sma(source, 20)/// bar colorbarColour = (open>=upper) ? color.green : (close>=upper) ? color.green : (close>basis) ? color.green : (open<lower) ? color.purple : color.bluesell = close < lower or close> strategy.position_avg_price*1.1 or close <strategy.position_avg_price-0.4 or vfi<-3 or vfima<-3 or close<open*.94barcolor(color=barColour)///if (isinsession and ( close[3]>upper and close>sma20 and vfi[3]>0 and vfi>0 and vfi>vfi[5] and barssince(sell)>5 ) or close>open*1.04) strategy.entry("Long", strategy.long)if (sell ) strategy.close("Long")plot(basis, color=color.red,title= "SMA")p1 = plot(upper, color=color.blue,title= "UB")p2 = plot(lower, color=color.blue,title= "LB")