Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

CCI Strategy

A Pine Script v4 strategy built on SMA (close, 20), DEV (close, 20) and Crossover (cci, 0). It has 16 order rules, 6 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 10000 in cash and pays no commission. 23 settings; defaults include CCI Length 20, Source close and CCI Simple Cross 0.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does CCI Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 31 of 31 trades.
How did CCI Strategy do on BTCUSDT 1D with default settings?
+62.07%
From 26 Jan 2024 to 21 Oct 2026, over 103 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can CCI Strategy be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does CCI Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 91, 93, 96, 98.
Does CCI Strategy run in Zeal Terminal?
Yes
It compiles in 31 ms and runs 1,000 bars in 85 ms, in the browser.

BTCUSDT · 1D · default settings

  • SMA
  • DEV
  • Crossover
  • Crossunder
  • Crossover
  • Crossunder
  • Crossunder
  • Crossover
  • Crossunder
  • Crossover
  • 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 (23)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$16,042$20,253Equity from $10,000
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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
+62.07%
$6,207.20
Buy and hold
+102.5%
same period
Closed trades
103
29 won · 74 lost
Profitable
28.2%
of closed trades
Profit factor
1.33
gross profit ÷ gross loss
Max drawdown
44.44%
−$5,603.27

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short 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.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames sma → ta.sma, dev → ta.dev, crossover → ta.crossover, crossunder → ta.crossunder.

v4 → v5

Verified

Same 103 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 8: sma → ta.sma
  • Line 9: dev → ta.dev
  • Line 11: input(type = input.time) → input.time()
  • Line 12: input(type = input.time) → input.time()
  • Line 32: crossover → ta.crossover
9 more edits
  • Line 33: crossunder → ta.crossunder
  • Line 34: crossover → ta.crossover
  • Line 35: crossunder → ta.crossunder
  • Line 36: crossunder → ta.crossunder
  • Line 37: crossover → ta.crossover
  • Line 38: crossunder → ta.crossunder
  • Line 39: crossover → ta.crossover
  • Line 43: input(type = input.float) → input.float()
  • Line 44: input(type = input.float) → input.float()
⋯// © REV0LUTI0N-//@version=4+//@version=5strategy(title="CCI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)⋯src = input(close, title="Source")-ma = sma(src, length)+ma = ta.sma(src, length)-cci = (src - ma) / (0.015 * dev(src, length))+cci = (src - ma) / (0.015 * ta.dev(src, length))// Strategy Backtesting-startDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')+startDate  = input.time(timestamp("2021-10-01T00:00:00"), title='Backtesting Start Date')-finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')+finishDate = input.time(timestamp("9999-12-31T00:00:00"), title='Backtesting End Date')time_cond  = time >= startDate and time <= finishDate⋯//Strategy Settings - Crosses-simplecrossup = crossover(cci, ccisource)+simplecrossup = ta.crossover(cci, ccisource)-simplecrossdown = crossunder(cci, ccisource)+simplecrossdown = ta.crossunder(cci, ccisource)-uppercrossup = crossover(cci, upperbandsource)+uppercrossup = ta.crossover(cci, upperbandsource)-lowercrossdown = crossunder(cci, lowerbandsource)+lowercrossdown = ta.crossunder(cci, lowerbandsource)-uppercrossdown = crossunder(cci, upperbandexitsource)+uppercrossdown = ta.crossunder(cci, upperbandexitsource)-lowercrossup = crossover(cci, lowerbandexitsource)+lowercrossup = ta.crossover(cci, lowerbandexitsource)-upperstop = crossunder(cci, upperbandsource)+upperstop = ta.crossunder(cci, upperbandsource)-lowerstop = crossover(cci, lowerbandsource)+lowerstop = ta.crossover(cci, lowerbandsource)// Stop Loss & Take Profit % Based⋯enabletp = input(false, title='Enable Take Profit')-stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100+stopTick = input.float(5.0, title='Stop Loss %', step=0.1) / 100-takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100+takeTick = input.float(10.0, title='Take Profit %', step=0.1) / 100longStop = strategy.position_avg_price * (1 - stopTick)⋯

Clean v5

VerifiedDownload the v5 script

Same 103 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 7: input() → input.source()
  • Line 15: input() → input.string()
  • Line 16: input() → input.bool()
  • Line 21: input() → input.bool()
  • Line 22: input() → input.bool()
