Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

3RSI 3CCI BB 5orders DCA strategy+

A Pine Script v5 strategy built on RSI (close, 14), CCI (close, 20) and BB (close, 20). It has 16 order rules and no entry of its own. Exits use a stop loss and a profit target. Each trade commits 1 in cash and pays 0.075% commission. 64 settings; defaults include Source Bot close, Trade Direction Long Bot and 1 order (%) 13.03.

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 3RSI 3CCI BB 5orders DCA 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 3RSI 3CCI BB 5orders DCA 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 code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does 3RSI 3CCI BB 5orders DCA strategy+ run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does 3RSI 3CCI BB 5orders DCA strategy+ use a stop loss?
Yes
strategy.exit sets a stop on line 242, 246.
Does 3RSI 3CCI BB 5orders DCA strategy+ run in Zeal Terminal?
Yes
It compiles in 95 ms and runs 1,000 bars in 199 ms, in the browser.

BTCUSDT · 1D · default settings

  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$0$0Equity from $0
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 227, 228, 229, 230, 231, 233 and more) so the engine trades the way the script says. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 5, BINANCE:BTCUSDT 15, BINANCE:BTCUSDT 30, BINANCE:BTCUSDT 60, which this page cannot load in your browser.

Needs BINANCE:BTCUSDT 5 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 15 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 30 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 60 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, $0 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.

  • 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 227, 228, 229, 230, 231, 233, 234, 235, 236, 237, 240, 242, 244, 246. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
Start Timetimestamp('01 January 2021 00:00')timeline 74
End Timetimestamp('01 January 2022 00:00')timeline 74
Source BotclosesourcelongEntryPrice0 shortEntryPrice0
Trade DirectionLong Botstring · options ['Long Bot', 'Short Bot']longOK shortOK
Show signalsfalseboolBuy Sell
weight of orders in %
1 order (%)13.03floatlongEntryqty0 shortEntryqty0
2 order (%)14.29floatlongEntryqty1 shortEntryqty1
3 order (%)17.19floatlongEntryqty2 shortEntryqty2
4 order (%)22.67floatlongEntryqty3 shortEntryqty3
5 order (%)32.80floatlongEntryqty4 shortEntryqty4
Long Bot
Rate cover (%)80float · min 1longEntryPrice1 longEntryPrice2 longEntryPrice3 longEntryPrice4
Take Profit (%)1.4float · step 0.05longTP
StopLossfalseboolexit exit_Long exit exit_Long Long Stop Loss line 239 line 241
for Long Bot (%)80float · step 0.1longSL
Short Bot
Rate cover (%)500float · min 1shortEntryPrice1 shortEntryPrice2 shortEntryPrice3 shortEntryPrice4
Take Profit (%)1.4float · step 0.05shortTP
StopLossfalseboolexit exit_Short exit exit_Short Long Stop Loss line 243 line 245
for Short Bot (%)500float · step 0.1shortSL
indicators
Sourceclosesourcersi1_sec_long rsi1_sec_short rsi2_sec_long rsi2_sec_short rsi3_sec_long rsi3_sec_short cci1_sec_long cci1_sec_short cci2_sec_long cci2_sec_short cci3_sec_long cci3_sec_short basis upper_bb lower_bb cci_sec bb_long bb_short line 169 line 171
RSI-1
RSI-1trueboolline 97 line 99
resolution5timeframersi1_sec_long rsi1_sec_short
long <65int · min 0 · max 100rsi1_long
Length14int · min 1rsi1_sec_long
short >37int · min 0 · max 100rsi1_short
Length14int · min 1rsi1_sec_short
RSI-2
RSI-2trueboolline 109 line 111
resolution15timeframersi2_sec_long rsi2_sec_short
long <72int · min 0 · max 100rsi2_long
Length14int · min 1rsi2_sec_long
short >37int · min 0 · max 100rsi2_short
Length14int · min 1rsi2_sec_short
RSI-3
RSI-3trueboolline 121 line 123
resolution30timeframersi3_sec_long rsi3_sec_short
long <74int · min 0 · max 100rsi3_long
Length14int · min 1rsi3_sec_long
short >34int · min 0 · max 100rsi3_short
Length14int · min 1rsi3_sec_short
CCI-1
CCI-1trueboolline 133 line 135
resolution5timeframecci1_sec_long cci1_sec_short
long <190int · step 5cci1_long
Length20int · min 1cci1_sec_long
short >-175int · step 5cci1_short
Length20int · min 1cci1_sec_short
CCI-2
CCI-2trueboolline 145 line 147
resolution15timeframecci2_sec_long cci2_sec_short
long <195int · step 5cci2_long
Length20int · min 1cci2_sec_long
short >-205int · step 5cci2_short
Length20int · min 1cci2_sec_short
CCI-3
CCI-3trueboolline 157 line 159
resolution30timeframecci3_sec_long cci3_sec_short
long <200int · step 5cci3_long
Length20int · min 1cci3_sec_long
short >-220int · step 5cci3_short
Length20int · min 1cci3_sec_short
Bollinger Bands
BB(for long trading) the price is below the lower band, (for short trading) the price is abowe the upper band, для лонга цена под нижней линией, для шорта цена над верхней линиейfalseboolline 169 line 171
resolution5timeframebasis upper_bb lower_bb
Deviation2.0float · min 0.1 · max 50 · step 0.1basis upper_bb lower_bb
Length20int · min 1basis upper_bb lower_bb
band CCI
band CCIthis setting sets the trading range by the level of the "CCI" indicator, эта настройка задает диапазон торговли по уровню индикатора "CCI" (я не использую)falseboolline 180
resolution60timeframecci_sec
CCI Length20int · min 1cci_sec
CCI >-110int · step 10cci_band
CCI <110int · step 10cci_band

