Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

EMA bands + leledc + bollinger bands trend following strategy v2

A Pine Script v5 strategy built on EMA (close, 34), SMA (close, 20) and Stdev (close, 20). It has 110 order rules, 24 entries among them, and trades long and short with the default settings; 4 entries are switched off until a setting enables them. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.036 commission. 61 settings; defaults include EMA Length 34, Top middle band multiplier 1 and Bottom middle band multiplier 1.

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 EMA bands + leledc + bollinger bands trend following strategy v2 repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did EMA bands + leledc + bollinger bands trend following strategy v2 do on BTCUSDT 1D with default settings?
+7.75%
From 26 Jan 2024 to 21 Oct 2026, over 38 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does EMA bands + leledc + bollinger bands trend following strategy v2 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: 38 before, 38 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 EMA bands + leledc + bollinger bands trend following strategy v2 use a stop loss?
Yes
strategy.exit sets a stop on line 646, 648, 672, 674.
Does EMA bands + leledc + bollinger bands trend following strategy v2 run in Zeal Terminal?
Yes
It compiles in 256 ms and runs 1,000 bars in 213 ms, in the browser.

BTCUSDT · 1D · default settings

  • Char
  • Char
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
50,00075,000100,000125,000AprJulOct2025AprJulOct2026AprJulOct$1,410$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. Zeal Terminal's engine currently reads an order side written as direction = strategy.short, direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 528, 537, 546, 555, 582, 591 and more) so the engine trades the way the script says. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 360, which this page cannot load in your browser.

Needs BINANCE:BTCUSDT 360 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
+7.75%
$77.53
Buy and hold
+102.5%
same period
Closed trades
38
10 won · 28 lost
Profitable
26.3%
of closed trades
Profit factor
1.07
gross profit ÷ gross loss
Max drawdown
31.97%
−$352.55

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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.sma(volume, 100) ignores the settings line 177

    Line 177 hard-codes volume where line 95 uses “Source” and 100 where line 95 uses “Bollinger Bands SMA Period Length”. Changing those settings moves one band but not this one.

    ta.sma(volume,100)ta.sma(i_srcBB, i_BBlength)
  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    1 setting has no label

    In the settings dialog res (line 57) shows 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

    The long side is off by default line 381

    Its orders only fire after “Use slow EMA filter” is switched on. The figures on this page cover long and long and long and short and short and short and counter trend short and counter trend short and counter trend short and counter trend short and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend short and counter trend short and default long and default short trades only.

  • Note

    The short side is off by default line 407

    Its orders only fire after “Use slow EMA filter” is switched on. The figures on this page cover long and long and long and short and short and short and counter trend short and counter trend short and counter trend short and counter trend short and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend short and counter trend short and default long and default short trades only.

  • Note

    The default long side is off by default line 686

    Its orders only fire after “Use slow EMA filter” is switched on. The figures on this page cover long and long and long and short and short and short and counter trend short and counter trend short and counter trend short and counter trend short and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend short and counter trend short and default long and default short trades only.

  • Note

    The default short side is off by default line 692

    Its orders only fire after “Use slow EMA filter” is switched on. The figures on this page cover long and long and long and short and short and short and counter trend short and counter trend short and counter trend short and counter trend short and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend long and counter trend short and counter trend short and default long and default short trades only.

Settings

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

SettingDefaultType and rangeFeeds
EMA Length34int · min 1 · step 1EMA rangema highShortEMA lowShortEMA
Open Conditions
Enable middle EMA band breakout: Longtrueboolline 358
Enable middle EMA band breakdown: Shorttrueboolline 384
Enable middle EMA band bounce re-entry: LongWorks best when early close conditions are usedfalseboollongBounce
Enable middle EMA band bounce re-entry: ShortWorks best when early close conditions are usedfalseboolshortBounce
Enable default positioning: LongDoes not work with "Enable default positioning: Short" also selected. Works best when early close conditions are usedfalseboolline 681 line 687 line 709 line 728 line 747 line 764
Enable default positioning: ShortDoes not work with "Enable default positioning: Long" also selected. Works best when early close conditions are usedfalseboolline 681 line 687 line 704 line 723 line 742 line 759
Top middle band multiplier1float · step 0.1middleBandTop shortbandsHigh phiExtensionHigh
Bottom middle band multiplier1float · step 0.1middleBandBot shortbandsLow phiExtensionLow
Use slow EMA filterCondition does not apply to counter-trend tradesfalseboolclose Short close Counter Trend Short close Default Short entry Long close Long close Counter Trend Long close Default Long entry Short entry Default Long entry Default Short line 359 line 371 line 385 line 397 line 682 line 688
Slow EMA Length200int · min 1 · step 1slowEMA
Close Conditions
Close on crosses through middle EMA bandsSelecting "Delayed bars inside" will closing positions after specified amount of candles close in between the middle EMA bands without breaking outOpposite bandstring · options ['Nearest band', 'Opposite band', 'Delayed bars inside']line 556 line 559 line 562 line 610 line 613 line 616 line 713 line 715 line 732 line 734 line 751 line 753 line 768 line 770
Delayed close no. of bars4int · min 1 · max 10 · step 1close Long close Short line 509 line 566 line 620
Close on Leledc barsfalseboolline 422 line 435 line 538 line 547 line 592 line 601
Which Leledc bar?Firststring · options ['First', 'Second', 'Third', 'Fourth', 'Fifth']numLele
Close on Bollinger Band exhaustion barsBollinger Band Exhaustion bars are candles that close back inside the Bollinger Bands when RSI is overbought or oversold. Settings for both can be changed under the -Bollinger Bands Exhaustion Bar Settings- header.falseboolline 458 line 471 line 520 line 529 line 574 line 583
Which BB exhaustion bar?Firststring · options ['First', 'Second', 'Third']numBBs
Close on loss of Buy/Sell zonefalseboolline 517 line 571
Which Buy/Sell zone?Innerstring · options ['Inner', 'Outer']line 488
Counter Trade Settings
Enable counter-trend trades: LongDoes not work with "Enable default positioning: Short" selectedfalseboolline 577 line 586 line 595 line 604 line 628 line 709 line 728 line 747 line 764
TriggerLeledcstring · options ['Leledc', 'BB Exhaustion']line 577 line 586 line 595 line 604 line 629
Enable counter-trend trades: ShortDoes not work with "Enable default positioning: Long" selected"falseboolline 523 line 532 line 541 line 550 line 654 line 704 line 723 line 742 line 759
TriggerLeledcstring · options ['Leledc', 'BB Exhaustion']line 523 line 532 line 541 line 550 line 655
Leledc/BB must be outside which Buy/Sell zone to openInnerstring · options ['Inner', 'Outer']line 271
Closing conditions for counter-trend longs-Cross- type close conditions market close position on candle closes above selected region \n\n-Touch- type enable trailing limit orders that follow the selected regionCross Top Middle Bandstring · options ['Cross Outer Buy Zone', 'Cross Inner Buy Zone', 'Touch Inner Buy Zone', 'Cross Bottom Middle Band', 'Touch Bottom Middle Band', 'Cross Top Middle Band', 'Touch Top Middle Band', 'Cross Inner Sell Zone', 'Touch Inner Sell Zone', 'Cross Outer Sell Zone', 'Touch Outer Sell Zone', 'First Leledc', 'First BB Exhaustion']CTlongCloseCond CTlongTP
Closing conditions for counter-trend shorts-Cross- type close conditions market close position on candle closes below selected region \n\n-Touch- type enable trailing limit orders that follow the selected regionFirst Leledcstring · options ['Cross Outer Sell Zone', 'Cross Inner Sell Zone', 'Touch Inner Sell Zone', 'Cross Top Middle Band', 'Touch Top Middle Band', 'Cross Bottom Middle Band', 'Touch Bottom Middle Band', 'Cross Inner Buy Zone', 'Touch Inner Buy Zone', 'Cross Outer Buy Zone', 'Touch Outer Buy Zone', 'First Leledc', 'First BB Exhaustion']CTshortCloseCond CTshortTP
Flat stop-loss % for counter-trend longs10floatCTlongSL exit Counter Trend Long line 644 line 649
Flat stop-loss % for counter-trend shorts10floatCTshortSL exit Counter Trend Short line 670 line 675
Keltner Buy/Sell Zones
Use Keltner channel multiples for "Buy/Sell Zones"Enables inputting custom multiples and a different/smoother calculation of "Buy/Sell Zones". Default calculation is a multiple of EMA band highs and lowsfalseboolrangema shortbandsHigh shortbandsLow phiExtensionHigh phiExtensionLow
Outer MultiplierOnly for "Buy/Sell Zones" calculated by Keltner channels5.0floatupper lower
Inner MultiplierOnly for "Buy/Sell Zones" calculated by Keltner channels3.0floatinner_upper inner_lower
BB-Keltner squeze
Filter out trades during BB-Keltner squeezesfalseboollongBounce shortBounce shortMidBreak longMidBreak line 149 line 628 line 654
Bollinger Band Crossover ConditionAt Least Onestring · options ['Both', 'At Least One']line 150 line 153 line 156
BB Length30int · min 1B2basis B2dev
Keltner Length18int · min 1Kma Krangema
Use current timeframefalseboolres line 150 line 153
Res (no label in the script)360timeframesrcClose srcHigh srcLow
BB Standard Deviation2float · min 0.001 · max 50B2dev
Keltner Range1.5floatKupper Klower
Bollinger Bands Exhaustion Bar Settings
Bollinger Bands SMA Period Length20int · min 1BBbasis BBdev
Bollinger Bands Standard Deviation1.8float · min 0.001 · max 50BBdev
RSI Period Length8int · min 1 · step 1vrsi
RSI Oversold Value30int · min 0 · max 50 · step 1RSIoverSold
RSI Overbought value70int · min 50 · max 100 · step 1RSIoverBought
SourceclosesourceBBbasis BBdev vrsi OSOBcolor
Leledc Exhaustion Bar Settings
Require Volume breakout for Leledc barsfalseboolline 191
Volume Multiplier1.5floatleleVol
Highest / Lowest30intmajor
Bar count no6intmajor
Close4intline 184 line 187
bindexSindex1intbindex sindex
Visual Elements
Enable Trend Bar ColorColor bars green when above mid bands, red when below, and gray when inside. Dark green and dark red bars signal a position is kept open from the delayed close settings.falseboolline 696
Show "Buy/Sell Zones"trueboolLower sell zone Higher buy zone Top sell zone Bottom buy zone
Show EMAfalseboolEMA
Show middle EMA bandstrueboolTop median zone Bottom median zone
Show Slow EMAfalseboolplot
Show Leledc Exhausion Barstrueboolplotchar
Enable Bollinger Bands exhaustion bar coloringtrueboolline 697 line 774
Enable Bollinger bands exhaustion bar background coloringEnabling this can help visualize when dialing in Bollinger Bands and RSI settingsfalseboolbgcolor
Enable Buy/Sell zone failure bar coloringfalseboolline 698 line 738 line 775 line 787
Enable volatility squeeze (BB-Keltner) background coloringtrueboolbgcolor

