Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

CCI Level Zone

A Pine Script v5 strategy built on CCI (ohlc4, 1000), SMA (cci, 200) and RSI (close, 9). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100 in cash and pays 0.1 commission. 22 settings; defaults include len 200, level_CCI_ZON 30 and len RSI Long 9.

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 CCI Level Zone repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did CCI Level Zone 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 CCI Level Zone 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 CCI Level Zone use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does CCI Level Zone run in Zeal Terminal?
Yes
It compiles in 51 ms and runs 1,000 bars in 118 ms, in the browser.

BTCUSDT · 1D · default settings

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

One run with the author's default settings, $100 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    ta.crossunder(sto, 65) ignores the settings line 80

    Line 80 hard-codes 65 where line 48 uses “cross B”. Changing those settings moves one band but not this one.

    ta.crossunder(sto, 65)ta.crossunder(sto, level_RSI_LongB)
  • Likely bug

    ta.crossover(sto, 20) ignores the settings line 62

    Line 62 hard-codes 20 where line 49 uses “cross S”. Changing those settings moves one band but not this one.

    ta.crossover(sto ,20)ta.crossover(sto, level_RSI_LongS)
  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • 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 88, 89, 92, 93. 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
use sma( cci , len ) falseboolzoneB_Long zoneB_Short line hma CCi
len200intsma_CCi
Show win losstrueboolplotchar
<<<<[ Long ]>>>>>
Open Trad Longtrueboolentry L close L line 87
level_CCI_ZON30int · step 10zoneB_Long
len RSI Long9intrsi_Long
cross B54intCon_Long
cross S28intCon_close_Long
inverttrueboolline 47
<<<<[ Short ]>>>>>
Open Trad Shorttrueboolentry S close S line 91
level_CCI_ZON-70int · step 10zoneB_Short
len RSI Long13intrsi_Short
cross B51intCon_Short
cross S39intCon_close_Short
invertfalseboolline 66
Set Test Date
═════ Date Range Filtering ═════falseboolline 33
From Year 2020int · min 1900fromDate
From Month1int · min 1 · max 12fromDate
From Day 15int · min 1 · max 31fromDate
To Year 2023int · min 1900toDate
To Month12int · min 1 · max 12toDate
To Day 31int · min 1 · max 31toDate

What it calculates

  • CCIohlc4, 1000cci · line 36
  • SMAcci, len (200)sma_CCi · line 37
  • RSIclose, len RSI Long (9)rsi_Long · line 38
  • RSIclose, len RSI Long (13)rsi_Short · line 39
  • Stochclose, high, low, 14sto · line 40
  • Crossover / Crossunderrsi_Long, cross S (28)Con_close_Long · line 49
  • Crossunder / Crossoverrsi_Short, cross S (39)Con_close_Short · line 68

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.

ohlc4ohlc4price datalen_smalensetting · 200closecloseprice datalen_RSI_Llen RSI Longsetting · 9len_RSI_Slen RSI Longsetting · 13lowlowprice datahighhighprice datalevel_RSI_LongScross Ssetting · 28level_RSI_ShortScross Ssetting · 39i_fromYearFrom Year setting · 2020i_fromMonthFrom Monthsetting · 1i_fromDayFrom Day setting · 15timetimeprice datai_toYearTo Year setting · 2023i_toMonthTo Monthsetting · 12i_toDayTo Day setting · 31level_CCI_ZON_Llevel_CCI_ZONsetting · 30level_CCI_ZON_Slevel_CCI_ZONsetting · -70level_RSI_LongBcross Bsetting · 54level_RSI_ShortBcross Bsetting · 51cciCCI→ ccisma_CCiSMA→ sma_CCirsi_LongRSI→ rsi_Longrsi_ShortRSI→ rsi_ShortstoStoch→ stoCon_close_LongCrossover / Crossunder→ Con_close_LongCon_close_ShortCrossunder / Crossover→ Con_close_ShortfromDatefromDatevaluetoDatetoDatevaluezoneB_LongzoneB_LongvaluezoneB_ShortzoneB_Shortvaluebuy, sell, buy_SELLbuy · sell +13 valuesCon_LongCon_LongconditionOpen_Long, Open_ShortOpen_Long · Open_Short2 conditionsCon_ShortCon_Shortconditionentry:LOpen Lstrategy.entryclose:LClose Lstrategy.closeentry:SOpen Sstrategy.entryclose:SClose Sstrategy.closeplot:94line cciplotplot:95line hma CCi plothline:96hlinehlinehline:97hlinehlinehline:98hlinehlinehline:99hlinehlinehline:100hlinehlinehline:101hlinehlinehline:102hlinehlineplotchar:113plotcharplotcharplotchar:114plotcharplotcharplotchar:115plotcharplotcharplotchar:116plotcharplotchar