What it calculates

  • RSISource (close), Length (14)rsi1_sec_long · line 76
  • RSISource (close), Length (14)rsi1_sec_short · line 77
  • RSISource (close), Length (14)rsi2_sec_long · line 78
  • RSISource (close), Length (14)rsi2_sec_short · line 79
  • RSISource (close), Length (14)rsi3_sec_long · line 80
  • RSISource (close), Length (14)rsi3_sec_short · line 81
  • CCISource (close), Length (20)cci1_sec_long · line 82
  • CCISource (close), Length (20)cci1_sec_short · line 83
  • CCISource (close), Length (20)cci2_sec_long · line 84
  • CCISource (close), Length (20)cci2_sec_short · line 85
  • CCISource (close), Length (20)cci3_sec_long · line 86
  • CCISource (close), Length (20)cci3_sec_short · line 87
  • BBSource (close), Length (20), Deviation (2.0)basis · line 88
  • BBSource (close), Length (20), Deviation (2.0)upper_bb · line 88
  • BBSource (close), Length (20), Deviation (2.0)lower_bb · line 88
  • CCISource (close), CCI Length (20)cci_sec · line 89

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

Order rules

OrderFires whenBy defaultLine
order Long0 longBuy_okOn227
order Long1 longBuy_okOn228
order Long2 longBuy_okOn229
order Long3 longBuy_okOn230
order Long4 longBuy_okOn231
order Short0 shortSell_okOn233
order Short1 shortSell_okOn234
order Short2 shortSell_okOn235
order Short3 shortSell_okOn236
order Short4 shortSell_okOn237
Exit exit_Long limitstrategy.position_size[1] > 0On240
Exit exit_Long stop and limitstrategy.position_size[1] > 0On242
Exit exit_Short limitstrategy.position_size[1] < 0On244
Exit exit_Short stop and limitstrategy.position_size[1] < 0On246
Close ta.crossunder(strategy.opentrades, 0.5)On249
cancel_all ta.crossunder(strategy.opentrades, 0.5)On250

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

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data14 request.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 5, BINANCE:BTCUSDT 15, BINANCE:BTCUSDT 30, BINANCE:BTCUSDT 60, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; 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.