13 more edits
  • Line 23: input() → input.bool()
  • Line 24: input() → input.bool()
  • Line 26: input() → input.int()
  • Line 27: input() → input.int()
  • Line 28: input() → input.int()
  • Line 29: input() → input.int()
  • Line 30: input() → input.int()
  • Line 41: input() → input.bool()
  • Line 42: input() → input.bool()
  • Line 54: input() → input.string()
  • Line 55: input() → input.string()
  • Line 56: input() → input.string()
  • Line 57: input() → input.string()
⋯//CCI Code-length = input(20, minval=1, title="CCI Length")+length = input.int(20, minval=1, title="CCI Length")-src = input(close, title="Source")+src = input.source(close, title="Source")ma = ta.sma(src, length)⋯//Time Restriction Settings-startendtime = input("", title='Time Frame To Enter Trades')+startendtime = input.string("", title='Time Frame To Enter Trades')-enableclose = input(false, title='Enable Close Trade At End Of Time Frame')+enableclose = input.bool(false, title='Enable Close Trade At End Of Time Frame')timetobuy = (time(timeframe.period, startendtime))⋯//Strategy Settings - Enable Check Boxes-enableentry = input(true, title="Enter First Trade ASAP")+enableentry = input.bool(true, title="Enter First Trade ASAP")-enableconfirmation = input(false, title="Wait For Cross To Enter First Trade")+enableconfirmation = input.bool(false, title="Wait For Cross To Enter First Trade")-enablezero =input(true, title="Use CCI Simple Cross Line For Entries & Exits")+enablezero =input.bool(true, title="Use CCI Simple Cross Line For Entries & Exits")-enablebands = input(false, title="Use Upper & Lower Bands For Entries & Exits")+enablebands = input.bool(false, title="Use Upper & Lower Bands For Entries & Exits")//Strategy Settings - Band Sources-ccisource = input(0, title="CCI Simple Cross")+ccisource = input.int(0, title="CCI Simple Cross")-upperbandsource =input(100, title="CCI Enter Long Band")+upperbandsource =input.int(100, title="CCI Enter Long Band")-upperbandexitsource =input(100, title="CCI Exit Long Band")+upperbandexitsource =input.int(100, title="CCI Exit Long Band")-lowerbandsource =input(-100, title="CCI Enter Short Band")+lowerbandsource =input.int(-100, title="CCI Enter Short Band")-lowerbandexitsource =input(-100, title="CCI Exit Short Band")+lowerbandexitsource =input.int(-100, title="CCI Exit Short Band")//Strategy Settings - Crosses⋯// Stop Loss & Take Profit % Based-enablesl = input(false, title='Enable Stop Loss')+enablesl = input.bool(false, title='Enable Stop Loss')-enabletp = input(false, title='Enable Take Profit')+enabletp = input.bool(false, title='Enable Take Profit')stopTick = input.float(5.0, title='Stop Loss %', step=0.1) / 100⋯// Alert messages-message_enterlong  = input("", title="Long Entry message")+message_enterlong  = input.string("", title="Long Entry message")-message_entershort = input("", title="Short Entry message")+message_entershort = input.string("", title="Short Entry message")-message_closelong = input("", title="Close Long message")+message_closelong = input.string("", title="Close Long message")-message_closeshort = input("", title="Close Short message")+message_closeshort = input.string("", title="Close Short message")    ⋯

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: 103 before, 6 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.

⋯// © REV0LUTI0N-//@version=5+//@version=6strategy(title="CCI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)⋯

Settings

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

