Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

B.Bands - Augmented - Intra-range - Long-Only

A Pine Script v5 strategy built on SMA (close, 20), EMA (close, 20) and Stdev (close, 20). It has 14 order rules, 2 entries among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays 0.075 commission. 17 settings; defaults include Periods 20, Std 2 and Entry 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 B.Bands - Augmented - Intra-range - Long-Only repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did B.Bands - Augmented - Intra-range - Long-Only do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does B.Bands - Augmented - Intra-range - Long-Only run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does B.Bands - Augmented - Intra-range - Long-Only use a stop loss?
Yes
strategy.exit sets a stop on line 76, 78, 82, 84, 100, 102, 107, 109.
Does B.Bands - Augmented - Intra-range - Long-Only run in Zeal Terminal?
Yes
It compiles in 41 ms and runs 1,000 bars in 95 ms, in the browser.

BTCUSDT · 1D · default settings

  • Simple Upper Bollinger Band
  • Simple Moving Average
  • Simple Lower Bollinger Band
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (17)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $1,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.

  • Check

    1 setting does nothing

    “Exit source” is declared but never read.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Strategy System
Simple Bollinger Bands trueboolSimple Upper Bollinger Band Simple Lower Bollinger Band close Entry line 68 line 73 line 79 line 85 Simple Moving Average
Augmented Bollinger BandsSelect Bollinger Band Indicator to trade Simple or AugmentedfalseboolAugmented Upper Bollinger Band Simple Lower Bollinger Band close Entry_A line 92 line 97 line 104 line 110 Augmented Moving Average
Technical Inputs
Periods20int · min 2 · step 1middle_sim middle_augm middle_upp middle_low dev
StdTechnical inputs for indicator calculation, Periods for MA and Standard Deviation2float · min 0.1 · step 0.1dev
Strategy Inputs
Entry sourceclosesourceSLT stop_inicial entry_long entry_long_augm
Exit sourceFor entry: Activate signal if the source lies below (for Long) or above (for Short). For exit: When price reach target selectedhighsourceunused
Max Spread Tolerance Beetween BandsMax. Tolerance beetween lower and upper band to allow trade for range systems99999.0float · step 0.1entry_long entry_long_augm
Profit Target
Profit to band:oppositestring · options ["middle", "opposite"]exit Target exit Target exit Target exit Target exit Target exit Target exit Target exit Target line 75 line 77 line 81 line 83 line 99 line 101 line 106 line 108
Only sell in profitSell only if position is on profit, unless Stop Loss activefalseboolline 73 line 79 line 97 line 104
Risk Management
Stop Loss %3.00float · step 0.05SL
Implement Stop Loss?Activate Stop Losstrueboolexit Target
Trailing %6.00float · step 0.125SLT stop_inicial
Implement trailing stop?falseboolslts Trailing Stop
Position Size
% of available capitalUse a % of the total capital selected for strategy5float · max 100 · step 0.25position
Limit strategy capital?If activated, only uses the percentage of capital selected from the properties tab. Default 1000$falseboolposition
BACKTEST RANGE
Starting Datetimestamp("2019-11-01T00:00:00")timefrom_date
Ending DateSelect the range for backtest and live strategytimestamp("2023-12-12T00:00:00")timeto_date

What it calculates

  • SMAclose, Periods (20)middle_sim · line 48
  • EMAclose, Periods (20)middle_augm · line 50
  • EMAhigh, Periods (20)middle_upp · line 51
  • EMAlow, Periods (20)middle_low · line 52
  • Stdevclose, Periods (20)dev · line 54

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.