ScriptSharesTypeNetTradesMax drawdown
3RSI 3CCI BB 5orders DCA strategy+ this page—v5 strategy0.0%00.0%
Suchit RSI CCI by SuchitRajucci rsiv4 strategy+11.4%6854.7%
Bollinger Bands strategy with RSI and MACD v1.0 by juliangonzacondersi bbv4 strategyNo trades on this market
CCI-RSI MR by monikabhaycci rsi bbv4 strategyNo trades on this market
Momentum Explosion 2CCI RSI by capamcci rsiv4 strategy+24.1%642.3%
CCI Level Zone by Naruephatcci rsiv5 strategyNo trades on this market

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.

  • 14 strategy calls use the when = argument (line 227, 228, 229, 230, 231, 233, 234, 235, 236, 237, 240, 242, 244, 246). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

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

  • Line 227: when = Buy_ok → if block
  • Line 228: when = Buy_ok → if block
  • Line 229: when = Buy_ok → if block
  • Line 230: when = Buy_ok → if block
  • Line 231: when = Buy_ok → if block
  • Line 233: when = Sell_ok → if block
8 more edits
  • Line 234: when = Sell_ok → if block
  • Line 235: when = Sell_ok → if block
  • Line 236: when = Sell_ok → if block
  • Line 237: when = Sell_ok → if block
  • Line 240: when = strategy.position_size[1] > 0 → if block
  • Line 242: when = strategy.position_size[1] > 0 → if block
  • Line 244: when = strategy.position_size[1] < 0 → if block
  • Line 246: when = strategy.position_size[1] < 0 → if block
⋯if strategy.opentrades == 0 and longOK and within_window()-    strategy.order(id='Long0', direction=strategy.long, qty=longEntryqty0, limit=longEntryPrice0, when=Buy_ok)+    if Buy_ok+        strategy.order(id='Long0', direction=strategy.long, qty=longEntryqty0, limit=longEntryPrice0)-    strategy.order(id='Long1', direction=strategy.long, qty=longEntryqty1, limit=longEntryPrice1, when=Buy_ok)+    if Buy_ok+        strategy.order(id='Long1', direction=strategy.long, qty=longEntryqty1, limit=longEntryPrice1)-    strategy.order(id='Long2', direction=strategy.long, qty=longEntryqty2, limit=longEntryPrice2, when=Buy_ok)+    if Buy_ok+        strategy.order(id='Long2', direction=strategy.long, qty=longEntryqty2, limit=longEntryPrice2)-    strategy.order(id='Long3', direction=strategy.long, qty=longEntryqty3, limit=longEntryPrice3, when=Buy_ok)+    if Buy_ok+        strategy.order(id='Long3', direction=strategy.long, qty=longEntryqty3, limit=longEntryPrice3)-    strategy.order(id='Long4', direction=strategy.long, qty=longEntryqty4, limit=longEntryPrice4, when=Buy_ok)+    if Buy_ok+        strategy.order(id='Long4', direction=strategy.long, qty=longEntryqty4, limit=longEntryPrice4)if strategy.opentrades == 0 and shortOK and within_window()-    strategy.order(id='Short0', direction=strategy.short, qty=shortEntryqty0, limit=shortEntryPrice0, when=Sell_ok)+    if Sell_ok+        strategy.order(id='Short0', direction=strategy.short, qty=shortEntryqty0, limit=shortEntryPrice0)-    strategy.order(id='Short1', direction=strategy.short, qty=shortEntryqty1, limit=shortEntryPrice1, when=Sell_ok)+    if Sell_ok+        strategy.order(id='Short1', direction=strategy.short, qty=shortEntryqty1, limit=shortEntryPrice1)-    strategy.order(id='Short2', direction=strategy.short, qty=shortEntryqty2, limit=shortEntryPrice2, when=Sell_ok)+    if Sell_ok+        strategy.order(id='Short2', direction=strategy.short, qty=shortEntryqty2, limit=shortEntryPrice2)-    strategy.order(id='Short3', direction=strategy.short, qty=shortEntryqty3, limit=shortEntryPrice3, when=Sell_ok)+    if Sell_ok+        strategy.order(id='Short3', direction=strategy.short, qty=shortEntryqty3, limit=shortEntryPrice3)-    strategy.order(id='Short4', direction=strategy.short, qty=shortEntryqty4, limit=shortEntryPrice4, when=Sell_ok)+    if Sell_ok+        strategy.order(id='Short4', direction=strategy.short, qty=shortEntryqty4, limit=shortEntryPrice4)// exit positionif (strategy.position_size > 0) and not entry_long_SL and longOK-    strategy.exit(id='exit_Long', limit=longTP, qty=strategy.position_size, when=strategy.position_size[1] > 0)+    if strategy.position_size[1] > 0+        strategy.exit(id='exit_Long', limit=longTP, qty=strategy.position_size)if (strategy.position_size > 0) and entry_long_SL and longOK-    strategy.exit(id='exit_Long', limit=longTP, stop=longSL, qty=strategy.position_size, when=strategy.position_size[1] > 0)+    if strategy.position_size[1] > 0+        strategy.exit(id='exit_Long', limit=longTP, stop=longSL, qty=strategy.position_size)if (strategy.position_size < 0) and not entry_short_SL and shortOK-    strategy.exit(id='exit_Short', limit=shortTP, qty=math.abs(strategy.position_size), when=strategy.position_size[1] < 0)+    if strategy.position_size[1] < 0+        strategy.exit(id='exit_Short', limit=shortTP, qty=math.abs(strategy.position_size))if (strategy.position_size < 0) and entry_short_SL and shortOK-    strategy.exit(id='exit_Short', limit=shortTP, stop=shortSL, qty=math.abs(strategy.position_size), when=strategy.position_size[1] < 0)+    if strategy.position_size[1] < 0+        strategy.exit(id='exit_Short', limit=shortTP, stop=shortSL, qty=math.abs(strategy.position_size))// Cleanup⋯

