Pine Script v4 · Strategy
[EURUSD60] BB Expansion Strategy
A Pine Script v4 strategy built on SMA (close[index], 40), Stdev (close[index], 40) and EMA (close[index], 14). It has 8 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 14 settings; defaults include Large BB Length 40, Small BB Length 20 and BB StdDev 2.0.
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 [EURUSD60] BB Expansion Strategy repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did [EURUSD60] BB Expansion Strategy 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 entry conditions never all held on this data. On BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Can [EURUSD60] BB Expansion Strategy be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does [EURUSD60] BB Expansion Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 113, 117.
- Does [EURUSD60] BB Expansion Strategy run in Zeal Terminal?
- Yes
- It compiles in 37 ms and runs 1,000 bars in 113 ms, in the browser.
BTCUSDT · 1D · default settings
- Large BB Basis
- Large BB Upper
- Large BB Lower
- Small BB Basis
- Small BB Upper
- Small BB Lower
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BINANCE:BTCUSDT 240 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.
- 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, $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.
-
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.
-
Note
Uses an argument v6 removed
when = on line 121, 123, 125, 127. The upgraded version below moves each call inside an if block.
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 security → request.security, sma → ta.sma, stdev → ta.stdev, ema → ta.ema, atr → ta.atr, round → math.round.
- 4 strategy calls use the when = argument (line 121, 123, 125, 127). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 9 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 7: input(type = input.resolution) → input.timeframe()
- Line 8: input(type = input.integer) → input.int()
- Line 9: input(type = input.resolution) → input.timeframe()
- Line 10: input(type = input.integer) → input.int()
- Line 11: input(type = input.float) → input.float()
20 more edits
- Line 14: input(type = input.resolution) → input.timeframe()
- Line 23: input(type = input.float) → input.float()
- Line 24: input(type = input.float) → input.float()
- Line 25: input(type = input.float) → input.float()
- Line 26: input(type = input.float) → input.float()
- Line 60: security → request.security
- Line 60: sma → ta.sma
- Line 61: security → request.security
- Line 61: stdev → ta.stdev
- Line 65: security → request.security
- Line 65: sma → ta.sma
- Line 66: security → request.security
- Line 66: stdev → ta.stdev
- Line 71: security → request.security
- Line 71: ema → ta.ema
- Line 72: security → request.security
- Line 72: ema → ta.ema
- Line 79: atr → ta.atr
- Line 81: round → math.round
- Line 82: round → math.round
⋯// © kasaism-//@version=4+//@version=5strategy(title="[EURUSD60] BB Expansion Strategy", shorttitle="[EURUSD60] BBEXP",overlay=true, max_bars_back=5000, max_labels_count=500)⋯////BB-largeBbRes = input(title="Large BB Resolution", type=input.resolution, defval="", group="BB")+largeBbRes = input.timeframe(title="Large BB Resolution", defval="", group="BB")-largeBbLength = input(title="Large BB Length", type=input.integer, defval=40, minval=1, group="BB")+largeBbLength = input.int(title="Large BB Length", defval=40, minval=1, group="BB")-smallBbRes = input(title="Small BB Resolution ", type=input.resolution, defval="", group="BB")+smallBbRes = input.timeframe(title="Small BB Resolution ", defval="", group="BB")-smallBbLength = input(title="Small BB Length", type=input.integer, defval=20, minval=1, group="BB")+smallBbLength = input.int(title="Small BB Length", defval=20, minval=1, group="BB")-multi = input(title="BB StdDev", type=input.float, defval=2.0, maxval=10, minval=0.01, group="BB")+multi = input.float(title="BB StdDev", defval=2.0, maxval=10, minval=0.01, group="BB")validLen = input(title="BB expand valid length", defval=14, group="BB")// 3 each EMA settings. EMA directions are as each time frame directions. -resFirstTime = input(title="EMA Trend t/f", type=input.resolution, defval="240", group="SMT")+resFirstTime = input.timeframe(title="EMA Trend t/f", defval="240", group="SMT")// resSecondTime = input(title="Second t/f", type=input.resolution, defval="30", group="SMT") ⋯riskManagementRule = input(riskManagementRule1, "Detect Risk Management Based On", options=[riskManagementRule1, riskManagementRule2, "No detection"], group="Trade")-atrMulti = input(3.0, title="ATR Multiple", type=input.float, minval = 1.0, group="ATR")+atrMulti = input.float(3.0, title="ATR Multiple", minval = 1.0, group="ATR")-riskRewardRatio = input(1.5, title="Risk Reward Ratio for ATR", type=input.float, minval = 0.01, group="ATR")+riskRewardRatio = input.float(1.5, title="Risk Reward Ratio for ATR", minval = 0.01, group="ATR")-stopLossPoint = input(100, title="Stop Loss Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")+stopLossPoint = input.float(100, title="Stop Loss Point for Braket(tick)", minval = 1.0, group="Bracket")-takeProfitPoint = input(200, title="Take Profit Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")+takeProfitPoint = input.float(200, title="Take Profit Point for Braket(tick)", minval = 1.0, group="Bracket")// === /INPUTS/ === //⋯//large BB-lrgBbBasis = security(syminfo.tickerid, largeBbRes, sma(close[index], largeBbLength))+lrgBbBasis = request.security(syminfo.tickerid, largeBbRes, ta.sma(close[index], largeBbLength))-lrgBbDev = multi * security(syminfo.tickerid, largeBbRes, stdev(close[index], largeBbLength))+lrgBbDev = multi * request.security(syminfo.tickerid, largeBbRes, ta.stdev(close[index], largeBbLength))lrgBbUpper = lrgBbBasis + lrgBbDev⋯//small BB-smlBbBasis = security(syminfo.tickerid, smallBbRes, sma(close[index], smallBbLength))+smlBbBasis = request.security(syminfo.tickerid, smallBbRes, ta.sma(close[index], smallBbLength))-smlBbDev = multi * security(syminfo.tickerid, smallBbRes, stdev(close[index], smallBbLength))+smlBbDev = multi * request.security(syminfo.tickerid, smallBbRes, ta.stdev(close[index], smallBbLength))smlBbUpper = smlBbBasis + smlBbDev⋯//EMA Trend-base=security(syminfo.tickerid, resFirstTime, ema(close[index],emaLen))+base=request.security(syminfo.tickerid, resFirstTime, ta.ema(close[index],emaLen))-sig=security(syminfo.tickerid, resFirstTime, ema(base[index],smooth))+sig=request.security(syminfo.tickerid, resFirstTime, ta.ema(base[index],smooth))emaTrend = not(na(base) or na(sig)) ? base < sig ? dn : up : na⋯float takeProfitLineForShort = na-atr_ = atr(14) * atrMulti+atr_ = ta.atr(14) * atrMultiif riskManagementRule == riskManagementRule1- stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : round(close[index] - atr_,3) : na+ stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : math.round(close[index] - atr_,3) : na- stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : round(close[index] + atr_,3) : na+ stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : math.round(close[index] + atr_,3) : na takeProfitLineForLong := strategy.position_size > 0 ? takeProfitLineForLong[1] ? takeProfitLineForLong[1] : close[index] + atr_*riskRewardRatio : na⋯Same 9 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 12: input() → input.int()
- Line 17: input() → input.int()
- Line 18: input() → input.int()
- Line 121: when = isAtrLongStop → if block
- Line 123: when = isAtrShortStop → if block
- Line 125: when = isAtrLongLimit → if block
- Line 127: when = isAtrShortLimit → if block
⋯multi = input.float(title="BB StdDev", defval=2.0, maxval=10, minval=0.01, group="BB")-validLen = input(title="BB expand valid length", defval=14, group="BB")+validLen = input.int(title="BB expand valid length", defval=14, group="BB")// 3 each EMA settings. EMA directions are as each time frame directions. ⋯// resThirdTime = input(title="Third t/f", type=input.resolution, defval="", group="SMT")-emaLen = input(14, minval=1, title="Length", group="SMT") +emaLen = input.int(14, minval=1, title="Length", group="SMT") -smooth = input(3, minval=1, title="Smooth factor", group="SMT")+smooth = input.int(3, minval=1, title="Smooth factor", group="SMT")//Lisk Management⋯ if(isAtrLongStop)- strategy.close("LongEntry", when=isAtrLongStop, comment="ATR Stop")+ if isAtrLongStop+ strategy.close("LongEntry", comment="ATR Stop") if(isAtrShortStop)- strategy.close("ShortEntry", when=isAtrShortStop, comment="ATR Stop")+ if isAtrShortStop+ strategy.close("ShortEntry", comment="ATR Stop") if(isAtrLongLimit)- strategy.close("LongEntry", when=isAtrLongLimit, comment="ATR Limit")+ if isAtrLongLimit+ strategy.close("LongEntry", comment="ATR Limit") if(isAtrShortLimit)- strategy.close("ShortEntry", when=isAtrShortLimit, comment="ATR Limit")+ if isAtrShortLimit+ strategy.close("ShortEntry", comment="ATR Limit")// === /TRADE/ === //⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L81:C56: cannot use 'float' 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.
⋯// © kasaism-//@version=5+//@version=6strategy(title="[EURUSD60] BB Expansion Strategy", shorttitle="[EURUSD60] BBEXP",overlay=true, max_bars_back=5000, max_labels_count=500)⋯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 |
|---|---|---|---|
| BB | |||
| Large BB Resolution | | timeframe (written input.resolution) | lrgBbBasis lrgBbDev |
| Large BB Length | 40 | int (written input.integer) · min 1 | lrgBbBasis lrgBbDev |
| Small BB Resolution | | timeframe (written input.resolution) | smlBbBasis smlBbDev |
| Small BB Length | 20 | int (written input.integer) · min 1 | smlBbBasis smlBbDev |
| BB StdDev | 2.0 | float · min 0.01 · max 10 | lrgBbDev smlBbDev |
| BB expand valid length | 14 | int | line 94 |
| SMT | |||
| EMA Trend t/f | 240 | timeframe (written input.resolution) | base sig |
| Length | 14 | int · min 1 | base |
| Smooth factor | 3 | int · min 1 | sig |
| Trade | |||
| Detect Risk Management Based On | riskManagementRule1 | value · options [riskManagementRule1, riskManagementRule2, "No detection"] | exit LongEntry exit ShortEntry line 80 line 85 line 112 line 116 line 119 |
| ATR | |||
| ATR Multiple | 3.0 | float · min 1.0 | atr_ |
| Risk Reward Ratio for ATR | 1.5 | float · min 0.01 | takeProfitLineForLong takeProfitLineForShort |
| Bracket | |||
| Stop Loss Point for Braket(tick) | 100 | float · min 1.0 | stopLossLineForLong stopLossLineForShort exit LongEntry exit ShortEntry |
| Take Profit Point for Braket(tick) | 200 | float · min 1.0 | takeProfitLineForLong takeProfitLineForShort exit LongEntry exit ShortEntry |
What it calculates
- SMA (
sma,ta.smain v5)close[index], Large BB Length (40)lrgBbBasis · line 60 - Stdev (
stdev,ta.stdevin v5)close[index], Large BB Length (40)lrgBbDev · line 61 - SMA (
sma,ta.smain v5)close[index], Small BB Length (20)smlBbBasis · line 65 - Stdev (
stdev,ta.stdevin v5)close[index], Small BB Length (20)smlBbDev · line 66 - EMA (
ema,ta.emain v5)close[index], Length (14)base · line 71 - EMA (
ema,ta.emain v5)base[index], Smooth factor (3)sig · line 72 - ATR (
atr,ta.atrin v5)14atr_ · line 79
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.
The script has 61 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open LongEntry long | (isBbLong and isEmaLong) | On | 111 |
| Exit LongEntry stop and limit | riskManagementRule == riskManagementRule2 | On | 113 |
| Open ShortEntry short | (isBbShort and isEmaShort) | On | 115 |
| Exit ShortEntry stop and limit | riskManagementRule == riskManagementRule2 | On | 117 |
| Close LongEntry | isAtrLongStoplow[index] <= stopLossLineForLong | On | 121 |
| Close ShortEntry | isAtrShortStophigh[index] >= stopLossLineForShort | On | 123 |
| Close LongEntry | isAtrLongLimithigh[index] >= takeProfitLineForLong | On | 125 |
| Close ShortEntry | isAtrShortLimitlow[index] <= takeProfitLineForShort | On | 127 |
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.
- ClearHigher-timeframe data6 security call(s), none with lookahead on.
- 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
Not run on other markets: the script requests BINANCE:BTCUSDT 240, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.
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 |
|---|---|---|---|---|---|
| [EURUSD60] BB Expansion Strategy this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Trend Following with Bollinger Bands by Robrecht99 | sma stdev ema atr | v5 strategy | +2.5% | 7 | 1.7% |
| [KL] BOLL + MACD Strategy v2 (published) by DojiEmoji | sma stdev ema atr | v4 strategy | −32.1% | 28 | 54.0% |
| [KL] Bollinger bands + RSI Strategy by DojiEmoji | sma stdev atr ema | v4 strategy | +28.2% | 30 | 14.7% |
| [KL] Bollinger Bands Consolidation Strategy by DojiEmoji | sma stdev atr ema | v4 strategy | +39.1% | 33 | 19.6% |
| Full strategy AllinOne with risk management MACD RSI PSAR ATR MA by SoftKill21 | sma stdev ema atr | v4 strategy | +2,985,110.0% | 3 | 2,350,820.0% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 37 ms | Yes 1,000 bars in 113 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. 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/// © kasaism//@version=4strategy(title="[EURUSD60] BB Expansion Strategy", shorttitle="[EURUSD60] BBEXP",overlay=true, max_bars_back=5000, max_labels_count=500)// === INPUTS === //////BBlargeBbRes = input(title="Large BB Resolution", type=input.resolution, defval="", group="BB")largeBbLength = input(title="Large BB Length", type=input.integer, defval=40, minval=1, group="BB")smallBbRes = input(title="Small BB Resolution ", type=input.resolution, defval="", group="BB")smallBbLength = input(title="Small BB Length", type=input.integer, defval=20, minval=1, group="BB")multi = input(title="BB StdDev", type=input.float, defval=2.0, maxval=10, minval=0.01, group="BB")validLen = input(title="BB expand valid length", defval=14, group="BB")// 3 each EMA settings. EMA directions are as each time frame directions. resFirstTime = input(title="EMA Trend t/f", type=input.resolution, defval="240", group="SMT")// resSecondTime = input(title="Second t/f", type=input.resolution, defval="30", group="SMT") // resThirdTime = input(title="Third t/f", type=input.resolution, defval="", group="SMT")emaLen = input(14, minval=1, title="Length", group="SMT") smooth = input(3, minval=1, title="Smooth factor", group="SMT")//Lisk Managementvar riskManagementRule1 = "ATR"var riskManagementRule2 = "Bracket"riskManagementRule = input(riskManagementRule1, "Detect Risk Management Based On", options=[riskManagementRule1, riskManagementRule2, "No detection"], group="Trade")atrMulti = input(3.0, title="ATR Multiple", type=input.float, minval = 1.0, group="ATR")riskRewardRatio = input(1.5, title="Risk Reward Ratio for ATR", type=input.float, minval = 0.01, group="ATR")stopLossPoint = input(100, title="Stop Loss Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")takeProfitPoint = input(200, title="Take Profit Point for Braket(tick)", type=input.float, minval = 1.0, group="Bracket")// === /INPUTS/ === //// === CONSTANT === ////For barmerge.lookahead_offindex = barstate.isrealtime ? 1 : 0//For EntryNOENTRY=0LONG=1SHORT=2//SMT colorint up=1int dn=2int up_HL=3int dn_HL=4//label colorcolor_bearish = color.redcolor_bullish = color.blueC_label_color_bearish = color.redC_label_color_bullish = color.blue// === /CONSTANT/ === //// === FUNCTIONS === ////BB trade directionbbTradeDetection(lrgUpper, lrgLower, smlUpper, smlLower) => if not(na(lrgUpper) or na(lrgLower) or na(smlUpper) or na(smlLower)) if lrgUpper < smlUpper and lrgLower > smlLower true else false else na// === /FUNCTIONS/ === //// === CALCURATES === //////BB//large BBlrgBbBasis = security(syminfo.tickerid, largeBbRes, sma(close[index], largeBbLength))lrgBbDev = multi * security(syminfo.tickerid, largeBbRes, stdev(close[index], largeBbLength))lrgBbUpper = lrgBbBasis + lrgBbDevlrgBbLower = lrgBbBasis - lrgBbDev//small BBsmlBbBasis = security(syminfo.tickerid, smallBbRes, sma(close[index], smallBbLength))smlBbDev = multi * security(syminfo.tickerid, smallBbRes, stdev(close[index], smallBbLength))smlBbUpper = smlBbBasis + smlBbDevsmlBbLower = smlBbBasis - smlBbDevbbTrade = bbTradeDetection(lrgBbUpper, lrgBbLower, smlBbUpper, smlBbLower)//EMA Trendbase=security(syminfo.tickerid, resFirstTime, ema(close[index],emaLen))sig=security(syminfo.tickerid, resFirstTime, ema(base[index],smooth))emaTrend = not(na(base) or na(sig)) ? base < sig ? dn : up : na////LISK MANAGEMENTfloat stopLossLineForLong = nafloat stopLossLineForShort = nafloat takeProfitLineForLong = nafloat takeProfitLineForShort = naatr_ = atr(14) * atrMultiif riskManagementRule == riskManagementRule1 stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : round(close[index] - atr_,3) : na stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : round(close[index] + atr_,3) : na takeProfitLineForLong := strategy.position_size > 0 ? takeProfitLineForLong[1] ? takeProfitLineForLong[1] : close[index] + atr_*riskRewardRatio : na takeProfitLineForShort := strategy.position_size < 0 ? takeProfitLineForShort[1] ? takeProfitLineForShort[1] :close[index] - atr_*riskRewardRatio : naif riskManagementRule == riskManagementRule2 stopLossLineForLong := strategy.position_size > 0 ? stopLossLineForLong[1] ? stopLossLineForLong[1] : close[index] - stopLossPoint * syminfo.mintick : na stopLossLineForShort := strategy.position_size < 0 ? stopLossLineForShort[1] ? stopLossLineForShort[1] : close[index] + stopLossPoint * syminfo.mintick : na takeProfitLineForLong := strategy.position_size > 0 ? takeProfitLineForLong[1] ? takeProfitLineForLong[1] : close[index] +takeProfitPoint * syminfo.mintick : na takeProfitLineForShort := strategy.position_size < 0 ? takeProfitLineForShort[1] ? takeProfitLineForShort[1] :close[index] - takeProfitPoint * syminfo.mintick : na// === /CALCURATES/ === //// === CONDITIONS === ////BBbool isBbEntry = nafor i=0 to validLen isBbEntry := bbTrade==true ? true : bbTrade[i]==true ? true : false//plotshape(isBbEntry, style=shape.circle, location=location.bottom)isBbLong = isBbEntry and open[index] < smlBbBasis[index] and close[index] > smlBbBasis[index]isBbShort = isBbEntry and open[index] > smlBbBasis[index] and close[index] < smlBbBasis[index] //SMTisEmaLong = emaTrend == up isEmaShort = emaTrend == dn//ATRisAtrLongStop = low[index] <= stopLossLineForLongisAtrShortStop = high[index] >= stopLossLineForShortisAtrLongLimit = high[index] >= takeProfitLineForLongisAtrShortLimit = low[index] <= takeProfitLineForShort// === /CONDITIONS/ === //// === TRADE === ////ENTRYif (isBbLong and isEmaLong) strategy.entry("LongEntry", strategy.long, 1000000, comment="LongEntry") if riskManagementRule == riskManagementRule2 strategy.exit("LongEntry", loss=stopLossPoint, profit=takeProfitPoint, comment="bracket")if (isBbShort and isEmaShort) strategy.entry("ShortEntry", strategy.short, 1000000, comment="ShortEntry") if riskManagementRule == riskManagementRule2 strategy.exit("ShortEntry", loss=stopLossPoint, profit=takeProfitPoint, comment="bracket")//EXITif riskManagementRule == riskManagementRule1 if(isAtrLongStop) strategy.close("LongEntry", when=isAtrLongStop, comment="ATR Stop") if(isAtrShortStop) strategy.close("ShortEntry", when=isAtrShortStop, comment="ATR Stop") if(isAtrLongLimit) strategy.close("LongEntry", when=isAtrLongLimit, comment="ATR Limit") if(isAtrShortLimit) strategy.close("ShortEntry", when=isAtrShortLimit, comment="ATR Limit")// === /TRADE/ === //// === PLOTS === //plot(lrgBbBasis, title="Large BB Basis", linewidth=2, color=color.gray)plot(lrgBbUpper, title="Large BB Upper", linewidth=2, color=color.gray)plot(lrgBbLower, title="Large BB Lower", linewidth=2, color=color.gray)plot(smlBbBasis, title="Small BB Basis", color=color.white)plot(smlBbUpper, title="Small BB Upper", color=color.white)plot(smlBbLower, title="Small BB Lower", color=color.white)plot(base, title="EMA Line", color= emaTrend==dn ? color_bearish : emaTrend==up ? color_bullish : color.gray)plot(stopLossLineForLong ? stopLossLineForLong : na, title="S/L Line For Long", color=color.yellow, style=plot.style_circles)plot(stopLossLineForShort ? stopLossLineForShort : na, title="S/L Line For Short", color=color.yellow, style=plot.style_circles)plot(takeProfitLineForLong ? takeProfitLineForLong : na, title="T/P Line For Long", color=color.purple, style=plot.style_circles)plot(takeProfitLineForShort ? takeProfitLineForShort : na, title="T/P Line For Short", color=color.purple, style=plot.style_circles)// /=== PLOTS ===/ //