What it calculates

  • EMAclose, EMA Length (34)EMA · line 87
  • EMAclose, Slow EMA Length (200)slowEMA · line 88
  • SMASource (close), Bollinger Bands SMA Period Length (20)BBbasis · line 95
  • StdevSource (close), Bollinger Bands SMA Period Length (20)BBdev · line 96
  • RSISource (close), RSI Period Length (8)vrsi · line 100
  • RMAhigh - low, EMA Length (34)rangema · line 111
  • SMAsrcClose, BB Length (30)B2basis · line 137
  • StdevsrcClose, BB Length (30)B2dev · line 138
  • EMAsrcClose, Keltner Length (18)Kma · line 142
  • EMAKrange, Keltner Length (18)Krangema · line 144
  • Barssincenot srcClose == barstate.isrealtimesqueezing · line 151
  • EMAhigh, EMA Length (34)highShortEMA · line 226
  • EMAlow, EMA Length (34)lowShortEMA · line 227
  • WMAshortbandsHigh, 8shortbandsHighEMA · line 239
  • WMAshortbandsLow, 8shortbandsLowEMA · line 240
  • WMAphiExtensionHigh, 8phiExtensionHighEMA · line 246
  • WMAphiExtensionLow, 8phiExtensionLowEMA · line 247

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 129 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Close ShortlongMidBreak and close > slowEMA and open < middleBandTopOn361
Close Counter Trend ShortlongMidBreak and close > slowEMA and open < middleBandTopOn362
Close Default ShortlongMidBreak and close > slowEMA and open < middleBandTopOn363
Open Long longlongMidBreak and close > slowEMA and open < middleBandTopOn364
Close ShortlongMidBreakOn366
Close Counter Trend ShortlongMidBreakOn367
Close Default ShortlongMidBreakOn368
Open Long longlongMidBreakOn369
Close Shortclose > slowEMAOn373
Close Counter Trend Shortclose > slowEMAOn374
Close Default Shortclose > slowEMAOn375
Open Long longclose > slowEMAOn376
Close Shorts_useSlowEMAOff “Use slow EMA filter”378
Close Counter Trend Shorts_useSlowEMAOff “Use slow EMA filter”379
Close Default Shorts_useSlowEMAOff “Use slow EMA filter”380
Open Long longs_useSlowEMAOff “Use slow EMA filter”381
Close LongshortMidBreak and close < slowEMA and open > middleBandBotOn387
Close Counter Trend LongshortMidBreak and close < slowEMA and open > middleBandBotOn388
Close Default LongshortMidBreak and close < slowEMA and open > middleBandBotOn389
Open Short shortshortMidBreak and close < slowEMA and open > middleBandBotOn390
Close LongshortMidBreakOn392
Close Counter Trend LongshortMidBreakOn393
Close Default LongshortMidBreakOn394
Open Short shortshortMidBreakOn395
Close Longclose < slowEMAOn399
Close Counter Trend Longclose < slowEMAOn400
Close Default Longclose < slowEMAOn401
Open Short shortclose < slowEMAOn402
Close Longs_useSlowEMAOff “Use slow EMA filter”404
Close Counter Trend Longs_useSlowEMAOff “Use slow EMA filter”405
Close Default Longs_useSlowEMAOff “Use slow EMA filter”406
Open Short shorts_useSlowEMAOff “Use slow EMA filter”407
Close LongreverBarColor == color.orangeOn519
Close LongOSOBcolor == color.yellowOn522
Close Longopen > CTbandTopOn525
Close Counter Trend Longopen > CTbandTopOn526
Close Default Longopen > CTbandTopOn527
Open Counter Trend Short shortopen > CTbandTopOn528
Close LongcountLongBBs == numBBsOn531
Close Longopen > CTbandTopOn534
Close Counter Trend Longopen > CTbandTopOn535
Close Default Longopen > CTbandTopOn536
Open Counter Trend Short shortopen > CTbandTopOn537
Close Longmajor == -1On540
Close Longhigh > CTbandTopOn543
Close Counter Trend Longhigh > CTbandTopOn544
Close Default Longhigh > CTbandTopOn545
Open Counter Trend Short shorthigh > CTbandTopOn546
Close LongcountLongLele == numLeleOn549
Close Longhigh > CTbandTopOn552
Close Counter Trend Longhigh > CTbandTopOn553
Close Default Longhigh > CTbandTopOn554
Open Counter Trend Short shorthigh > CTbandTopOn555
Close LongcrossDownTopMB or wiggleDownTopMBOn558
Close LongcrossDownBotMB or wiggleDownBotMBOn561
Close LongcrossDownBotMB or wiggleDownBotMBOn564
Close Longopen[i_numBars] > middleBandTop and close[i_numBars] < middleBandTop and inMidOn567
Close ShortreverBarColor == color.purpleOn573
Close ShortOSOBcolor == color.blueOn576
Close Shortopen < CTbandBottomOn579
Close Counter Trend Shortopen < CTbandBottomOn580
Close Default Shortopen < CTbandBottomOn581
Open Counter Trend Long longopen < CTbandBottomOn582
Close ShortcountShortBBs == numBBsOn585
Close Shortopen < CTbandBottomOn588
Close Counter Trend Shortopen < CTbandBottomOn589
Close Default Shortopen < CTbandBottomOn590
Open Counter Trend Long longopen < CTbandBottomOn591
Close Shortmajor == 1On594
Close Shortlow < CTbandBottomOn597
Close Counter Trend Shortlow < CTbandBottomOn598
Close Default Shortlow < CTbandBottomOn599
Open Counter Trend Long longlow < CTbandBottomOn600
Close ShortcountShortLele == numLeleOn603
Close Shortlow < CTbandBottomOn606
Close Counter Trend Shortlow < CTbandBottomOn607
Close Default Shortlow < CTbandBottomOn608
Open Counter Trend Long longlow < CTbandBottomOn609
Close ShortcrossUpBotMB or wiggleUpBotMBOn612
Close ShortcrossUpTopMB or wiggleUpTopMBOn615
Close ShortcrossUpTopMB or wiggleUpTopMBOn618
Close Shortopen[i_numBars] < middleBandBot and close[i_numBars] > middleBandBot and inMidOn621
Close Shortlow < CTbandBottomOn632
Close Counter Trend Shortlow < CTbandBottomOn633
Close Default Shortlow < CTbandBottomOn634
Open Counter Trend Long longlow < CTbandBottomOn635
Close ShortOSOBcolor == color.blueOn638
Close Counter Trend ShortOSOBcolor == color.blueOn639
Close Default ShortOSOBcolor == color.blueOn640
Open Counter Trend Long longOSOBcolor == color.blueOn641
Exit Counter Trend Long stopna(CTlongTP)On646
Exit Counter Trend Long stop and limitna(CTlongTP)On648
Exit Counter Trend Long limiti_CTlongSL == 0On650
Close Counter Trend LongCTlongCloseCondOn652
Close Longhigh > CTbandTopOn658
Close Counter Trend Longhigh > CTbandTopOn659
Close Default Longhigh > CTbandTopOn660
Open Counter Trend Short shorthigh > CTbandTopOn661
Close LongOSOBcolor == color.yellowOn664
Close Counter Trend LongOSOBcolor == color.yellowOn665
Close Default LongOSOBcolor == color.yellowOn666
Open Counter Trend Short shortOSOBcolor == color.yellowOn667
Exit Counter Trend Short stopna(CTshortTP)On672
Exit Counter Trend Short stop and limitna(CTshortTP)On674
Exit Counter Trend Short limiti_CTshortSL == 0On676
Close Counter Trend ShortCTshortCloseCondOn678
Open Default Long longclose > slowEMAOn684
Open Default Long longs_useSlowEMAOff “Use slow EMA filter”686
Open Default Short shortclose < slowEMAOn690
Open Default Short shorts_useSlowEMAOff “Use slow EMA filter”692

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