Does it run in Pine Script v6?

Not tested

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

⋯// © rrolik66-//@version=5+//@version=6strategy(title="3RSI 3CCI BB 5orders DCA strategy+", overlay=true, default_qty_type=strategy.cash, initial_capital=0.1, commission_type=strategy.commission.percent, commission_value=0.075)⋯

Where it runs

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

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 227, 228, 229, 230, 231, 233 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/// © rrolik66//@version=5strategy(title="3RSI 3CCI BB 5orders DCA strategy+", overlay=true, default_qty_type=strategy.cash, initial_capital=0.1, commission_type=strategy.commission.percent, commission_value=0.075)start_time = input.time(defval=timestamp('01 January 2021 00:00'), title='Start Time')end_time = input.time(defval=timestamp('01 January 2022 00:00'), title='End Time')src_bot = input.source(close, 'Source Bot')tradeDirection = input.string(title='Trade Direction', options=['Long Bot', 'Short Bot'], defval='Long Bot')weight_order0 = input.float(13.03, title='1 order (%)', group='weight of orders in %', inline='Input 0') * 0.01weight_order1 = input.float(14.29, title='2 order (%)', group='weight of orders in %', inline='Input 0') * 0.01weight_order2 = input.float(17.19, title='3 order (%)', group='weight of orders in %', inline='Input 1') * 0.01weight_order3 = input.float(22.67, title='4 order (%)', group='weight of orders in %', inline='Input 1') * 0.01weight_order4 = input.float(32.80, title='5 order (%)', group='weight of orders in %', inline='Input 2') * 0.01st_long_orders = input.float(title='Rate cover (%)', minval=1, defval=80, group='Long Bot', inline='Input 1') / 4 * 0.01longTakeProfit = input.float(1.4, step=0.05, title='Take Profit (%)', group='Long Bot', inline='Input 1') * 0.01entry_long_SL = input.bool(defval=false, title='StopLoss', group='Long Bot', inline='Input 2')longStopLoss = input.float(80, step=0.1, title='for Long Bot (%)', group='Long Bot', inline='Input 2') * 0.01st_short_orders = input.float(title='Rate cover (%)', minval=1, defval=500, group='Short Bot', inline='Input 1') / 4 * 0.01shortTakeProfit = input.float(1.4, step=0.05, title='Take Profit (%)', group='Short Bot', inline='Input 1') * 0.01entry_short_SL = input.bool(defval=false, title='StopLoss', group='Short Bot', inline='Input 2')shortStopLoss = input.float(500, step=0.1, title='for Short Bot (%)', group='Short Bot', inline='Input 2') * 0.01//inputs for indicatorssrc = input.source(close, 'Source', group='indicators')rsi1_input = input.bool(defval=true, title='RSI-1', group='RSI-1', inline='Input 0')rsi1_res = input.timeframe(title='resolution', defval='5', group='RSI-1', inline='Input 0')rsi1_low = input.int(65, minval=0, maxval=100, title='long <', group='RSI-1', inline='Input 1')rsi1_len_long = input.int(14, minval=1, title='Length', group='RSI-1', inline='Input 1')rsi1_up = input.int(37, minval=0, maxval=100, title='short >', group='RSI-1', inline='Input 2')rsi1_len_short = input.int(14, minval=1, title='Length', group='RSI-1', inline='Input 2')rsi2_input = input.bool(defval=true, title='RSI-2', group='RSI-2', inline='Input 0')rsi2_res = input.timeframe(title='resolution', defval='15', group='RSI-2', inline='Input 0')rsi2_low = input.int(72, minval=0, maxval=100, title='long <', group='RSI-2', inline='Input 1')rsi2_len_long = input.int(14, minval=1, title='Length', group='RSI-2', inline='Input 1')rsi2_up = input.int(37, minval=0, maxval=100, title='short >', group='RSI-2', inline='Input 2')rsi2_len_short = input.int(14, minval=1, title='Length', group='RSI-2', inline='Input 2')rsi3_input = input.bool(defval=true, title='RSI-3', group='RSI-3', inline='Input 0')rsi3_res = input.timeframe(title='resolution', defval='30', group='RSI-3', inline='Input 0')rsi3_low = input.int(74, minval=0, maxval=100, title='long <', group='RSI-3', inline='Input 1')rsi3_len_long = input.int(14, minval=1, title='Length', group='RSI-3', inline='Input 1')rsi3_up = input.int(34, minval=0, maxval=100, title='short >', group='RSI-3', inline='Input 2')rsi3_len_short = input.int(14, minval=1, title='Length', group='RSI-3', inline='Input 2')cci1_input = input.bool(defval=true, title='CCI-1', group='CCI-1', inline='Input 0')cci1_res = input.timeframe(title='resolution', defval='5', group='CCI-1', inline='Input 0')cci1_low = input.int(190, step=5, title='long <', group='CCI-1', inline='Input 1')cci1_len_long = input.int(20, minval=1, title='Length', group='CCI-1', inline='Input 1')cci1_up = input.int(-175, step=5, title='short >', group='CCI-1', inline='Input 2')cci1_len_short = input.int(20, minval=1, title='Length', group='CCI-1', inline='Input 2')cci2_input = input.bool(defval=true, title='CCI-2', group='CCI-2', inline='Input 0')cci2_res = input.timeframe(title='resolution', defval='15', group='CCI-2', inline='Input 0')cci2_low = input.int(195, step=5, title='long <', group='CCI-2', inline='Input 1')cci2_len_long = input.int(20, minval=1, title='Length', group='CCI-2', inline='Input 1')cci2_up = input.int(-205, step=5, title='short >', group='CCI-2', inline='Input 2')cci2_len_short = input.int(20, minval=1, title='Length', group='CCI-2', inline='Input 2')cci3_input = input.bool(defval=true, title='CCI-3', group='CCI-3', inline='Input 0')cci3_res = input.timeframe(title='resolution', defval='30', group='CCI-3', inline='Input 0')cci3_low = input.int(200, step=5, title='long <', group='CCI-3', inline='Input 1')cci3_len_long = input.int(20, minval=1, title='Length', group='CCI-3', inline='Input 1')cci3_up = input.int(-220, step=5, title='short >', group='CCI-3', inline='Input 2')cci3_len_short = input.int(20, minval=1, title='Length', group='CCI-3', inline='Input 2')bb_input = input.bool(defval=false, title='BB', group='Bollinger Bands', tooltip='(for long trading) the price is below the lower band, (for short trading) the price is abowe the upper band, для лонга цена под нижней линией, для шорта цена над верхней линией', inline='Input 0')bb_res = input.timeframe(title='resolution', defval='5', group='Bollinger Bands', inline='Input 0')bb_dev = input.float(2.0, minval=0.1, maxval=50, step=0.1, title='Deviation', group='Bollinger Bands', inline='Input 2')bb_len = input.int(20, minval=1, title='Length', group='Bollinger Bands', inline='Input 2')cci_input = input.bool(defval=false, title='band CCI', group='band CCI', tooltip='this setting sets the trading range by the level of the "CCI" indicator, эта настройка задает диапазон торговли по уровню индикатора "CCI" (я не использую)', inline='Input 0')cci_res = input.timeframe(title='resolution', defval='60', group='band CCI', inline='Input 0')cci_len = input.int(20, minval=1, title='CCI Length', group='band CCI', inline='Input 1')cci_low = input.int(-110, step=10, title='CCI >', group='band CCI', inline='Input 2')cci_up = input.int(110, step=10, title='CCI <', group='band CCI', inline='Input 2')show_signals = input.bool(defval=false, title='Show signals', inline='Input')//Input to trading conditionslongOK = tradeDirection == 'Long Bot'shortOK = tradeDirection == 'Short Bot'within_window() =>    time >= start_time and time <= end_time// get indicatorsrsi1_sec_long = request.security(syminfo.tickerid, rsi1_res, ta.rsi(src, rsi1_len_long))rsi1_sec_short = request.security(syminfo.tickerid, rsi1_res, ta.rsi(src, rsi1_len_short))rsi2_sec_long = request.security(syminfo.tickerid, rsi2_res, ta.rsi(src, rsi2_len_long))rsi2_sec_short = request.security(syminfo.tickerid, rsi2_res, ta.rsi(src, rsi2_len_short))rsi3_sec_long = request.security(syminfo.tickerid, rsi3_res, ta.rsi(src, rsi3_len_long))rsi3_sec_short = request.security(syminfo.tickerid, rsi3_res, ta.rsi(src, rsi3_len_short))cci1_sec_long = request.security(syminfo.tickerid, cci1_res, ta.cci(src, cci1_len_long))cci1_sec_short = request.security(syminfo.tickerid, cci1_res, ta.cci(src, cci1_len_short))cci2_sec_long = request.security(syminfo.tickerid, cci2_res, ta.cci(src, cci2_len_long))cci2_sec_short = request.security(syminfo.tickerid, cci2_res, ta.cci(src, cci2_len_short))cci3_sec_long = request.security(syminfo.tickerid, cci3_res, ta.cci(src, cci3_len_long))cci3_sec_short = request.security(syminfo.tickerid, cci3_res, ta.cci(src, cci3_len_short))[basis, upper_bb, lower_bb] = request.security(syminfo.tickerid, bb_res, ta.bb(src, bb_len, bb_dev))cci_sec = request.security(syminfo.tickerid, cci_res, ta.cci(src, cci_len))// calculate indicatorsfloat rating_long = 0float rating_long_num = 0float rating_short = 0float rating_short_num = 0float rsi1_long = nafloat rsi1_short = naif not na(rsi1_sec_long) and rsi1_input and longOK    rsi1_long := rsi1_sec_long < rsi1_low ? 1 : 0if not na(rsi1_sec_short) and rsi1_input and shortOK    rsi1_short := rsi1_sec_short > rsi1_up ? 1 : 0if not na(rsi1_long)    rating_long += rsi1_long    rating_long_num += 1if not na(rsi1_short)    rating_short += rsi1_short    rating_short_num += 1float rsi2_long = nafloat rsi2_short = naif not na(rsi2_sec_long) and rsi2_input and longOK    rsi2_long := rsi2_sec_long < rsi2_low ? 1 : 0if not na(rsi2_sec_short) and rsi2_input and shortOK    rsi2_short := rsi2_sec_short > rsi2_up ? 1 : 0if not na(rsi2_long)    rating_long += rsi2_long    rating_long_num += 1if not na(rsi2_short)    rating_short += rsi2_short    rating_short_num += 1float rsi3_long = nafloat rsi3_short = naif not na(rsi3_sec_long) and rsi3_input and longOK    rsi3_long := rsi3_sec_long < rsi3_low ? 1 : 0if not na(rsi3_sec_short) and rsi3_input and shortOK    rsi3_short := rsi3_sec_short > rsi3_up ? 1 : 0if not na(rsi3_long)    rating_long += rsi3_long    rating_long_num += 1if not na(rsi3_short)    rating_short += rsi3_short    rating_short_num += 1float cci1_long = nafloat cci1_short = naif not na(cci1_sec_long) and cci1_input and longOK    cci1_long := cci1_sec_long < cci1_low ? 1 : 0if not na(cci1_sec_short) and cci1_input and shortOK    cci1_short := cci1_sec_short > cci1_up ? 1 : 0if not na(cci1_long)    rating_long += cci1_long    rating_long_num += 1if not na(cci1_short)    rating_short += cci1_short    rating_short_num += 1float cci2_long = nafloat cci2_short = naif not na(cci2_sec_long) and cci2_input and longOK    cci2_long := cci2_sec_long < cci2_low ? 1 : 0if not na(cci2_sec_short) and cci2_input and shortOK    cci2_short := cci2_sec_short > cci2_up ? 1 : 0if not na(cci2_long)    rating_long += cci2_long    rating_long_num += 1if not na(cci2_short)    rating_short += cci2_short    rating_short_num += 1float cci3_long = nafloat cci3_short = naif not na(cci3_sec_long) and cci3_input and longOK    cci3_long := cci3_sec_long < cci3_low ? 1 : 0if not na(cci3_sec_short) and cci3_input and shortOK    cci3_short := cci3_sec_short > cci3_up ? 1 : 0if not na(cci3_long)    rating_long += cci3_long    rating_long_num += 1if not na(cci3_short)    rating_short += cci3_short    rating_short_num += 1float bb_long = nafloat bb_short = naif not(na(lower_bb) or na(src) or na(src[1])) and bb_input and longOK    bb_long := src < lower_bb ? 1 : 0if not(na(upper_bb) or na(src) or na(src[1])) and bb_input and shortOK    bb_short := src > upper_bb ? 1 : 0if not na(bb_long)    rating_long += bb_long    rating_long_num += 1if not na(bb_short)    rating_short += bb_short    rating_short_num += 1float cci_band = naif not na(cci_sec) and cci_input    cci_band := cci_sec < cci_up and cci_sec > cci_low ? 1 : 0if not na(cci_band)    rating_long += cci_band    rating_long_num += 1    rating_short += cci_band    rating_short_num += 1//Buy SellBuy_ok = rating_long_num != 0 and longOK ? rating_long == rating_long_num : trueSell_ok = rating_short_num != 0 and shortOK ? rating_short == rating_short_num : true// Plottingplotshape(Buy_ok and show_signals and longOK, title='Buy', text='Long', textcolor=color.new(color.white, 0), style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), size=size.tiny)plotshape(Sell_ok and show_signals and shortOK, title='Sell', text='Short', textcolor=color.new(color.white, 0), style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), size=size.tiny)//Figure in entry orders pricelongEntryPrice0 = src_botlongEntryPrice1 = longEntryPrice0 * (1 - st_long_orders)longEntryPrice2 = longEntryPrice0 * (1 - st_long_orders * 2)longEntryPrice3 = longEntryPrice0 * (1 - st_long_orders * 3)longEntryPrice4 = longEntryPrice0 * (1 - st_long_orders * 4)longEntryqty0 = strategy.initial_capital * weight_order0 / longEntryPrice0longEntryqty1 = strategy.initial_capital * weight_order1 / longEntryPrice1longEntryqty2 = strategy.initial_capital * weight_order2 / longEntryPrice2longEntryqty3 = strategy.initial_capital * weight_order3 / longEntryPrice3longEntryqty4 = strategy.initial_capital * weight_order4 / longEntryPrice4shortEntryPrice0 = src_botshortEntryPrice1 = shortEntryPrice0 * (1 + st_short_orders)shortEntryPrice2 = shortEntryPrice0 * (1 + st_short_orders * 2)shortEntryPrice3 = shortEntryPrice0 * (1 + st_short_orders * 3)shortEntryPrice4 = shortEntryPrice0 * (1 + st_short_orders * 4)shortcontracts = strategy.initial_capital / shortEntryPrice0shortEntryqty0 = shortcontracts * weight_order0shortEntryqty1 = shortcontracts * weight_order1shortEntryqty2 = shortcontracts * weight_order2shortEntryqty3 = shortcontracts * weight_order3shortEntryqty4 = shortcontracts * weight_order4long_entry_price = strategy.opentrades.entry_price (0)short_entry_price = strategy.opentrades.entry_price (0)longTP = strategy.position_avg_price * (1 + longTakeProfit)longSL = long_entry_price * (1 - longStopLoss)shortTP = strategy.position_avg_price * (1 - shortTakeProfit)shortSL = short_entry_price * (1 + shortStopLoss)plot(series=strategy.position_size > 0 and longOK ? longTP : na, color=color.new(color.red, 0), style=plot.style_circles, linewidth=3, title='Long Take Profit')plot(series=strategy.position_size > 0 and entry_long_SL and longOK ? longSL : na, color=color.new(color.black, 0), style=plot.style_circles, linewidth=1, title='Long Stop Loss')plot(series=strategy.position_size < 0 and shortOK ? shortTP : na, color=color.new(color.green, 0), style=plot.style_circles, linewidth=3, title='Long Take Profit')plot(series=strategy.position_size < 0 and entry_short_SL and shortOK ? shortSL : na, color=color.new(color.black, 0), style=plot.style_circles, linewidth=1, title='Long Stop Loss')// Submit entry ordersif strategy.opentrades == 0 and longOK and within_window()    strategy.order(id='Long0', direction=strategy.long, qty=longEntryqty0, limit=longEntryPrice0, when=Buy_ok)    strategy.order(id='Long1', direction=strategy.long, qty=longEntryqty1, limit=longEntryPrice1, when=Buy_ok)    strategy.order(id='Long2', direction=strategy.long, qty=longEntryqty2, limit=longEntryPrice2, when=Buy_ok)    strategy.order(id='Long3', direction=strategy.long, qty=longEntryqty3, limit=longEntryPrice3, when=Buy_ok)    strategy.order(id='Long4', direction=strategy.long, qty=longEntryqty4, limit=longEntryPrice4, when=Buy_ok)if strategy.opentrades == 0 and shortOK and within_window()    strategy.order(id='Short0', direction=strategy.short, qty=shortEntryqty0, limit=shortEntryPrice0, when=Sell_ok)    strategy.order(id='Short1', direction=strategy.short, qty=shortEntryqty1, limit=shortEntryPrice1, when=Sell_ok)    strategy.order(id='Short2', direction=strategy.short, qty=shortEntryqty2, limit=shortEntryPrice2, when=Sell_ok)    strategy.order(id='Short3', direction=strategy.short, qty=shortEntryqty3, limit=shortEntryPrice3, when=Sell_ok)    strategy.order(id='Short4', direction=strategy.short, qty=shortEntryqty4, limit=shortEntryPrice4, when=Sell_ok)// exit positionif (strategy.position_size > 0) and not entry_long_SL and longOK    strategy.exit(id='exit_Long', limit=longTP, qty=strategy.position_size, when=strategy.position_size[1] > 0)if (strategy.position_size > 0) and entry_long_SL and longOK    strategy.exit(id='exit_Long', limit=longTP, stop=longSL, qty=strategy.position_size, when=strategy.position_size[1] > 0)if (strategy.position_size < 0) and not entry_short_SL and shortOK    strategy.exit(id='exit_Short', limit=shortTP, qty=math.abs(strategy.position_size), when=strategy.position_size[1] < 0)if (strategy.position_size < 0) and entry_short_SL and shortOK    strategy.exit(id='exit_Short', limit=shortTP, stop=shortSL, qty=math.abs(strategy.position_size), when=strategy.position_size[1] < 0)// Cleanupif ta.crossunder(strategy.opentrades, 0.5)    strategy.close_all()    strategy.cancel_all()