closecloseprice dataperiodsPeriodssetting · 20highhighprice datalowlowprice datastdStdsetting · 2riskPerc% of available capitalsetting · 5stop_lossStop Loss %setting · 3.00stop_percTrailing %setting · 6.00max_spread_bbMax Spread Tolerance Be…setting · 99999.0timetimeprice datastartStarting Datesetting · timestamp("2019-11-…endEnding Datesetting · timestamp("2023-12-…take_profitProfit to band:setting · oppositemiddle_simSMA→ middle_simmiddle_augmEMA→ middle_augmmiddle_uppEMA→ middle_uppmiddle_lowEMA→ middle_lowdevStdev→ devpositionpositionvalueSLSLvaluestop_inicialstop_inicialvalueupper, lowerupper · lower2 valuesupper_augmupper_augmvaluelower_augmlower_augmvaluespreadspreadvaluespread_augmspread_augmvaluein_positionin_positionconditionsltssltsconditionentry_longentry_longconditionentry_long_augmentry_long_augmconditionfrom_datefrom_dateconditionto_dateto_dateconditionSLTSLTconditionentry:EntryOpen Entrystrategy.entryexit:Targetexit Targetstrategy.exitclose:EntryClose Entrystrategy.closeentry:Entry_AOpen Entry_Astrategy.entryclose:Entry_AClose Entry_Astrategy.closeplot:118Stop Lossplotplot:119Trailing Stopplotplot:120Simple Upper Bollinger …plotplot:121Simple Moving Averageplotplot:122Simple Lower Bollinger …plotfill:123Fillfill × 2plot:124Augmented Moving Averageplotplot:125Augmented Upper Bolling…plotplot:126Simple Lower Bollinger …plotfill:127Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open Entry longentry_longOn71
Exit Target stop and limittake_profit == "middle"On76
Exit Target stop and limittake_profit == "opposite"On78
Exit Target stop and limittake_profit == "middle"On82
Exit Target stop and limittake_profit == "opposite"On84
Close Entryin_position and show_simp and slts and In_date()On87
Close Entrynot In_date()On90
Open Entry_A longentry_long_augmOn95
Exit Target stop and limittake_profit == "middle"On100
Exit Target stop and limittake_profit == "opposite"On102
Exit Target stop and limittake_profit == "middle"On107
Exit Target stop and limittake_profit == "opposite"On109
Close Entry_Ain_position and show_augm and slts and In_date()On112
Close Entry_Anot In_date()On116

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
B.Bands - Augmented - Intra-range - Long-Only this page—v5 strategy0.0%00.0%
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategyNo trades on this market
Super Breakout day trading by beststockalertstdev sma emav4 strategyNo trades on this market
Super Auto Breakout Day Trade Volatile stocks by beststockalertstdev sma emav4 strategy−6.1%5129.1%
VFI strategy [based on VFI indicator published by UTS] by mohaneesma stdev emav4 strategy+181.4%8154.2%

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.

  • 5 settings use the untyped input() (line 13, 14, 18, 21, 23). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 13: input() → input.source()
  • Line 14: input() → input.source()
  • Line 18: input() → input.bool()
  • Line 21: input() → input.bool()
  • Line 23: input() → input.bool()
⋯// Strategy data-entry_source    = input(close, title="Entry source", group="Strategy Inputs", inline='3')+entry_source    = input.source(close, title="Entry source", group="Strategy Inputs", inline='3')-exit_source     = input(high, title="Exit source", group="Strategy Inputs", inline='3',tooltip='For entry: Activate signal if the source lies below (for Long) or above (for Short). For exit: When price reach target selected')+exit_source     = input.source(high, title="Exit source", group="Strategy Inputs", inline='3',tooltip='For entry: Activate signal if the source lies below (for Long) or above (for Short). For exit: When price reach target selected')max_spread_bb   = input.float(99999.0, title="Max Spread Tolerance Beetween Bands", step=0.1, group="Strategy Inputs",tooltip='Max. Tolerance beetween lower and upper band to allow trade for range systems')⋯take_profit     = input.string("opposite", title = "Profit to band:", inline='4', options = ["middle", "opposite"], group="Profit Target")-sell_profit     = input(false, title="Only sell in profit", group="Profit Target", inline='4', tooltip='Sell only if position is on profit, unless Stop Loss active')+sell_profit     = input.bool(false, title="Only sell in profit", group="Profit Target", inline='4', tooltip='Sell only if position is on profit, unless Stop Loss active')// Risk Managementstop_loss       = input.float(3.00, title="Stop Loss %", inline='5',  step=0.05, group="Risk Management")-isStopLoss      = input(true, 'Implement Stop Loss?', inline='5', group="Risk Management", tooltip='Activate Stop Loss')+isStopLoss      = input.bool(true, 'Implement Stop Loss?', inline='5', group="Risk Management", tooltip='Activate Stop Loss')stop_perc       = input.float(6.00, title="Trailing %", step=0.125, inline='6', group="Risk Management") * 0.01-trailing        = input(false, title="Implement trailing stop?",inline='6', group="Risk Management")+trailing        = input.bool(false, title="Implement trailing stop?",inline='6', group="Risk Management")// Position Management⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © JCGMarkets -//@version=5+//@version=6strategy("B.Bands | Augmented | Intra-range | Long-Only", shorttitle = "BB|A|IR|L", initial_capital=1000, commission_value=0.075, slippage = 0, overlay = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 41 msYes 1,000 bars in 95 msNot measured
PineTSNot testedNot testedNot 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/// © JCGMarkets //@version=5strategy("B.Bands | Augmented | Intra-range | Long-Only", shorttitle = "BB|A|IR|L", initial_capital=1000, commission_value=0.075, slippage = 0, overlay = true)// TODO stop loss plot add short// Control Panel ============================================================================================================================================================//Technical Indicators Datashow_simp   = input.bool(true, title="Simple Bollinger Bands ", inline='1', group="Strategy System")show_augm   = input.bool(false, title="Augmented Bollinger Bands", inline='1', group="Strategy System",tooltip='Select Bollinger Band Indicator to trade Simple or Augmented') periods     = input.int(20, title="Periods", minval = 2, step = 1,inline='2', group="Technical Inputs")std         = input.float(2, title="Std", minval=0.1 , step = 0.1, group="Technical Inputs",inline='2', tooltip='Technical inputs for indicator calculation, Periods for MA and Standard Deviation')// Strategy dataentry_source    = input(close, title="Entry source", group="Strategy Inputs", inline='3')exit_source     = input(high, title="Exit source", group="Strategy Inputs", inline='3',tooltip='For entry: Activate signal if the source lies below (for Long) or above (for Short). For exit: When price reach target selected')max_spread_bb   = input.float(99999.0, title="Max Spread Tolerance Beetween Bands", step=0.1, group="Strategy Inputs",tooltip='Max. Tolerance beetween lower and upper band to allow trade for range systems')// Profittake_profit     = input.string("opposite", title = "Profit to band:", inline='4', options = ["middle", "opposite"], group="Profit Target")sell_profit     = input(false, title="Only sell in profit", group="Profit Target", inline='4', tooltip='Sell only if position is on profit, unless Stop Loss active')// Risk Managementstop_loss       = input.float(3.00, title="Stop Loss %", inline='5',  step=0.05, group="Risk Management")isStopLoss      = input(true, 'Implement Stop Loss?', inline='5', group="Risk Management", tooltip='Activate Stop Loss')stop_perc       = input.float(6.00, title="Trailing %", step=0.125, inline='6', group="Risk Management") * 0.01trailing        = input(false, title="Implement trailing stop?",inline='6', group="Risk Management")// Position ManagementriskPerc   = input.float(title="% of available capital", maxval=100 , inline='7', group='Position Size', defval=5, step=0.25, tooltip='Use a % of the total capital selected for strategy')usePosSize = input.bool(title="Limit strategy capital?", defval=false, inline='7', group='Position Size', tooltip='If activated, only uses the percentage of capital selected from the properties tab. Default 1000$')// Backtest Range start   = input.time(timestamp("2019-11-01T00:00:00"),inline='9', title="Starting Date",group="BACKTEST RANGE" )end     = input.time(timestamp("2023-12-12T00:00:00"), inline='9',title="Ending Date",group="BACKTEST RANGE",tooltip='Select the range for backtest and live strategy')// Helper Functions ============================================================================================================================================================// Date ConditionIn_date() =>     from_date = time >= start    to_date = time <= end    from_date and to_dateposition = usePosSize ? math.round((strategy.equity * (riskPerc / 100) / close) , 6) : math.round((strategy.equity / close) , 6)in_position = strategy.position_size > 0 // Initialize variables ========================================================================================================================================================var SL = 0.0var SLT= 0.0SLT := if in_position and In_date()    stop_inicial = entry_source * (1 - stop_perc)    math.max(stop_inicial, SLT[1])else    0slts = (low <= SLT) and (trailing == true)//Simple BB Calculation -> adapt if needed with different std for upper-lower, sma-ema, etc middle_sim = ta.sma(close, periods)//Augmented BB Calculation -> adapt if needed with different std for upper lower, etcmiddle_augm  = ta.ema(close, periods)middle_upp = ta.ema(high, periods)middle_low = ta.ema(low, periods)//Multiplierdev      = ta.stdev(close, periods) * std//Upper & Lower Bandsupper = (middle_sim + dev)lower = (middle_sim - dev)//Augmented Bandsupper_augm = (middle_upp + dev)lower_augm = (middle_low - dev)//Bands Spreadspread   = upper - lowerspread_augm   = upper_augm - lower_augm//Trading Conditions entry_long = (entry_source <= lower) and (spread < max_spread_bb)entry_long_augm = (entry_source <= lower_augm) and (spread_augm < max_spread_bb)// Simple Bollingerif (not in_position and show_simp and In_date())    if entry_long        // Trigger buy order        strategy.entry("Entry", strategy.long, qty = position )        SL := close * (1 - (stop_loss / 100)) // You could determine wether or not implement stop loss with bool input and if condition here.if in_position and show_simp and not sell_profit and In_date()    //Exits if not sell in profit    if take_profit == "middle"         strategy.exit("Target", "Entry", limit = middle_sim, stop =  isStopLoss ? SL: na, comment="Exit")    if take_profit == "opposite"        strategy.exit("Target", "Entry", limit = upper, stop =  isStopLoss ? SL :na , comment="Exit")    if in_position and show_simp and sell_profit and In_date()    //Exits if sell in profit    if take_profit == "middle"         strategy.exit("Target", "Entry", limit = (strategy.openprofit > 0 ? middle_sim: na), stop =  isStopLoss ? SL: na, comment="Exit")    if take_profit == "opposite"        strategy.exit("Target", "Entry", limit = (strategy.openprofit > 0 ? upper: na), stop =  isStopLoss ? SL : na, comment="Exit")    if in_position and show_simp and slts and In_date()    //Trailing activation    strategy.close("Entry", comment="SLT")if not In_date()    //Exit due out of date range    strategy.close("Entry", comment="Out of date range")// Augmented Bollinger Conditionsif (not in_position and show_augm and In_date())     if entry_long_augm        // Trigger buy order        strategy.entry("Entry_A", strategy.long, qty = position )        SL := close * (1 - (stop_loss / 100) )if in_position and show_augm and not sell_profit and In_date()    //Exits and not sell in profit    if take_profit == "middle"        strategy.exit("Target", "Entry_A", limit = middle_augm, stop =  isStopLoss ? SL : na, comment="Exit")    if take_profit == "opposite"        strategy.exit("Target", "Entry_A", limit = upper_augm, stop =  isStopLoss ? SL : na, comment="Exit")                    if in_position and show_augm and sell_profit and In_date()     //Exit only in profit    if take_profit == "middle"        strategy.exit("Target", "Entry_A", limit = (strategy.openprofit > 0 ? middle_augm:na), stop =  isStopLoss ? SL : na, comment="Exit")    if take_profit == "opposite"        strategy.exit("Target", "Entry_A", limit = (strategy.openprofit > 0 ? upper_augm: na) , stop =  isStopLoss ? SL : na, comment="Exit") if in_position  and show_augm and slts and In_date()    //Trigger trailing    strategy.close("Entry_A", comment="SLT")    if not In_date()    //Out of date trigger    strategy.close("Entry_A", comment= "Out of date range")// Plotting ==========================================================================================================================plot(in_position ? SL > 0 ? SL : na : na , style = plot.style_circles, color = color.red, title = "Stop Loss")plot(in_position ? trailing ? SLT > 0 ? SLT : na : na : na , style = plot.style_circles, color = color.blue, title = "Trailing Stop" )s = plot(show_simp ? upper : na , color = color.aqua, title='Simple Upper Bollinger Band')plot(show_simp ? middle_sim : na , color=color.red, title='Simple Moving Average')i = plot(show_simp ? lower : na , color = color.aqua, title='Simple Lower Bollinger Band')fill(s,i, color=color.new(color.aqua,90))plot(show_augm ? middle_augm : na , color=color.blue, title='Augmented Moving Average')s_a = plot( show_augm ? upper_augm : na, color=color.orange, title='Augmented Upper Bollinger Band')i_a = plot( show_augm ? lower_augm : na, color= color.orange, title='Simple Lower Bollinger Band')fill(s_a,i_a, color=color.new(color.orange, 90))