10/10trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationreads realtime-only state. Live values can differ from history.
  • 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 360, 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.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1315%−$321.24
Sideways market1833%$351.10
Falling market729%$48.07

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

51.2%

The 95th percentile of the worst drawdown when the same 38 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 26.6% to 51.2%; the tick is what actually happened, 26.9%. Order luck alone moves it this much.

0%59%
All 38 trades
SideEntryExitBarsP&L
long21 Mar 2024 67,840.5014 Apr 2024 63,924.5024−$58.40
short14 Apr 2024 63,924.5016 May 2024 66,206.5032−$34.30
long16 May 2024 66,206.5015 Jun 2024 66,044.0030−$2.88
short15 Jun 2024 66,044.0016 Jul 2024 64,724.1031$17.43
long16 Jul 2024 64,724.103 Aug 2024 61,498.3018−$46.59
short3 Aug 2024 61,498.3024 Aug 2024 64,037.2021−$36.78
long24 Aug 2024 64,037.2028 Aug 2024 59,415.004−$61.11
short28 Aug 2024 59,415.0014 Sep 2024 60,498.0017−$14.73
long14 Sep 2024 60,498.0010 Oct 2024 60,636.0026$1.19
short10 Oct 2024 60,636.0013 Oct 2024 63,206.203−$32.94
long13 Oct 2024 63,206.2030 Dec 2024 93,738.2078$352.42
short30 Dec 2024 93,738.204 Jan 2025 98,174.205−$52.06
long4 Jan 2025 98,174.2010 Jan 2025 92,552.506−$59.77
short10 Jan 2025 92,552.5016 Jan 2025 100,497.006−$84.12
long16 Jan 2025 100,497.003 Feb 2025 97,700.6018−$25.33
short3 Feb 2025 97,700.6022 Apr 2025 87,516.2078$89.27
long22 Apr 2025 87,516.206 Jun 2025 101,509.0045$151.35
short6 Jun 2025 101,509.008 Jun 2025 105,552.002−$44.73
long8 Jun 2025 105,552.0022 Jun 2025 102,120.0014−$35.15
short22 Jun 2025 102,120.0025 Jun 2025 106,083.003−$40.44
long25 Jun 2025 106,083.002 Aug 2025 113,298.0038$66.08
short2 Aug 2025 113,298.008 Aug 2025 117,472.006−$39.39
long8 Aug 2025 117,472.0020 Aug 2025 112,873.0012−$40.22
short20 Aug 2025 112,873.0012 Sep 2025 115,483.0023−$23.10
long12 Sep 2025 115,483.0023 Sep 2025 112,651.0011−$23.86
short23 Sep 2025 112,651.002 Oct 2025 118,595.009−$49.32
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$43.44
short11 Oct 2025 112,774.005 Jan 2026 91,529.7086$155.64
long5 Jan 2026 91,529.7021 Jan 2026 88,427.7016−$34.07
short21 Jan 2026 88,427.7016 Mar 2026 72,815.3054$167.22
long16 Mar 2026 72,815.3022 Mar 2026 68,918.106−$60.61
short22 Mar 2026 68,918.108 Apr 2026 71,924.2017−$46.89
long8 Apr 2026 71,924.2023 May 2026 75,539.5045$50.04
short23 May 2026 75,539.5015 Jul 2026 65,044.0053$146.62
long15 Jul 2026 65,044.001 Aug 2026 62,887.9017−$40.86
short1 Aug 2026 62,887.909 Aug 2026 64,962.608−$39.33
long9 Aug 2026 64,962.6013 Aug 2026 63,480.004−$26.52
short13 Aug 2026 63,480.0019 Aug 2026 64,725.406−$22.39

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
EMA bands + leledc + bollinger bands trend following strategy v2 this page—v5 strategy+7.8%3832.0%
Contrarian Scalping Counter Trend Bb Envelope Adx and Stochastic by exlux99sma stdev ema rmav5 strategy+1.9%153.2%
Forex Scalping 1min Bollinger Bands, RSI and ADX Trading System by exlux99rsi sma stdev rmav4 strategy−0.0%30.0%
Take Profit On Trend (by BHD_Trade_Bot) by BHD_Trade_Botema rsi stdev smav4 strategy+54.8%913.1%
DRSI DMA Scalping Strategy No Repaint by allenlksma wma ema rsiv4 strategy−99.5%44137.7%
Best TradingView Strategy - For NASDAQ and DOW30 and other Index by The_Bigger_Bullsma stdev rma emav5 strategy+2.2%173.4%

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

Verified

Nothing 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: 38 before, 38 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.

⋯// backtesting results when considering for slippage and fees,  readability adjustments-//@version=5+//@version=6strategy(title='EMA bands + leledc + bollinger bands trend catching strategy w/ countertrend scalp', ⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 256 msWith a workaround 1,000 bars in 213 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.short, direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 528, 537, 546, 555, 582, 591 and more) so the engine trades the way the script says.