SettingDefaultType and rangeFeeds
CCI Length20int · min 1ma cci
Sourceclosesourcema cci
Backtesting Start Datetimestamp("2021-10-01T00:00:00")timetime_cond
Backtesting End Datetimestamp("9999-12-31T00:00:00")timetime_cond
Time Frame To Enter Tradesstringtimetobuy timetoclose
Enable Close Trade At End Of Time Framefalseboolclose_all close_all line 85 line 87
Enter First Trade ASAPtrueboolentry Long entry Short line 61 line 63
Wait For Cross To Enter First Tradefalseboolentry Long entry Short line 65 line 67
Use CCI Simple Cross Line For Entries & Exitstrueboolentry Long entry Short entry Long entry Short line 61 line 63 line 65 line 67
Use Upper & Lower Bands For Entries & Exitsfalseboolentry Long entry Short close_all close_all close_all close_all line 70 line 72 line 75 line 77 line 80 line 82
CCI Simple Cross0intsimplecrossup simplecrossdown entry Long entry Short line 61 line 63
CCI Enter Long Band100intuppercrossup upperstop
CCI Exit Long Band100intuppercrossdown
CCI Enter Short Band-100intlowercrossdown lowerstop
CCI Exit Short Band-100intlowercrossup
Enable Stop Lossfalseboolexit Close Long exit Close Short Long Fixed SL Short Fixed SL line 90 line 92
Enable Take Profitfalseboolexit Close Long exit Close Short Long Take Profit Short Take Profit line 95 line 97
Stop Loss %5.0float · step 0.1longStop shortStop
Take Profit %10.0float · step 0.1shortTake longTake
Long Entry messagestringentry Long
Short Entry messagestringentry Short
Close Long messagestringclose_all exit Close Long
Close Short messagestringclose_all exit Close Short

What it calculates

  • SMA (sma, ta.sma in v5)Source (close), CCI Length (20)ma · line 8
  • DEV (dev, ta.dev in v5)Source (close), CCI Length (20)cci · line 9
  • Crossover (crossover, ta.crossover in v5)cci, CCI Simple Cross (0)simplecrossup · line 32
  • Crossunder (crossunder, ta.crossunder in v5)cci, CCI Simple Cross (0)simplecrossdown · line 33
  • Crossover (crossover, ta.crossover in v5)cci, CCI Enter Long Band (100)uppercrossup · line 34
  • Crossunder (crossunder, ta.crossunder in v5)cci, CCI Enter Short Band (-100)lowercrossdown · line 35
  • Crossunder (crossunder, ta.crossunder in v5)cci, CCI Exit Long Band (100)uppercrossdown · line 36
  • Crossover (crossover, ta.crossover in v5)cci, CCI Exit Short Band (-100)lowercrossup · line 37
  • Crossunder (crossunder, ta.crossunder in v5)cci, CCI Enter Long Band (100)upperstop · line 38
  • Crossover (crossover, ta.crossover in v5)cci, CCI Enter Short Band (-100)lowerstop · line 39

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