Order rules

OrderFires whenBy defaultLine
Open L longf_tradeDateIsAllowed() and Open_LongOn “Open Trad Long”88
Close LCon_close_LongOn “Open Trad Long”89
Open S shortf_tradeDateIsAllowed() and Con_ShortOn “Open Trad Short”92
Close SCon_close_ShortOn “Open Trad Short”93

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

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

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

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

Similar scripts

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

ScriptSharesTypeNetTradesMax drawdown
CCI Level Zone this page—v5 strategy0.0%00.0%
Suchit RSI CCI by SuchitRajucci sma rsiv4 strategy+11.4%6854.7%
Momentum Explosion 2CCI RSI by capamsma cci rsiv4 strategy+24.1%642.3%
AVWAP Strategy by asfbherorsi stoch smav5 strategydoes not run in Zeal Terminal
SRJ RSI Outperformer Strategy by Sapt_Jashrsi smav5 strategy+0.6%82.4%
RSI SMA Crossover Strategy by reeesrsi smav5 strategy+39.8%4230.8%

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.

  • 4 strategy calls use the when = argument (line 88, 89, 92, 93). 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 88: when = f_tradeDateIsAllowed() and Open_Long → if block
  • Line 89: when = Con_close_Long → if block
  • Line 92: when = f_tradeDateIsAllowed() and Con_Short → if block
  • Line 93: when = Con_close_Short → if block
⋯if trad_Long-    strategy.entry('L' ,strategy.long , when =f_tradeDateIsAllowed()  and  Open_Long , alert_message = textAlert_Long )+    if f_tradeDateIsAllowed()  and  Open_Long+        strategy.entry('L' ,strategy.long  , alert_message = textAlert_Long )-    strategy.close('L' ,when = Con_close_Long , alert_message = textAlert_Long)+    if Con_close_Long+        strategy.close('L'  , alert_message = textAlert_Long)    if trad_Short-    strategy.entry('S', strategy.short,when =f_tradeDateIsAllowed() and  Con_Short , alert_message = textAlert_Short)+    if f_tradeDateIsAllowed() and  Con_Short+        strategy.entry('S', strategy.short , alert_message = textAlert_Short)-    strategy.close('S' ,when = Con_close_Short , alert_message = textAlert_Close_Short )+    if Con_close_Short+        strategy.close('S'  , alert_message = textAlert_Close_Short )plot(cci , 'line cci', color = zoneB_Short ? color.purple :  zoneB_Long ? color.green : color.new(color.gray, 50))⋯

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.