“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/// © danielx888// Credits to Joy_Bangla for the Leledc exhaustion bar code// Credits to VishvaP for the 34 EMA bands code// Credits to SlumdogTrader for the BB exhaustion code (edited for functionality)// Credits to Juanc2316 for his code for BB Keltner Squeeze//// Update Notes : added strategy close conditions before every entry for more accurate// backtesting results when considering for slippage and fees,  readability adjustments//@version=5strategy(title='EMA bands + leledc + bollinger bands trend catching strategy w/ countertrend scalp',      shorttitle='Trend Pooristics', overlay=true, initial_capital = 1000, commission_value= 0.036,      pyramiding= 0, default_qty_type= strategy.percent_of_equity, default_qty_value= 100,      margin_long=0, margin_short=0, max_bars_back=200)//USER INPUTS {//INPUT: OPENi_EMAlength         = input.int   (34, 'EMA Length', minval=1, step=1)s_needLong          = input.bool  (true, title = "Enable middle EMA band breakout: Long", group="Open Conditions")s_needShort         = input.bool  (true, title = "Enable middle EMA band breakdown: Short", group="Open Conditions")s_longBounce        = input.bool  (false, 'Enable middle EMA band bounce re-entry: Long', tooltip='Works best when early close conditions are used', group= 'Open Conditions')s_shortBounce       = input.bool  (false, 'Enable middle EMA band bounce re-entry: Short', tooltip='Works best when early close conditions are used', group= 'Open Conditions')s_alwaysLong        = input.bool  (false, title = "Enable default positioning: Long", tooltip='Does not work with "Enable default positioning: Short" also selected. Works best when early close conditions are used', group = 'Open Conditions')s_alwaysShort       = input.bool  (false, title = "Enable default positioning: Short", tooltip='Does not work with "Enable default positioning: Long" also selected. Works best when early close conditions are used', group = 'Open Conditions')i_topMBmult         = input.float (1, 'Top middle band multiplier', 0.1,3,step=0.1,group='Open Conditions')i_botMBmult         = input.float (1, 'Bottom middle band multiplier',0.1,3,step=0.1,group='Open Conditions')s_useSlowEMA        = input.bool  (false, title='Use slow EMA filter',tooltip='Condition does not apply to counter-trend trades', group='Open Conditions')i_slowEMAlen        = input.int   (200, title='Slow EMA Length', step=1, minval=1, group='Open Conditions')//INPUT: CLOSEi_midClose          = input.string('Opposite band', 'Close on crosses through middle EMA bands', tooltip='Selecting "Delayed bars inside" will closing positions after specified amount of candles close in between the middle EMA bands without breaking out', options=['Nearest band', 'Opposite band', 'Delayed bars inside'], group='Close Conditions')i_numBars           = input.int   (4, 'Delayed close no. of bars', minval=1, maxval=10, step=1, group='Close Conditions')s_useLele           = input.bool  (false, 'Close on Leledc bars', group='Close Conditions')i_whichLele         = input.string('First', 'Which Leledc bar?', options=['First', 'Second', 'Third', 'Fourth', 'Fifth'], group='Close Conditions')s_useBBExtend       = input.bool  (false, 'Close on Bollinger Band exhaustion bars', tooltip='Bollinger Band Exhaustion bars are candles that close back inside the Bollinger Bands when RSI is overbought or oversold. Settings for both can be changed under the -Bollinger Bands Exhaustion Bar Settings- header.', group='Close Conditions')i_whichBBext        = input.string('First', 'Which BB exhaustion bar?', options=['First', 'Second', 'Third'], group='Close Conditions')s_buySellClose      = input.bool  (false, 'Close on loss of Buy/Sell zone', group='Close Conditions')s_whichBuySellBars  = input.string('Inner', 'Which Buy/Sell zone?', options=['Inner', 'Outer'], group='Close Conditions')//INPUT: COUNTER-TREND TRADESs_needCTlong        = input.bool  (false, "Enable counter-trend trades: Long", tooltip='Does not work with "Enable default positioning: Short" selected',  group="Counter Trade Settings")i_CTlongType        = input.string('Leledc', title = 'Trigger', options=['Leledc', 'BB Exhaustion'], group='Counter Trade Settings')s_needCTshort       = input.bool  (false, "Enable counter-trend trades: Short", tooltip='Does not work with "Enable default positioning: Long" selected"', group="Counter Trade Settings")i_CTshortType       = input.string('Leledc', 'Trigger', options=['Leledc', 'BB Exhaustion'], group='Counter Trade Settings')i_ctLeleBuySell     = input.string('Inner', 'Leledc/BB must be outside which Buy/Sell zone to open', options=['Inner', 'Outer'], group="Counter Trade Settings")i_CTlongCloseCond   = input.string('Cross Top Middle Band','Closing conditions for counter-trend longs', tooltip='-Cross- type close conditions market close position on candle closes above selected region \n\n-Touch- type enable trailing limit orders that follow the selected region', options=['Cross Outer Buy Zone', 'Cross Inner Buy Zone', 'Touch Inner Buy Zone', 'Cross Bottom Middle Band', 'Touch Bottom Middle Band', 'Cross Top Middle Band', 'Touch Top Middle Band', 'Cross Inner Sell Zone', 'Touch Inner Sell Zone', 'Cross Outer Sell Zone', 'Touch Outer Sell Zone', 'First Leledc', 'First BB Exhaustion'], group='Counter Trade Settings')i_CTshortCloseCond  = input.string('First Leledc','Closing conditions for counter-trend shorts', tooltip='-Cross- type close conditions market close position on candle closes below selected region \n\n-Touch- type enable trailing limit orders that follow the selected region',options=['Cross Outer Sell Zone', 'Cross Inner Sell Zone', 'Touch Inner Sell Zone', 'Cross Top Middle Band', 'Touch Top Middle Band', 'Cross Bottom Middle Band', 'Touch Bottom Middle Band', 'Cross Inner Buy Zone', 'Touch Inner Buy Zone', 'Cross Outer Buy Zone', 'Touch Outer Buy Zone', 'First Leledc', 'First BB Exhaustion'], group='Counter Trade Settings')i_CTlongSL          = input.float (10, 'Flat stop-loss % for counter-trend longs', 0, 100, 0.1, 'Input 0 to disable stop-loss for counter-trend trades. Enabling stop-loss will not apply to middle band breakout, bounce, or default positional trades',group='Counter Trade Settings')i_CTshortSL         = input.float (10, 'Flat stop-loss % for counter-trend shorts', 0, 100, 0.1, 'Input 0 to disable stop-loss for counter-trend trades. Enabling stop-loss will not apply to middle band breakout, bounce, or default positional trades',group='Counter Trade Settings')//INPUT: KELTNER BUY/SELL ZONESs_keltnerBuySell    = input.bool  (false, 'Use Keltner channel multiples for "Buy/Sell Zones"',tooltip='Enables inputting custom multiples and a different/smoother calculation of "Buy/Sell Zones". Default calculation is a multiple of EMA band highs and lows', group='Keltner Buy/Sell Zones')i_mult              = input.float (5.0, "Outer Multiplier", tooltip='Only for "Buy/Sell Zones" calculated by Keltner channels', group='Keltner Buy/Sell Zones')i_innerMult         = input.float (3.0, "Inner Multiplier", tooltip='Only for "Buy/Sell Zones" calculated by Keltner channels', group='Keltner Buy/Sell Zones')//INPUT: VOLATILITY SQUEEZE FILTERs_squeezeFilter     = input.bool  (false, 'Filter out trades during BB-Keltner squeezes', group= 'BB-Keltner squeze')i_bbCondition       = input.string('At Least One', title='Bollinger Band Crossover Condition', options=['Both', 'At Least One'], group= 'BB-Keltner squeze')i_bbSqueezeLength   = input.int   (30, minval=1, title='BB Length', group= 'BB-Keltner squeze')i_ktSqueezeLength   = input.int   (18, minval=1, title='Keltner Length', group= 'BB-Keltner squeze')s_useRes            = input.bool  (false, 'Use current timeframe', group= 'BB-Keltner squeze')res = (s_useRes ? '' :input.timeframe('360', 'Resolution for BB-Keltner squeeze', group= 'BB-Keltner squeze'))i_B2mult            = input.float (2, minval=0.001, maxval=50, title='BB Standard Deviation', group= 'BB-Keltner squeze')i_Kmult             = input.float (1.5, title='Keltner Range', group= 'BB-Keltner squeze')//INPUT: BOLLINGER BANDS EXHAUSTION BARSi_BBlength          = input.int   (20, minval=1, title='Bollinger Bands SMA Period Length', group='Bollinger Bands Exhaustion Bar Settings')i_BBmult            = input.float (1.8, minval=0.001, maxval=50, title='Bollinger Bands Standard Deviation', group='Bollinger Bands Exhaustion Bar Settings')i_RSIlength         = input.int   (8, minval=1, step=1, title='RSI Period Length', group='Bollinger Bands Exhaustion Bar Settings')i_RSIos             = input.int   (30, minval=0, maxval=50, step=1,title='RSI Oversold Value', group='Bollinger Bands Exhaustion Bar Settings')i_RSIob             = input.int   (70, minval=50, maxval=100, step=1, title='RSI Overbought value', group='Bollinger Bands Exhaustion Bar Settings')i_srcBB             = input.source(close, title='Source', group='Bollinger Bands Exhaustion Bar Settings')//INPUT: LELEDCi_leleVol           = input.bool  (false, 'Require Volume breakout for Leledc bars', group='Leledc Exhaustion Bar Settings')i_volMult           = input.float (1.5,'Volume Multiplier', 0.1,20,0.1, group='Leledc Exhaustion Bar Settings')i_majLen            = input.int   (30, 'Highest / Lowest', group='Leledc Exhaustion Bar Settings')i_majQual           = input.int   (6, 'Bar count no', group='Leledc Exhaustion Bar Settings')i_closeVal          = input.int   (4, 'Close', group='Leledc Exhaustion Bar Settings')i_bindexSindex      = input.int   (1, 'bindexSindex', group='Leledc Exhaustion Bar Settings')//INPUT: VISUAL ELEMENTSs_trendColor        = input.bool  (false, 'Enable Trend Bar Color', tooltip='Color bars green when above mid bands, red when below, and gray when inside. Dark green and dark red bars signal a position is kept open from the delayed close settings.', group='Visual Elements')s_showBuySell       = input.bool  (true, 'Show "Buy/Sell Zones"', group='Visual Elements')s_showEMA           = input.bool  (false, 'Show EMA', group='Visual Elements')s_showMiddleBands   = input.bool  (true, 'Show middle EMA bands', group='Visual Elements')s_showSlowEMA       = input.bool  (false, 'Show Slow EMA', group='Visual Elements')s_showMaj           = input.bool  (true, 'Show Leledc Exhausion Bars', group='Visual Elements')s_switch1           = input.bool  (true, 'Enable Bollinger Bands exhaustion bar coloring', group='Visual Elements')s_switch2           = input.bool  (false, 'Enable Bollinger bands exhaustion bar background coloring', tooltip='Enabling this can help visualize when dialing in Bollinger Bands and RSI settings', group='Visual Elements')s_colorBuySellBars  = input.bool  (false, 'Enable Buy/Sell zone failure bar coloring', group='Visual Elements')s_squeezeBG         = input.bool  (true, 'Enable volatility squeeze (BB-Keltner) background coloring', group='Visual Elements')//}//VARIABLES: EMA and slowEMA CALC {EMA = ta.ema(close, i_EMAlength)slowEMA = ta.ema(close, i_slowEMAlen)plot(s_showSlowEMA ? slowEMA : na)//}//*****************************// SlumdogTrader's Bollinger Bands + RSI Double Strategy - Profit Trailer//====================================================================================================//{//BB VARIABLESBBbasis = ta.sma(i_srcBB, i_BBlength)BBdev   = i_BBmult * ta.stdev(i_srcBB, i_BBlength)BBupper = BBbasis + BBdevBBlower = BBbasis - BBdev//RSI VARIABLESvrsi            = ta.rsi(i_srcBB, i_RSIlength)RSIoverSold     = vrsi < i_RSIosRSIoverBought   = vrsi > i_RSIob//BB EXHAUSTION BAR COLOR VARIABLEOSOBcolor =      RSIoverBought and i_srcBB[1] > BBupper and i_srcBB < BBupper ? color.yellow :      RSIoverSold and i_srcBB[1] < BBlower and i_srcBB > BBlower ? color.blue :      na//====================================================================================================////}//KELTNER SELL ZONE {rangema = s_keltnerBuySell ? ta.rma(high - low, i_EMAlength) : 0.0kt_outersell(_ma) =>    upper = EMA + _ma * i_mult    upperkt_innersell(_ma) =>    inner_upper = EMA + _ma * i_innerMult    inner_upperkt_outerbuy(_ma) =>    lower = EMA - _ma * i_mult    lowerkt_innerbuy(_ma) =>    inner_lower = EMA - _ma * i_innerMult    inner_lower//}//*****************************// BB-Keltner Squeeze-FVBO-2.0// Modified by Juan C for FVBO Strategy, some source code from Trader-Elisa//====================================================================================================//{//VARIABLES FOR HTF SOURCESrp_security(_sym, _res, _src) =>     request.security(_sym, _res, _src[barstate.ishistory ? 0 : 1], gaps=barmerge.gaps_on)    srcClose    = rp_security(syminfo.tickerid, res, close)srcHigh     = rp_security(syminfo.tickerid, res, high)srcLow      = rp_security(syminfo.tickerid, res, low)//SQUEEZE BOLLINGER BANDSB2basis     = ta.sma(srcClose, i_bbSqueezeLength)B2dev       = i_B2mult * ta.stdev(srcClose, i_bbSqueezeLength)B2upper     = B2basis + B2devB2lower     = B2basis - B2dev//SQUEEZE KELTNER CHANNELSKma         = ta.ema(srcClose, i_ktSqueezeLength)Krange      = srcHigh - srcLowKrangema    = ta.ema(Krange, i_ktSqueezeLength)Kupper      = Kma + Krangema * i_KmultKlower      = Kma - Krangema * i_Kmult//DEFINE SQUEEZEvar bool squeezing = falseif s_squeezeFilter    if i_bbCondition == 'Both' and s_useRes        squeezing := B2upper <= Kupper and B2lower >= Klower ? true : false        squeezing    else if i_bbCondition == 'At Least One' and s_useRes        squeezing := B2upper <= Kupper or B2lower >= Klower ? true : false        squeezing    else if i_bbCondition == 'Both'        squeezing :=          B2upper[ta.barssince(not srcClose == barstate.isrealtime)] <= Kupper[ta.barssince(not srcClose == barstate.isrealtime)] and          B2lower[ta.barssince(not srcClose == barstate.isrealtime)] >= Klower[ta.barssince(not srcClose == barstate.isrealtime)] ? true : false        squeezing    else         squeezing :=          B2upper[ta.barssince(not srcClose == barstate.isrealtime)] <= Kupper[ta.barssince(not srcClose == barstate.isrealtime)] or          B2lower[ta.barssince(not srcClose == barstate.isrealtime)] >= Klower[ta.barssince(not srcClose == barstate.isrealtime)] ? true : false        squeezing//VISUALcross_over_color = (squeezing ? color.new(color.aqua, 90) : na)bgcolor(s_squeezeBG ? cross_over_color : na)bgcolor(s_switch2 ? color.new(OSOBcolor,70) : na)//}//*****************************// © Joy_Bangla Leledc Exhaustion V4//====================================================================================================//{//min = input(false, 'Minor Leledc Exhaustion Bar ::  Show')//min_qual = input(5, 'Minor Leledc Exhausion Bar ::  Bar count no')//min_len = input(5, 'Minor Leledc Exhausion Bar ::  Bar count no')leleVol = volume > ta.sma(volume,100)*i_volMultlele(qual, len) =>    bindex = 0    sindex = 0    bindex := nz(bindex[i_bindexSindex], 0)    sindex := nz(sindex[i_bindexSindex], 0)    ret = 0    if close > close[i_closeVal]        bindex += 1        bindex    if close < close[i_closeVal]        sindex += 1        sindex        if i_leleVol and not leleVol        ret := 0        ret    else        if bindex > qual and close < open and high >= ta.highest(high, len)            bindex := 0            ret := -1            ret        if sindex > qual and close > open and low <= ta.lowest(low, len)            sindex := 0            ret := 1            ret    return_1 = ret    return_1major = lele(i_majQual, i_majLen)//minor = lele(min_qual, min_len)plotchar(s_showMaj ? major == -1 ? high : na : na, char='•', location=location.absolute, color=color.new(color.red, 0), size=size.small)plotchar(s_showMaj ? major == 1 ? low : na : na, char='•', location=location.absolute, color=color.new(color.lime, 0), size=size.small)//plotchar(min ? minor == 1 ? high : na : na, char='x', location=location.absolute, color=color.new(color.red, 0), size=size.small)//plotchar(min ? minor == -1 ? low : na : na, char='x', location=location.absolute, color=color.new(color.lime, 0), size=size.small)//leledcMajorBullish = major == 1 ? low : na//leledcMajorBearish = major == -1 ? high : na//leledcMinorBullish = minor == 1 ? low : na//leledcMinorBearish = minor == -1 ? high : na//==============================================////alertcondition(leledcMajorBullish, title='Major Bullish Leledc', message='Major Bullish Leledc')//alertcondition(leledcMajorBearish, title='Major Bearish Leledc', message='Major Bearish Leledc')//alertcondition(leledcMinorBullish, title='Minor Bullish Leledc', message='Minor Bullish Leledc')//alertcondition(leledcMinorBearish, title='Minor Bearish Leledc', message='Minor Bearish Leledc')//====================================================================================================////}//*****************************// © VishvaP 34 EMA Bands v2//====================================================================================================//{//BUILD EMA MIDDLE BANDShighShortEMA = ta.ema(high, i_EMAlength)lowShortEMA = ta.ema(low, i_EMAlength)middleBandTop = (highShortEMA - EMA) * i_topMBmult + EMAmiddleBandBot = (lowShortEMA - EMA) * i_botMBmult + EMA//==============================================////1D Bands [Not Used]//bandsHigh = highShortEMA * math.phi//bandsLow = lowShortEMA * math.rphi//==============================================////INNER BUY/SELL ZONESshortbandsHigh = s_keltnerBuySell ? kt_innersell(rangema) : ((highShortEMA - EMA) * math.phi * i_topMBmult) * math.pi + EMAshortbandsLow = s_keltnerBuySell ? kt_innerbuy(rangema) : (-(EMA - lowShortEMA) * math.phi * i_botMBmult) * math.pi + EMA//SMOOTH INNERshortbandsHighEMA = ta.wma(shortbandsHigh, 8)shortbandsLowEMA = ta.wma(shortbandsLow, 8)//==============================================////OUTER BUY/SELL ZONESphiExtensionHigh = s_keltnerBuySell ? kt_outersell(rangema) : ((highShortEMA - EMA) * math.phi * i_topMBmult) * (math.phi + 4) + EMAphiExtensionLow  = s_keltnerBuySell ? kt_outerbuy(rangema) : (-(EMA - lowShortEMA) * math.phi * i_botMBmult) * (math.phi + 4) + EMA//SMOOTH OUTERphiExtensionHighEMA = ta.wma(phiExtensionHigh, 8)phiExtensionLowEMA = ta.wma(phiExtensionLow, 8)//==============================================////PLOT MIDDLE BANDS AND EMAhighP1 = plot(s_showMiddleBands ? middleBandTop : na, color = color.new(color.blue, 100), title = "Top median zone")lowP1 = plot(s_showMiddleBands ? middleBandBot : na, color = color.new(color.blue, 100), title = "Bottom median zone")plot(s_showEMA ? EMA : na, color = color.new(color.gray, 0), title = "EMA")//1D bands [not used]//highP2 = plot(bandsHigh)//lowP2 = plot(bandsLow)//PLOT BUY/SELL ZONEShighP3 = plot(s_showBuySell ? shortbandsHighEMA : na, color = color.new(color.yellow, 100), title = "Lower sell zone")lowP3 = plot(s_showBuySell ? shortbandsLowEMA : na, color = color.new(color.teal, 100), title = "Higher buy zone")phiPlotHigh = plot(s_showBuySell ? phiExtensionHighEMA : na, color = color.new(color.red, 100), title = "Top sell zone")phiPlotLow = plot(s_showBuySell ? phiExtensionLowEMA : na, color = color.new(color.green, 100), title = "Bottom buy zone")//==============================================////BUY/SELL ZONE AND MIDDLE BAND COLOR FILLSfill(phiPlotHigh, highP3, color.new(color.red, 85), title = "Sell zone")fill(lowP3, phiPlotLow, color.new(color.green, 85), title = "Buy zone")fill(highP1, lowP1, color.new(color.gray, 70), title = "Median zone")//====================================================================================================////}//ASSIGN BANDS FOR COUNTERTREND ENTRIES {float CTbandTop = nafloat CTbandBottom = na if i_ctLeleBuySell == 'Inner'    CTbandTop := shortbandsHighEMA    CTbandBottom := shortbandsLowEMAelse     CTbandTop := phiExtensionHighEMA    CTbandBottom := phiExtensionLowEMA//}//BUILD VARIABLES FOR CROSSES {crossUpTopMB = open < middleBandTop and close > middleBandTopwiggleUpTopMB = open > middleBandTop and close > middleBandTop and close[1] <= middleBandTop[1]crossDownTopMB = open > middleBandTop and close < middleBandTopwiggleDownTopMB = open < middleBandTop and close < middleBandTop and close[1] >= middleBandTop[1]crossUpBotMB = open < middleBandBot and close > middleBandBotwiggleUpBotMB = open > middleBandBot and close > middleBandBot and close[1] <= middleBandBot[1]crossDownBotMB = open > middleBandBot and close < middleBandBotwiggleDownBotMB = open < middleBandBot and close < middleBandBot and close[1] >= middleBandBot[1]crossUpBotInnerRB = open < shortbandsLowEMA and close > shortbandsLowEMAwiggleUpBotInnerRB = open > shortbandsLowEMA and close > shortbandsLowEMA and close[1] <= shortbandsLowEMA[1]crossUpBotOuterRB = open < phiExtensionLowEMA and close > phiExtensionLowEMAwiggleUpBotOuterRB = open > phiExtensionLowEMA and close > phiExtensionLowEMA and close[1] <= phiExtensionLowEMA[1]crossUpTopInnerRB = open < shortbandsHighEMA and close > shortbandsHighEMAwiggleUpTopInnerRB = open > shortbandsHighEMA and close > shortbandsHighEMA and close[1] <= shortbandsHighEMA[1]crossUpTopOuterRB = open < phiExtensionHighEMA and close > phiExtensionHighEMAwiggleUpTopOuterRB = open > phiExtensionHighEMA and close > phiExtensionHighEMA and close[1] <= phiExtensionHighEMA[1]crossDownBotInnerRB = open > shortbandsLowEMA and close < shortbandsLowEMAwiggleDownBotInnerRB = open < shortbandsLowEMA and close < shortbandsLowEMA and close[1] >= shortbandsLowEMA[1]crossDownBotOuterRB = open > phiExtensionLowEMA and close < phiExtensionLowEMAwiggleDownBotOuterRB = open < phiExtensionLowEMA and close < phiExtensionLowEMA and close[1] >= phiExtensionLowEMA[1]crossDownTopInnerRB = open > shortbandsHighEMA and close < shortbandsHighEMAwiggleDownTopInnerRB = open < shortbandsHighEMA and close < shortbandsHighEMA and close[1] >= shortbandsHighEMA[1]crossDownTopOuterRB = open > phiExtensionHighEMA and close < phiExtensionHighEMAwiggleDownTopOuterRB = open < phiExtensionHighEMA and close < phiExtensionHighEMA and close[1] >= phiExtensionHighEMA[1]//}//VARIABLES FOR BOUNCES {longBounce  =      not s_longBounce ? false :      s_squeezeFilter ? open > middleBandTop and close > middleBandTop and low < middleBandTop and squeezing == false :      open > middleBandTop and close > middleBandTop and low < middleBandTopshortBounce =      not s_shortBounce ? false :      s_squeezeFilter ? open < middleBandBot and close < middleBandBot and high > middleBandBot and squeezing == false :      open < middleBandBot and close < middleBandBot and high > middleBandBot//}//BUILD VARIABLES FOR CLOSING CONDITIONS {CTlongCloseCond =     i_CTlongCloseCond == 'Cross Inner Sell Zone' ? (crossUpTopInnerRB or wiggleUpTopInnerRB) :      i_CTlongCloseCond == 'Cross Outer Sell Zone' ? (crossUpTopOuterRB or wiggleUpTopOuterRB) :      i_CTlongCloseCond == 'Cross Top Middle Band' ? (crossUpTopMB or wiggleUpTopMB)           :      i_CTlongCloseCond == 'Cross Bottom Middle Band' ? (crossUpBotMB or wiggleUpBotMB)        :      i_CTlongCloseCond == 'Cross Inner Buy Zone' ? (crossUpBotInnerRB or wiggleUpBotInnerRB)  :      i_CTlongCloseCond == 'Cross Outer Buy Zone' ? (crossUpBotOuterRB or crossUpBotOuterRB)   :      i_CTlongCloseCond == 'First Leledc' ? major == -1                                        :      i_CTlongCloseCond == 'First BB Exhaustion' ? OSOBcolor == color.yellow                   :      naCTlongTP =      i_CTlongCloseCond == 'Touch Inner Buy Zone' ? shortbandsLowEMA     :      i_CTlongCloseCond == 'Touch Top Middle Band' ? middleBandTop       :      i_CTlongCloseCond == 'Touch Bottom Middle Band' ? middleBandBot    :      i_CTlongCloseCond == 'Touch Inner Sell Zone' ? shortbandsHighEMA   :      i_CTlongCloseCond == 'Touch Outer Sell Zone' ? phiExtensionHighEMA :      naCTshortCloseCond =      i_CTshortCloseCond == 'Cross Inner Buy Zone' ? (crossDownBotInnerRB or wiggleDownBotInnerRB)  :      i_CTshortCloseCond == 'Cross Outer Buy Zone' ? (crossDownBotOuterRB or wiggleDownBotOuterRB)  :      i_CTshortCloseCond == 'Cross Bottom Middle Band' ? (crossDownBotMB or wiggleDownBotMB)        :      i_CTshortCloseCond == 'Cross Top Middle Band' ? (crossDownTopMB or wiggleDownTopMB)           :      i_CTshortCloseCond == 'Cross Inner Sell Zone' ? (crossDownTopInnerRB or wiggleDownTopInnerRB) :      i_CTshortCloseCond == 'Cross Outer Sell Zone' ? (crossDownTopOuterRB or crossDownTopOuterRB)  :      i_CTshortCloseCond == 'First Leledc' ? major == 1                                             :      i_CTshortCloseCond == 'First BB Exhaustion' ? OSOBcolor == color.blue                         :      naCTshortTP =      i_CTshortCloseCond == 'Touch Inner Sell Zone' ? shortbandsHighEMA :      i_CTshortCloseCond == 'Touch Bottom Middle Band' ? middleBandBot  :      i_CTshortCloseCond == 'Touch Top Middle Band' ? middleBandTop     :      i_CTshortCloseCond == 'Touch Inner Buy Zone' ? shortbandsLowEMA   :      i_CTshortCloseCond == 'Touch Outer Buy Zone' ? phiExtensionLowEMA :     nashortMidBreak =      s_squeezeFilter ? (crossDownBotMB or wiggleDownBotMB) and squeezing == false :      crossDownBotMB or wiggleDownBotMBlongMidBreak =      s_squeezeFilter ? (crossUpTopMB or wiggleUpTopMB) and squeezing == false :      crossUpTopMB or wiggleUpTopMB//}//BASIC STRATEGY POSITIONS OPEN//LONGS OPEN {if s_needLong    if s_useSlowEMA        if longMidBreak and close > slowEMA and open < middleBandTop            strategy.close('Short', comment='Close Short')            strategy.close('Counter Trend Short', comment='Close CT Short')            strategy.close('Default Short', comment='Close Default Short')            strategy.entry('Long', strategy.long)    else if longMidBreak        strategy.close('Short', comment='Close Short')        strategy.close('Counter Trend Short', comment='Close CT Short')        strategy.close('Default Short', comment='Close Default Short')        strategy.entry('Long', strategy.long)if strategy.position_size == 0 and longBounce    if s_useSlowEMA        if close > slowEMA            strategy.close('Short', comment='Close Short')            strategy.close('Counter Trend Short', comment='Close CT Short')            strategy.close('Default Short', comment='Close Default Short')            strategy.entry('Long', strategy.long)    else         strategy.close('Short', comment='Close Short')        strategy.close('Counter Trend Short', comment='Close CT Short')        strategy.close('Default Short', comment='Close Default Short')        strategy.entry('Long', strategy.long)//}//SHORTS OPEN {if s_needShort    if s_useSlowEMA        if shortMidBreak and close < slowEMA and open > middleBandBot            strategy.close('Long', comment='Close Long')            strategy.close('Counter Trend Long', comment='Close CT Long')            strategy.close('Default Long', comment='Close Default Long')            strategy.entry('Short', strategy.short)    else if shortMidBreak        strategy.close('Long', comment='Close Long')        strategy.close('Counter Trend Long', comment='Close CT Long')        strategy.close('Default Long', comment='Close Default Long')                strategy.entry('Short', strategy.short)if strategy.position_size == 0 and shortBounce    if s_useSlowEMA        if close < slowEMA            strategy.close('Long', comment='Close Long')            strategy.close('Counter Trend Long', comment='Close CT Long')            strategy.close('Default Long', comment='Close Default Long')                        strategy.entry('Short', strategy.short)    else         strategy.close('Long', comment='Close Long')        strategy.close('Counter Trend Long', comment='Close CT Long')        strategy.close('Default Long', comment='Close Default Long')                strategy.entry('Short', strategy.short)//}//COUNT LELEDC BARS BETWEEN CURRENT BAR AND POSITION OPEN {//VARIABLESint countLongLele = 0int countShortLele = 0int numLele = switch i_whichLele    'First' => 1    'Second' => 2    'Third' => 3    'Fourth' => 4    'Fifth' => 5int i = 0//COUNT LELES FOR LONGSif strategy.position_size > 0    if s_useLele and numLele > 1        while i <= 200            if strategy.position_size[i] <= 0                break            if bar_index[i] == 0                break            if major[i] == -1                countLongLele += 1             if countLongLele == numLele                break            i += 1//COUNT LELES FOR SHORTSif strategy.position_size < 0     if s_useLele and numLele > 1        while i <= 200            if strategy.position_size[i] >= 0                break            if bar_index[i] == 0                break            if major[i] == 1                countShortLele += 1            if countShortLele == numLele                break            i += 1//}//COUNT BB EXHAUSTION BARS BETWEEN CURRENT BAR AND POSITION OPEN {//VARIABLESint countLongBBs = 0int countShortBBs = 0int numBBs = switch i_whichBBext    'First' => 1    'Second' => 2    'Third' => 3int n = 0//COUNT BB BARS FOR LONGSif strategy.position_size > 0    if s_useBBExtend and numBBs > 1        while n <= 200            if strategy.position_size[n] <= 0                break            if bar_index[n] == 0                break            if OSOBcolor[n] == color.yellow                countLongBBs += 1             if countLongBBs == numBBs                break            n+= 1//COUNT BB BARS FOR SHORTSif strategy.position_size < 0    if s_useBBExtend and numBBs > 1        while n <= 200            if strategy.position_size[n] >= 0                break            if bar_index[n] == 0                break            if OSOBcolor[n] == color.blue                countShortBBs += 1             if countShortBBs == numBBs                break            n+= 1//}//VARIABLES: CONDITIONS OF LOSS OF BUY/SELL ZONES {var bool crossUpRB = falsevar bool wiggleUpRB = falsevar bool crossDownRB = falsevar bool wiggleDownRB = falseif s_whichBuySellBars == 'Inner'    crossUpRB    := crossUpBotInnerRB    wiggleUpRB   := wiggleUpBotInnerRB    crossDownRB  := crossDownTopInnerRB    wiggleDownRB := wiggleDownTopInnerRBelse     crossUpRB    := crossUpBotOuterRB    wiggleUpRB   := wiggleUpBotOuterRB    crossDownRB  := crossDownTopOuterRB    wiggleDownRB := wiggleDownTopOuterRB//}//VARIABLES: reverBarColor {reverBarColor = crossDownRB or (wiggleDownRB and not crossDownRB[1]) ? color.orange :      crossUpRB or (wiggleUpRB and not crossUpRB[1]) ? color.purple :      na//}//FUNCTION: isAllMid() {//return true after specified number of bars (i_numBars) closes inside the mid bands but no breakoutinMid = close > middleBandBot and close < middleBandTop and open > middleBandBot and open < middleBandTopisAllMid() =>    AllMid = true    for t = 0 to i_numBars by 1        if longMidBreak[t] or shortMidBreak[t]            AllMid := false    AllMid//}//BASIC STRATEGY POSITIONS CLOSE//LONGS CLOSE {if strategy.position_size > 0    if s_buySellClose        if reverBarColor == color.orange            strategy.close('Long', comment = 'Close Long')    if s_useBBExtend and numBBs == 1        if OSOBcolor == color.yellow            strategy.close('Long', comment = 'Close Long')            if s_needCTshort and i_CTshortType == 'BB Exhaustion'                if open > CTbandTop                    strategy.close('Long', comment='Close Long')                    strategy.close('Counter Trend Long', comment='Close CT Long')                    strategy.close('Default Long', comment='Close Default Long')                                        strategy.entry('Counter Trend Short', comment = 'CT Short', direction=strategy.short)    if s_useBBExtend and numBBs > 1        if countLongBBs == numBBs              strategy.close('Long', comment = 'Close Long')            if s_needCTshort and i_CTshortType == 'BB Exhaustion'                if open > CTbandTop                    strategy.close('Long', comment='Close Long')                    strategy.close('Counter Trend Long', comment='Close CT Long')                    strategy.close('Default Long', comment='Close Default Long')                                        strategy.entry('Counter Trend Short', comment = 'CT Short', direction=strategy.short)    if s_useLele and numLele == 1        if major == -1            strategy.close('Long', comment = 'Close Long')            if s_needCTshort and i_CTshortType == 'Leledc'                if high > CTbandTop                    strategy.close('Long', comment='Close Long')                    strategy.close('Counter Trend Long', comment='Close CT Long')                    strategy.close('Default Long', comment='Close Default Long')                                    strategy.entry('Counter Trend Short', comment = 'CT Short', direction=strategy.short)    if s_useLele and numLele > 1        if countLongLele == numLele            strategy.close('Long', comment = 'Close Long')            if s_needCTshort and i_CTshortType == 'Leledc'                if high > CTbandTop                    strategy.close('Long', comment='Close Long')                    strategy.close('Counter Trend Long', comment='Close CT Long')                    strategy.close('Default Long', comment='Close Default Long')                                        strategy.entry('Counter Trend Short', comment = 'CT Short', direction=strategy.short)    if i_midClose == 'Nearest band'        if crossDownTopMB or wiggleDownTopMB            strategy.close('Long', comment = 'Close Long')    if i_midClose == 'Opposite band'        if crossDownBotMB or wiggleDownBotMB            strategy.close('Long', comment = 'Close Long')    if i_midClose == 'Delayed bars inside'        if crossDownBotMB or wiggleDownBotMB            strategy.close('Long', comment = 'Close Long')        if isAllMid()            if open[i_numBars] > middleBandTop and close[i_numBars] < middleBandTop and inMid                strategy.close('Long', comment = 'Close Long')//}//SHORTS CLOSE {if strategy.position_size < 0    if s_buySellClose        if reverBarColor == color.purple            strategy.close('Short', comment = 'Close Short')    if s_useBBExtend and numBBs == 1        if OSOBcolor == color.blue            strategy.close('Short', comment = 'Close Short')            if s_needCTlong and i_CTlongType == 'BB Exhaustion'                if open < CTbandBottom                    strategy.close('Short', comment='Close Short')                    strategy.close('Counter Trend Short', comment='Close CT Short')                    strategy.close('Default Short', comment='Close Default Short')                                        strategy.entry('Counter Trend Long', comment = 'CT Long', direction=strategy.long)    if s_useBBExtend and numBBs > 1        if countShortBBs == numBBs            strategy.close('Short', comment = 'Close Short')            if s_needCTlong and i_CTlongType == 'BB Exhaustion'                if open < CTbandBottom                    strategy.close('Short', comment='Close Short')                    strategy.close('Counter Trend Short', comment='Close CT Short')                    strategy.close('Default Short', comment='Close Default Short')                                        strategy.entry(id='Counter Trend Long', comment = 'CT Long', direction=strategy.long)    if s_useLele and numLele == 1        if major == 1            strategy.close('Short', comment = 'Close Short')            if s_needCTlong and i_CTlongType == 'Leledc'                if low < CTbandBottom                    strategy.close('Short', comment='Close Short')                    strategy.close('Counter Trend Short', comment='Close CT Short')                    strategy.close('Default Short', comment='Close Default Short')                                        strategy.entry(id='Counter Trend Long', comment= 'CT Long', direction=strategy.long)    if s_useLele and numLele > 1        if countShortLele == numLele            strategy.close('Short', comment = 'Close Short')            if s_needCTlong and i_CTlongType == 'Leledc'                if low < CTbandBottom                    strategy.close('Short', comment='Close Short')                    strategy.close('Counter Trend Short', comment='Close CT Short')                    strategy.close('Default Short', comment='Close Default Short')                                        strategy.entry(id='Counter Trend Long', comment= 'CT Long', direction=strategy.long)    if i_midClose == 'Nearest band'        if crossUpBotMB or wiggleUpBotMB            strategy.close('Short', comment = 'Close Short')    if i_midClose == 'Opposite band'        if crossUpTopMB or wiggleUpTopMB            strategy.close('Short', comment = 'Close Short')    if i_midClose == 'Delayed bars inside'        if crossUpTopMB or wiggleUpTopMB            strategy.close('Short', comment = 'Close Short')        if isAllMid()             if open[i_numBars] < middleBandBot and close[i_numBars] > middleBandBot and inMid                strategy.close('Short', comment = 'Close Short')//}//COUNTER TREND STRATEGY POSITIONS OPEN AND CLOSE {//VARIABLES FOR CT STOP LOSSESCTlongSL = strategy.position_avg_price * (1 - i_CTlongSL / 100)CTshortSL = strategy.position_avg_price * (1 + i_CTshortSL / 100)//CT LONGS OPENif s_needCTlong and strategy.position_size == 0 and (not s_squeezeFilter or not squeezing)    if i_CTlongType == 'Leledc'        if major == 1            if low < CTbandBottom                strategy.close('Short', comment='Close Short')                strategy.close('Counter Trend Short', comment='Close CT Short')                strategy.close('Default Short', comment='Close Default Short')                strategy.entry('Counter Trend Long', comment = 'CT Long', direction = strategy.long)    else        if OSOBcolor == color.blue            strategy.close('Short', comment='Close Short')            strategy.close('Counter Trend Short', comment='Close CT Short')            strategy.close('Default Short', comment='Close Default Short')            strategy.entry('Counter Trend Long', comment = 'CT Long', direction = strategy.long)//CT LONGS CLOSEDif strategy.position_size > 0 and strategy.opentrades.entry_id(strategy.opentrades - 1) == 'Counter Trend Long'    if i_CTlongSL > 0        if na(CTlongTP)            strategy.exit(id='Counter Trend Long', stop=CTlongSL, comment = 'CT Long SL')        else            strategy.exit(id='Counter Trend Long', stop=CTlongSL, limit=CTlongTP, comment = 'CT Long TP/SL')    else if i_CTlongSL == 0        strategy.exit(id='Counter Trend Long', limit=CTlongTP, comment = 'CT Long TP')    if CTlongCloseCond        strategy.close(id='Counter Trend Long', comment = 'Close CT Long')//CT SHORTS OPENif s_needCTshort and strategy.position_size == 0  and (not s_squeezeFilter or not squeezing)    if i_CTshortType == 'Leledc'        if major == -1            if high > CTbandTop                strategy.close('Long', comment='Close Long')                strategy.close('Counter Trend Long', comment='Close CT Long')                strategy.close('Default Long', comment='Close Default Long')                                         strategy.entry('Counter Trend Short', comment = 'CT Short', direction=strategy.short)    else        if OSOBcolor == color.yellow            strategy.close('Long', comment='Close Long')            strategy.close('Counter Trend Long', comment='Close CT Long')            strategy.close('Default Long', comment='Close Default Long')                                 strategy.entry('Counter Trend Short', comment= 'CT Short', direction=strategy.short)//CT SHORTS CLOSEif strategy.position_size < 0 and strategy.opentrades.entry_id(strategy.opentrades - 1) == 'Counter Trend Short'    if i_CTshortSL > 0        if na(CTshortTP)            strategy.exit(id='Counter Trend Short', stop=CTshortSL, comment = 'CT Short SL')        else            strategy.exit(id='Counter Trend Short', stop=CTshortSL, limit=CTshortTP, comment = 'CT Short TP/SL')    else if i_CTshortSL == 0        strategy.exit(id='Counter Trend Short', limit=CTshortTP, comment = 'CT Short TP')    if CTshortCloseCond        strategy.close(id='Counter Trend Short', comment = "Close CT Short")//}//DEFAULT POSITIONING STRATEGY OPENS {if s_alwaysLong and not s_alwaysShort and strategy.position_size == 0     if s_useSlowEMA        if close > slowEMA            strategy.entry(id='Default Long', comment = 'Default Long', direction=strategy.long)    else        strategy.entry(id='Default Long', comment='Default Long', direction=strategy.long)if s_alwaysShort and not s_alwaysLong and strategy.position_size == 0     if s_useSlowEMA        if close < slowEMA            strategy.entry(id='Default Short', comment = 'Default Short', direction=strategy.short)    else        strategy.entry(id='Default Short', comment='Default Short', direction=strategy.short)//}//SET BAR COLORS {var colorBar = color.new(color.white, 50)if s_trendColor    if s_switch1        if s_colorBuySellBars            if reverBarColor == color.purple or reverBarColor == color.orange                colorBar := reverBarColor            else if OSOBcolor == color.yellow or OSOBcolor == color.blue                colorBar := OSOBcolor            else if close > middleBandTop                if (s_alwaysShort or s_needCTshort) and strategy.position_size < 0                    colorBar := color.new(color.red, 0)                else                    colorBar := color.new(color.green, 0)            else if close < middleBandBot                if (s_alwaysLong or s_needCTlong) and strategy.position_size > 0                    colorBar := color.new(color.green, 0)                else                    colorBar := color.new(color.red, 0)            else if strategy.position_size > 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')                colorBar := color.new(#0a6136, 20)            else if strategy.position_size < 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')                colorBar := color.new(#600008, 20)            else                colorBar := color.new(color.gray, 0)        else            if OSOBcolor == color.yellow or OSOBcolor == color.blue                colorBar := OSOBcolor            else if close > middleBandTop                if (s_alwaysShort or s_needCTshort) and strategy.position_size < 0                    colorBar := color.new(color.red, 0)                    else                        colorBar := color.new(color.green, 0)            else if close < middleBandBot                if (s_alwaysLong or s_needCTlong) and strategy.position_size > 0                    colorBar := color.new(color.green, 0)                else                    colorBar := color.new(color.red, 0)            else if strategy.position_size > 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')                colorBar := color.new(#0a6136, 20)            else if strategy.position_size < 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')                colorBar := color.new(#600008, 20)            else                colorBar := color.new(color.gray, 0)    else if s_colorBuySellBars        if reverBarColor == color.purple or reverBarColor == color.orange            colorBar := reverBarColor        else if close > middleBandTop            if (s_alwaysShort or s_needCTshort) and strategy.position_size < 0                colorBar := color.new(color.red, 0)            else                colorBar := color.new(color.green, 0)        else if close < middleBandBot            if (s_alwaysLong or s_needCTlong) and strategy.position_size > 0                colorBar := color.new(color.green, 0)            else                    colorBar := color.new(color.red, 0)        else if strategy.position_size > 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')            colorBar := color.new(#0a6136, 20)        else if strategy.position_size < 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')            colorBar := color.new(#600008, 20)        else            colorBar := color.new(color.gray, 0)    else        if close > middleBandTop            if (s_alwaysShort or s_needCTshort) and strategy.position_size < 0                colorBar := color.new(color.red, 0)            else                    colorBar := color.new(color.green, 0)        else if close < middleBandBot            if (s_alwaysLong or s_needCTlong) and strategy.position_size > 0                colorBar := color.new(color.green, 0)            else                    colorBar := color.new(color.red, 0)        else if strategy.position_size > 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')            colorBar := color.new(#0a6136, 20)        else if strategy.position_size < 0 and (i_midClose == 'Delayed bars inside' or i_midClose == 'Opposite band')            colorBar := color.new(#600008, 20)        else            colorBar := color.new(color.gray, 0)else if s_switch1     if s_colorBuySellBars        if reverBarColor == color.purple or reverBarColor == color.orange            colorBar := reverBarColor        else if OSOBcolor == color.yellow or OSOBcolor == color.blue            colorBar := OSOBcolor        else             colorBar := na    else        if OSOBcolor == color.yellow or OSOBcolor == color.blue            colorBar := OSOBcolor        else             colorBar := naelse if s_colorBuySellBars    if reverBarColor == color.purple or reverBarColor == color.orange        colorBar := reverBarColor    else        colorBar := naelse    colorBar := nabarcolor(colorBar)//}