closecloseprice datalengthCCI Lengthsetting · 20ccisourceCCI Simple Crosssetting · 0upperbandsourceCCI Enter Long Bandsetting · 100lowerbandsourceCCI Enter Short Bandsetting · -100upperbandexitsourceCCI Exit Long Bandsetting · 100lowerbandexitsourceCCI Exit Short Bandsetting · -100startendtimeTime Frame To Enter Tra…setting · stopTickStop Loss %setting · 5.0takeTickTake Profit %setting · 10.0timetimeprice datastartDateBacktesting Start Datesetting · timestamp("2021-10-…finishDateBacktesting End Datesetting · timestamp("9999-12-…maSMA→ macciDEV→ ccisimplecrossupCrossover→ simplecrossupsimplecrossdownCrossunder→ simplecrossdownuppercrossupCrossover→ uppercrossuplowercrossdownCrossunder→ lowercrossdownuppercrossdownCrossunder→ uppercrossdownlowercrossupCrossover→ lowercrossupupperstopCrossunder→ upperstoplowerstopCrossover→ lowerstoptimetobuy, timetoclosetimetobuy · timetoclose2 valueslongStop, shortStoplongStop · shortStop2 valuesshortTake, longTakeshortTake · longTake2 valuestime_condtime_condconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose_all:close_all strategy.close_allexit:Close Longexit Close Longstrategy.exitexit:Close Shortexit Close Shortstrategy.exitplot:49Long Fixed SLplotplot:50Short Fixed SLplotplot:51Long Take Profitplotplot:52Short Take Profitplot

Order rules

OrderFires whenBy defaultLine
Open Long long(cci > ccisource and enablezero and enableentry and time_cond and timetobuy)On62
Open Short short(cci < ccisource and enablezero and enableentry and time_cond and timetobuy)On64
Open Long long(simplecrossup and enablezero and enableconfirmation and time_cond and timetobuy)On66
Open Short short(simplecrossdown and enablezero and enableconfirmation and time_cond and timetobuy)On68
Open Long long(uppercrossup and enablebands and time_cond and timetobuy)On71
Open Short short(lowercrossdown and enablebands and time_cond and timetobuy)On73
Close strategy.position_size > 0 and uppercrossdown and enablebands and time_cond and timetobuyOn76
Close strategy.position_size < 0 and lowercrossup and enablebands and time_cond and timetobuyOn78
Close strategy.position_size > 0 and upperstop and enablebands and time_cond and timetobuyOn81
Close strategy.position_size < 0 and lowerstop and enablebands and time_cond and timetobuyOn83
Close strategy.position_size > 0 and timetoclose and enableclose and time_condOn86
Close strategy.position_size < 0 and timetoclose and enableclose and time_condOn88
Exit Close Long stop and limitstrategy.position_size > 0 and enablesl and time_condOn91
Exit Close Short stop and limitstrategy.position_size < 0 and enablesl and time_condOn93
Exit Close Long stop and limitstrategy.position_size > 0 and enabletp and time_condOn96
Exit Close Short stop and limitstrategy.position_size < 0 and enabletp and time_condOn98

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, and the live replay matched history.

31/31trades 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. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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 1D+62.1%+102.5%10328%1.3344.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−3.7%+5.5%10822%0.9626.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+87.6%+9.8%10125%1.3036.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−34.9%+8.4%15215%0.7444.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+48.9%+16.7%9533%1.1442.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+1.1%+21.5%12222%1.0123.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+124.7%+148.3%9931%1.7625.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−10.1%+17.1%12823%0.8826.0%8 May 2026 – 21 Oct 2026

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

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market3531%$347.94
Sideways market4033%$2,938.73
Falling market2818%$2,920.53

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

How bad could the drawdown be?

51.0%

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

0%59%
All 103 trades
SideEntryExitBarsP&L
long15 Feb 2024 51,795.2017 Mar 2024 65,300.6031$2,607.48
short17 Mar 2024 65,300.6018 Mar 2024 68,393.501−$473.63
long18 Mar 2024 68,393.5020 Mar 2024 61,937.402−$943.96
short20 Mar 2024 61,937.4021 Mar 2024 67,840.501−$953.08
long21 Mar 2024 67,840.5022 Mar 2024 65,501.301−$344.81
short22 Mar 2024 65,501.3026 Mar 2024 69,880.004−$668.49
long26 Mar 2024 69,880.003 Apr 2024 65,464.008−$631.94
short3 Apr 2024 65,464.005 Apr 2024 68,487.802−$461.90
long5 Apr 2024 68,487.8013 Apr 2024 67,116.508−$200.22
short13 Apr 2024 67,116.5023 Apr 2024 66,819.3010$44.28
long23 Apr 2024 66,819.3024 Apr 2024 66,414.001−$60.66
short24 Apr 2024 66,414.005 May 2024 63,892.0011$379.74
long5 May 2024 63,892.007 May 2024 63,165.202−$113.76
short7 May 2024 63,165.2014 May 2024 62,940.107$35.64
long14 May 2024 62,940.1015 May 2024 61,577.501−$216.49
short15 May 2024 61,577.5016 May 2024 66,206.501−$751.74
long16 May 2024 66,206.5012 Jun 2024 67,314.2027$167.31
short12 Jun 2024 67,314.2015 Jul 2024 60,797.9033$968.04
long15 Jul 2024 60,797.901 Aug 2024 64,628.0017$629.97
short1 Aug 2024 64,628.0022 Aug 2024 61,156.0021$537.23
long22 Aug 2024 61,156.0028 Aug 2024 59,415.006−$284.69
short28 Aug 2024 59,415.0014 Sep 2024 60,498.0017−$182.28
long14 Sep 2024 60,498.002 Oct 2024 60,804.9018$50.73
short2 Oct 2024 60,804.9013 Oct 2024 63,206.2011−$394.92
long13 Oct 2024 63,206.205 Nov 2024 67,850.0023$734.70
short5 Nov 2024 67,850.006 Nov 2024 69,372.001−$224.32
long6 Nov 2024 69,372.0011 Dec 2024 96,593.0035$3,923.92
short11 Dec 2024 96,593.0012 Dec 2024 101,125.001−$469.19
long12 Dec 2024 101,125.0020 Dec 2024 97,461.908−$362.24
short20 Dec 2024 97,461.904 Jan 2025 98,174.2015−$73.09
long4 Jan 2025 98,174.209 Jan 2025 95,060.605−$317.15
short9 Jan 2025 95,060.6015 Jan 2025 96,560.906−$157.82
long15 Jan 2025 96,560.902 Feb 2025 100,636.0018$421.99
short2 Feb 2025 100,636.0021 Feb 2025 98,305.0019$231.59
long21 Feb 2025 98,305.0022 Feb 2025 96,182.001−$215.96
short22 Feb 2025 96,182.003 Mar 2025 94,270.009$198.79
long3 Mar 2025 94,270.004 Mar 2025 86,221.201−$853.81
short4 Mar 2025 86,221.2020 Mar 2025 86,845.9016−$72.46
long20 Mar 2025 86,845.9021 Mar 2025 84,223.401−$301.98
short21 Mar 2025 84,223.4024 Mar 2025 86,082.503−$220.74
long24 Mar 2025 86,082.5030 Mar 2025 82,648.506−$398.92
short30 Mar 2025 82,648.502 Apr 2025 85,158.403−$303.67
long2 Apr 2025 85,158.403 Apr 2025 82,516.301−$310.25
short3 Apr 2025 82,516.3012 Apr 2025 83,423.809−$109.98
long12 Apr 2025 83,423.8030 May 2025 105,590.0048$2,657.02
short30 May 2025 105,590.0010 Jun 2025 110,263.0011−$442.59
long10 Jun 2025 110,263.0013 Jun 2025 105,672.003−$416.39
short13 Jun 2025 105,672.0017 Jun 2025 106,795.004−$106.25
long17 Jun 2025 106,795.0018 Jun 2025 104,551.001−$210.06
short18 Jun 2025 104,551.0024 Jun 2025 105,334.006−$74.87
long24 Jun 2025 105,334.0030 Jul 2025 117,951.0036$1,197.79
short30 Jul 2025 117,951.008 Aug 2025 117,472.009$40.59
long8 Aug 2025 117,472.009 Aug 2025 116,675.001−$67.87
short9 Aug 2025 116,675.0011 Aug 2025 119,294.002−$224.52
long11 Aug 2025 119,294.0019 Aug 2025 116,227.008−$257.11
short19 Aug 2025 116,227.0023 Aug 2025 116,936.004−$61.00
long23 Aug 2025 116,936.0024 Aug 2025 115,438.001−$128.10
short24 Aug 2025 115,438.009 Sep 2025 112,065.0016$292.18
long9 Sep 2025 112,065.0023 Sep 2025 112,651.0014$52.27
short23 Sep 2025 112,651.0030 Sep 2025 114,312.007−$147.44
long30 Sep 2025 114,312.001 Oct 2025 114,049.001−$23.01
short1 Oct 2025 114,049.002 Oct 2025 118,595.001−$398.61
long2 Oct 2025 118,595.0011 Oct 2025 112,774.009−$490.79
short11 Oct 2025 112,774.0027 Oct 2025 114,559.0016−$158.27
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$396.14
short30 Oct 2025 110,021.003 Nov 2025 110,541.004−$47.21
long3 Nov 2025 110,541.004 Nov 2025 106,583.001−$358.03
short4 Nov 2025 106,583.003 Dec 2025 91,277.9029$1,435.99
long3 Dec 2025 91,277.906 Dec 2025 89,330.003−$213.40
short6 Dec 2025 89,330.008 Dec 2025 90,395.302−$119.25
long8 Dec 2025 90,395.3013 Dec 2025 90,268.405−$14.04
short13 Dec 2025 90,268.4031 Dec 2025 88,485.5018$197.51
long31 Dec 2025 88,485.501 Jan 2026 87,648.201−$94.62
short1 Jan 2026 87,648.202 Jan 2026 88,839.101−$135.87
long2 Jan 2026 88,839.1021 Jan 2026 88,427.7019−$46.31
short21 Jan 2026 88,427.703 Mar 2026 68,830.1041$2,216.23
long3 Mar 2026 68,830.108 Mar 2026 67,262.905−$227.68
short8 Mar 2026 67,262.9010 Mar 2026 68,432.202−$173.83
long10 Mar 2026 68,432.2020 Mar 2026 69,930.0010$218.88
short20 Mar 2026 69,930.0021 Mar 2026 70,510.701−$83.04
long21 Mar 2026 70,510.7022 Mar 2026 68,918.101−$225.87
short22 Mar 2026 68,918.1024 Mar 2026 70,906.402−$288.51
long24 Mar 2026 70,906.4027 Mar 2026 68,820.303−$294.21
short27 Mar 2026 68,820.306 Apr 2026 69,034.2010−$31.08
long6 Apr 2026 69,034.2016 May 2026 79,113.2040$1,460.00
short16 May 2026 79,113.2021 Jun 2026 64,298.0036$1,872.66
long21 Jun 2026 64,298.0022 Jun 2026 63,312.001−$153.35
short22 Jun 2026 63,312.0023 Jun 2026 64,020.001−$111.83
long23 Jun 2026 64,020.0024 Jun 2026 62,734.601−$200.79
short24 Jun 2026 62,734.604 Jul 2026 62,583.3010$24.12
long4 Jul 2026 62,583.3025 Jul 2026 64,140.0021$248.75
short25 Jul 2026 64,140.0026 Jul 2026 64,375.001−$36.64
long26 Jul 2026 64,375.0028 Jul 2026 63,755.902−$96.18
short28 Jul 2026 63,755.9031 Jul 2026 64,780.003−$160.64
long31 Jul 2026 64,780.001 Aug 2026 62,887.901−$292.09
short1 Aug 2026 62,887.906 Aug 2026 64,665.205−$282.62
long6 Aug 2026 64,665.207 Aug 2026 64,323.601−$52.83
short7 Aug 2026 64,323.608 Aug 2026 64,923.201−$93.21
long8 Aug 2026 64,923.2011 Aug 2026 63,970.003−$146.82
short11 Aug 2026 63,970.0018 Aug 2026 64,532.107−$87.87
long18 Aug 2026 64,532.1010 Sep 2026 78,306.4023$2,134.49
short10 Sep 2026 78,306.4019 Sep 2026 80,883.909−$329.15
long19 Sep 2026 80,883.908 Oct 2026 83,321.8019$301.41

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 Strategy this page—v4 strategy+62.1%10344.4%
CCI & EMA strategy by Tradeswithashish by tradeswithashishsma devv5 strategy+0.1%160.4%
Crypto rsi cci mf stoch rsi oscillators all in one strategy by SoftKill21sma devv4 strategy+1.6%326.8%
CCI + EMA with RSI Cross Strategy by rwestbrookjrsma devv5 strategyNo trades on this market
Oath by OrcChieftainsma devv4 strategy+0.2%450.0%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 31 msWith a workaround 1,000 bars in 85 msNot measured
PineTSNo v5 and v6 only—Not measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

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

Source

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © REV0LUTI0N//@version=4strategy(title="CCI Strategy", overlay=true, initial_capital = 10000, default_qty_value = 10000, default_qty_type = strategy.cash)//CCI Codelength = input(20, minval=1, title="CCI Length")src = input(close, title="Source")ma = sma(src, length)cci = (src - ma) / (0.015 * dev(src, length))// Strategy BacktestingstartDate  = input(timestamp("2021-10-01T00:00:00"), type = input.time, title='Backtesting Start Date')finishDate = input(timestamp("9999-12-31T00:00:00"), type = input.time, title='Backtesting End Date')time_cond  = time >= startDate and time <= finishDate//Time Restriction Settingsstartendtime = input("", title='Time Frame To Enter Trades')enableclose = input(false, title='Enable Close Trade At End Of Time Frame')timetobuy = (time(timeframe.period, startendtime))timetoclose = na(time(timeframe.period, startendtime))//Strategy Settings//Strategy Settings - Enable Check Boxesenableentry = input(true, title="Enter First Trade ASAP")enableconfirmation = input(false, title="Wait For Cross To Enter First Trade")enablezero =input(true, title="Use CCI Simple Cross Line For Entries & Exits")enablebands = input(false, title="Use Upper & Lower Bands For Entries & Exits")//Strategy Settings - Band Sourcesccisource = input(0, title="CCI Simple Cross")upperbandsource =input(100, title="CCI Enter Long Band")upperbandexitsource =input(100, title="CCI Exit Long Band")lowerbandsource =input(-100, title="CCI Enter Short Band")lowerbandexitsource =input(-100, title="CCI Exit Short Band")//Strategy Settings - Crossessimplecrossup = crossover(cci, ccisource)simplecrossdown = crossunder(cci, ccisource)uppercrossup = crossover(cci, upperbandsource)lowercrossdown = crossunder(cci, lowerbandsource)uppercrossdown = crossunder(cci, upperbandexitsource)lowercrossup = crossover(cci, lowerbandexitsource)upperstop = crossunder(cci, upperbandsource)lowerstop = crossover(cci, lowerbandsource)// Stop Loss & Take Profit % Basedenablesl = input(false, title='Enable Stop Loss')enabletp = input(false, title='Enable Take Profit')stopTick = input(5.0, title='Stop Loss %', type=input.float, step=0.1) / 100takeTick = input(10.0, title='Take Profit %', type=input.float, step=0.1) / 100longStop = strategy.position_avg_price * (1 - stopTick)shortStop = strategy.position_avg_price * (1 + stopTick)shortTake = strategy.position_avg_price * (1 - takeTick)longTake = strategy.position_avg_price * (1 + takeTick)plot(strategy.position_size > 0 and enablesl ? longStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Long Fixed SL")plot(strategy.position_size < 0 and enablesl ? shortStop : na, style=plot.style_linebr, color=color.red, linewidth=1, title="Short Fixed SL")plot(strategy.position_size > 0 and enabletp ? longTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Long Take Profit")plot(strategy.position_size < 0 and enabletp ? shortTake : na, style=plot.style_linebr, color=color.green, linewidth=1, title="Short Take Profit")// Alert messagesmessage_enterlong  = input("", title="Long Entry message")message_entershort = input("", title="Short Entry message")message_closelong = input("", title="Close Long message")message_closeshort = input("", title="Close Short message")    //Strategy Execution//Strategy Execution - Simple Line Crossif (cci > ccisource and enablezero and enableentry and time_cond and timetobuy)    strategy.entry("Long", strategy.long, alert_message = message_enterlong)if (cci < ccisource and enablezero and enableentry and time_cond and timetobuy)    strategy.entry("Short", strategy.short, alert_message = message_entershort)if (simplecrossup and enablezero and enableconfirmation and time_cond and timetobuy)    strategy.entry("Long", strategy.long, alert_message = message_enterlong)if (simplecrossdown and enablezero and enableconfirmation and time_cond and timetobuy)    strategy.entry("Short", strategy.short, alert_message = message_entershort)//Strategy Execution - Upper and Lower Band Entryif (uppercrossup and enablebands and time_cond and timetobuy)    strategy.entry("Long", strategy.long, alert_message = message_enterlong)if (lowercrossdown and enablebands and time_cond and timetobuy)    strategy.entry("Short", strategy.short, alert_message = message_entershort)//Strategy Execution - Upper and Lower Band Exitif strategy.position_size > 0 and uppercrossdown and enablebands and time_cond and timetobuy    strategy.close_all(alert_message = message_closelong)if strategy.position_size < 0 and lowercrossup and enablebands and time_cond and timetobuy    strategy.close_all(alert_message = message_closeshort)//Strategy Execution - Upper and Lower Band Stopsif strategy.position_size > 0 and upperstop and enablebands and time_cond and timetobuy    strategy.close_all(alert_message = message_closelong)if strategy.position_size < 0 and lowerstop and enablebands and time_cond and timetobuy    strategy.close_all(alert_message = message_closeshort)//Strategy Execution - Close Trade At End Of Time Frame    if strategy.position_size > 0 and timetoclose and enableclose and time_cond    strategy.close_all(alert_message = message_closelong)if strategy.position_size < 0 and timetoclose and enableclose and time_cond    strategy.close_all(alert_message = message_closeshort)//Strategy Execution - Stop Loss and Take Profitif strategy.position_size > 0 and enablesl and time_cond    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)if strategy.position_size < 0 and enablesl and time_cond    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)    if strategy.position_size > 0 and enabletp and time_cond    strategy.exit(id="Close Long", stop=longStop, limit=longTake, alert_message = message_closelong)if strategy.position_size < 0 and enabletp and time_cond    strategy.exit(id="Close Short", stop=shortStop, limit=shortTake, alert_message = message_closeshort)