⋯// © Naruephat-//@version=5+//@version=6strategy("CCI Level Zone", overlay= false  ,pyramiding = 0,  default_qty_type = strategy.cash,initial_capital = 100, default_qty_value =100 , commission_value=0.1)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 51 msYes 1,000 bars in 118 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Naruephat//@version=5strategy("CCI Level Zone", overlay= false  ,pyramiding = 0,  default_qty_type = strategy.cash,initial_capital = 100, default_qty_value =100 , commission_value=0.1)use_sma = input.bool( false ,  'use sma( cci , len ) ' ,inline = 'u' )len_sma = input.int( 200 , 'len' ,inline = 'u' )GL = '<<<<[ Long ]>>>>>'trad_Long = input.bool(true  ,  'Open Trad Long' ,inline = 'T' , group = GL)level_CCI_ZON_L = input.int(30 , 'level_CCI_ZON' , step = 10,inline = 'CR', group = GL)len_RSI_L = input.int(9 , 'len RSI Long' ,inline = 'CR', group = GL)level_RSI_LongB = input.int(54 , 'cross B' ,inline = 'L', group = GL)level_RSI_LongS = input.int(28 , 'cross S' ,inline = 'L', group = GL)cross_invert_L = input.bool(true , 'invert' , inline  =   'L' , group = GL)GS = '<<<<[ Short ]>>>>>'trad_Short = input.bool(true ,  'Open Trad Short' ,inline = 'T' , group = GS)level_CCI_ZON_S = input.int(-70 , 'level_CCI_ZON' , step = 10,inline = 'CR', group = GS)len_RSI_S = input.int(13 , 'len RSI Long',inline = 'CR', group = GS)level_RSI_ShortB = input.int(51 , 'cross B' , inline  =   'S' , group = GS)level_RSI_ShortS = input.int(39 , 'cross S' , inline  =   'S' , group = GS)cross_invert_S = input.bool(false , 'invert' , inline  =   'S' , group = GS)/////////////////////////////////////////////////////////[  Set Test Date  ]///////////////////////////////////////////////////////////////////////////////////////////////////// G0 = 'Set Test Date'i_dateFilter    = input.bool(false,  "═════ Date Range Filtering ═════" ,group = G0)i_fromYear      = input.int(2020,   "From Year ",    minval = 1900 ,inline = 'd1',group = G0)i_fromMonth     = input.int(1,      "From Month",   minval = 1, maxval = 12,inline = 'd2',group = G0)i_fromDay       = input.int(15,      "From Day ",     minval = 1, maxval = 31,inline = 'd3',group = G0)i_toYear        = input.int(2023,   "To Year ",      minval = 1900,inline = 'd1',group = G0)i_toMonth       = input.int(12,      "To Month",     minval = 1, maxval = 12,inline = 'd2',group = G0)i_toDay         = input.int(31,      "To Day ",       minval = 1, maxval = 31,inline = 'd3',group = G0)fromDate        = timestamp(i_fromYear, i_fromMonth, i_fromDay, 00, 00)toDate          = time < timestamp(i_toYear, i_toMonth, i_toDay, 23, 59) ? time :  timestamp(i_toYear, i_toMonth, i_toDay, 23, 59)// เอา f_tradeDateIsAllowed() ไปใช้f_tradeDateIsAllowed() => not i_dateFilter or (time >= fromDate and time <= toDate)Win_Loss_Show = input.bool(true,'Show win loss', inline = 's')// indicator cci = ta.cci(ohlc4 , 1000)sma_CCi = ta.sma(cci,len_sma)rsi_Long = ta.rsi(close,len_RSI_L)rsi_Short = ta.rsi(close,len_RSI_S)sto = ta.stoch(close, high, low, 14)// condition zonezoneB_Long = cci > level_CCI_ZON_L and ( use_sma ?  cci > sma_CCi : true ) zoneB_Short = cci < level_CCI_ZON_S  and ( use_sma ?  cci < sma_CCi : true )  /////////////////////////////////////////////////[ condition Long  ]/////////////////////////////////////////////////Con_Long       = falseCon_close_Long = falseif cross_invert_L    Con_Long        :=  zoneB_Long and ta.crossunder(rsi_Long , level_RSI_LongB)    Con_close_Long  := ta.crossover(rsi_Long , level_RSI_LongS)else    Con_Long        :=  zoneB_Long and ta.crossover(rsi_Long , level_RSI_LongB)    Con_close_Long  := ta.crossunder(rsi_Long , level_RSI_LongS)    // If conditions pass, remember this first. Find the opportunity to open the next order with stoch.var con_L_perss = 0if Con_Long and con_L_perss == 0    con_L_perss := 1// clear con_L_perssif strategy.position_avg_price != 0 or  Con_close_Long    con_L_perss := 0 // END Condition LongOpen_Long = con_L_perss == 1 and ta.crossover(sto ,20)/////////////////////////////////////////////////[ condition Short  ]/////////////////////////////////////////////////Con_Short       = falseCon_close_Short = falseif cross_invert_S    Con_Short       := zoneB_Short and  ta.crossover(rsi_Short , level_RSI_ShortB)    Con_close_Short :=  ta.crossunder(rsi_Short , level_RSI_ShortS)else    Con_Short       := zoneB_Short and  ta.crossunder(rsi_Short , level_RSI_ShortB)    Con_close_Short :=  ta.crossover(rsi_Short , level_RSI_ShortS)// If conditions pass, remember this first. Find the opportunity to open the next order with stoch.var con_S_perss = 0if Con_Short and con_S_perss == 0    con_S_perss := 1//  clear con_S_perssif strategy.position_avg_price != 0 or  Con_close_Short    con_S_perss := 0 // END ConditionOpen_Short = con_S_perss == 1 and ta.crossunder(sto, 65)///////////////////////////////////////////////////////////////////////////////////////////////[ // this chang Alert message for utextAlert_Long          = 'textAlert Long 'textAlert_close_Long    = 'textAlert Close Long 'textAlert_Short         = 'textAlert_Short'textAlert_Close_Short   = 'textAlert_Close_Short'if trad_Long    strategy.entry('L' ,strategy.long , when =f_tradeDateIsAllowed()  and  Open_Long , alert_message = textAlert_Long )    strategy.close('L' ,when = Con_close_Long , alert_message = textAlert_Long)    if trad_Short    strategy.entry('S', strategy.short,when =f_tradeDateIsAllowed() and  Con_Short , alert_message = textAlert_Short)    strategy.close('S' ,when = Con_close_Short , alert_message = textAlert_Close_Short )plot(cci , 'line cci', color = zoneB_Short ? color.purple :  zoneB_Long ? color.green : color.new(color.gray, 50))plot(use_sma ? sma_CCi : na, 'line hma CCi ', color = zoneB_Short ? color.purple :  zoneB_Long ? color.green : color.new(color.gray, 50))hline(350 ,'line level'   , linestyle = hline.style_dotted ,color = color.new(color.green  , 65 ))hline(200 ,'line level'   , linestyle = hline.style_dotted ,color = color.new(color.green  , 65 ))hline(100 ,'line level'   , linestyle = hline.style_dotted ,color = color.new(color.green  , 65 ))hline(0 ,'line level'     , linestyle = hline.style_dotted ,color = color.new(color.white , 50 ))hline(-350 ,'line level'  , linestyle = hline.style_dotted ,color = color.new(color.red  ,65 ))hline(-200 ,'line level'  , linestyle = hline.style_dotted ,color = color.new(color.red  ,65 ))hline(-100 ,'line level'  , linestyle = hline.style_dotted ,color = color.new(color.red  ,65 ))/////////////////////////////////////////////////////////[  Plot  ]///////////////////////////////////////////////////////////////////////////////////////////////////// var buy= 0.   var sell  = 0. if(ta.change(strategy.position_size) and  strategy.position_size == 0)        buy := nz(strategy.closedtrades.entry_price(strategy.closedtrades-1))    sell  := nz(strategy.closedtrades.exit_price(strategy.closedtrades-1))var buy_SELL = 2buy_SELL := strategy.position_size > 0 ? 0 : strategy.position_size < 0 ? 1 : 2//plot(buy_SELL[1])plotchar(  Win_Loss_Show ? nz(buy_SELL[1]) == 1 and ta.change(strategy.position_size) and  strategy.position_size == 0 and buy > sell : na ,location  = location.top ,color = color.new(color.green, 0), char='☺'  , size  = size.small)     plotchar(  Win_Loss_Show ? nz(buy_SELL[1]) == 1 and ta.change(strategy.position_size) and  strategy.position_size == 0 and buy < sell : na ,location  = location.top ,  color = color.new(color.red, 0), char='☹'  , size  = size.tiny)   plotchar(  Win_Loss_Show ? nz(buy_SELL[1]) ==0 and ta.change(strategy.position_size) and  strategy.position_size == 0 and buy < sell : na ,location  = location.top ,color = color.new(color.green, 0), char='☺'  , size  = size.small)     plotchar(  Win_Loss_Show ? nz(buy_SELL[1]) ==0 and ta.change(strategy.position_size) and  strategy.position_size == 0 and buy > sell : na ,location  = location.top ,  color = color.new(color.red, 0), char='☹'  , size  = size.tiny)