Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

CCI Scalping Strategy

A Pine Script v4 strategy built on Lowest (10), Highest (10) and Valuewhen (bought, LL). It has 10 order rules, 8 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.04 commission. 15 settings; defaults include Strategy Direction 0, Strategy Stop Mult 0 and CCI Length 16.

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 Scalping Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
How did CCI Scalping Strategy do on BTCUSDT 1D with default settings?
−66.20%
From 26 Jan 2024 to 21 Oct 2026, over 41 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can CCI Scalping 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 Scalping Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 93, 94.
Does CCI Scalping Strategy run in Zeal Terminal?
Yes
It compiles in 27 ms and runs 1,000 bars in 78 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • SL
  • SSL
  • TP
  • STP
  • Bullish Setup
  • Bearish Setup
  • 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 (15)
50,000100,000150,000AprJulOct2025AprJulOct2026AprJulOct$3,449$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. Lines are what the script plots.
Net profit
−66.20%
−$6,620.17
Buy and hold
+102.5%
same period
Closed trades
41
20 won · 21 lost
Profitable
48.8%
of closed trades
Profit factor
0.48
gross profit ÷ gross loss
Max drawdown
72.97%
−$7,297.05

One run with the author's default settings, $10,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.

  • Check

    2 settings do nothing

    “-----------------Strategy Inputs-------------------”, “-----------------General Inputs-------------------” are declared but never read.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    Uses an argument v6 removed

    when = on line 77, 78, 80, 81, 84, 85, 87, 88, 93, 94. The upgraded version below moves each call inside an if block.

Upgrade and export

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

  • Upgrading to v5 renames lowest → ta.lowest, highest → ta.highest, valuewhen → ta.valuewhen, atr → ta.atr, cci → ta.cci, wma → ta.wma, crossover → ta.crossover, crossunder → ta.crossunder.
  • 10 strategy calls use the when = argument (line 77, 78, 80, 81, 84, 85, 87, 88, 93, 94). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 11: //@version=4 → //@version=5
  • Line 20: input(type = input.integer) → input.int()
  • Line 41: lowest → ta.lowest
  • Line 42: highest → ta.highest
  • Line 43: valuewhen → ta.valuewhen
  • Line 44: valuewhen → ta.valuewhen
9 more edits
  • Line 50: atr → ta.atr
  • Line 53: valuewhen → ta.valuewhen
  • Line 54: valuewhen → ta.valuewhen
  • Line 61: cci → ta.cci
  • Line 63: wma → ta.wma
  • Line 65: valuewhen → ta.valuewhen
  • Line 66: valuewhen → ta.valuewhen
  • Line 69: crossover → ta.crossover
  • Line 70: crossunder → ta.crossunder
⋯// Stop: Above 20 WMA"-//@version=4+//@version=5strategy("CCI Scalping Strat", ⋯     slippage=0)-direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)+direction = input.int(0, title = "Strategy Direction", minval=-1, maxval=1)strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))⋯// Price Action Stop and Take Profit-LL=(lowest(i_SPL))*(1-i_PercIncrement)+LL=(ta.lowest(i_SPL))*(1-i_PercIncrement)-HH=(highest(i_SPL))*(1+i_PercIncrement)+HH=(ta.highest(i_SPL))*(1+i_PercIncrement)-LL_price = valuewhen(bought, LL, 0)+LL_price = ta.valuewhen(bought, LL, 0)-HH_price = valuewhen(bought, HH, 0)+HH_price = ta.valuewhen(bought, HH, 0)entry_LL_price = strategy.position_size > 0 ? LL_price : na ⋯// ATR Stop-ATR=atr(i_ATR)*i_ATRMult+ATR=ta.atr(i_ATR)*i_ATRMultATRLong = ohlc4 - ATRATRShort = ohlc4 + ATR-ATRLongStop = valuewhen(bought, ATRLong, 0)+ATRLongStop = ta.valuewhen(bought, ATRLong, 0)-ATRShortStop = valuewhen(bought, ATRShort, 0)+ATRShortStop = ta.valuewhen(bought, ATRShort, 0)LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na ⋯//CCI-CCI=cci(close, i_CCI)+CCI=ta.cci(close, i_CCI)//WMA-WMA=wma(close, i_WMA)+WMA=ta.wma(close, i_WMA)//Stops-LongStop=valuewhen(bought, WMA, 0)*(1-i_Stop)+LongStop=ta.valuewhen(bought, WMA, 0)*(1-i_Stop)-ShortStop=valuewhen(bought, WMA, 0)*(1+i_Stop)+ShortStop=ta.valuewhen(bought, WMA, 0)*(1+i_Stop)StratTP=strategy.position_avg_price + (strategy.position_avg_price - LongStop)*i_TPRRRStratSTP=strategy.position_avg_price - (ShortStop - strategy.position_avg_price)*i_TPRRR-BUY = (close > WMA) and crossover(CCI , -100)+BUY = (close > WMA) and ta.crossover(CCI , -100)-SELL = (close < WMA) and crossunder(CCI , 100)+SELL = (close < WMA) and ta.crossunder(CCI , 100)//Trading Inputs⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 23: input() → input.bool()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 28: input() → input.bool()
  • Line 30: input() → input.bool()
18 more edits
  • Line 31: input() → input.string()
  • Line 32: input() → input.int()
  • Line 33: input() → input.int()
  • Line 34: input() → input.int()
  • Line 35: input() → input.int()
  • Line 36: input() → input.float()
  • Line 72: input() → input.bool()
  • Line 73: input() → input.bool()
  • Line 77: when = SELL and strategy.position_size == 0 → if block
  • Line 78: when = BUY and strategy.position_size == 0 → if block
  • Line 80: when = SELL → if block
  • Line 81: when = BUY → if block
  • Line 84: when = BUY and strategy.position_size == 0 → if block
  • Line 85: when = SELL and strategy.position_size == 0 → if block
  • Line 87: when = BUY → if block
  • Line 88: when = SELL → if block
  • Line 93: when = i_SL → if block
  • Line 94: when = i_SL → if block
⋯/////////////////////// STRATEGY INPUTS ////////////////////////////////////////-title1=input(true, "-----------------Strategy Inputs-------------------")  +title1=input.bool(true, "-----------------Strategy Inputs-------------------")  -i_Stop = input(0, step=.05, title="Strategy Stop Mult")*.01+i_Stop = input.int(0, step=.05, title="Strategy Stop Mult")*.01-i_CCI=input(16, title="CCI Length")+i_CCI=input.int(16, title="CCI Length")-i_WMA=input(5, title="WMA Length")+i_WMA=input.int(5, title="WMA Length")/////////////////////// BACKTESTER /////////////////////////////////////////////-title2=input(true, "-----------------General Inputs-------------------")  +title2=input.bool(true, "-----------------General Inputs-------------------")  // Backtester General Inputs-i_SL=input(true, title="Use Stop Loss and Take Profit")+i_SL=input.bool(true, title="Use Stop Loss and Take Profit")-i_SLType=input(defval="ATR Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])+i_SLType=input.string(defval="ATR Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])-i_SPL=input(defval=10, title="Swing Point Lookback")+i_SPL=input.int(defval=10, title="Swing Point Lookback")-i_PercIncrement=input(defval=2, step=.1, title="Swing Point SL Perc Increment")*0.01+i_PercIncrement=input.int(defval=2, step=.1, title="Swing Point SL Perc Increment")*0.01-i_ATR = input(14, title="ATR Length")+i_ATR = input.int(14, title="ATR Length")-i_ATRMult = input(10, step=.1, title="ATR Multiple")+i_ATRMult = input.int(10, step=.1, title="ATR Multiple")-i_TPRRR = input(1.5, step=.1, title="Take Profit Risk Reward Ratio")+i_TPRRR = input.float(1.5, step=.1, title="Take Profit Risk Reward Ratio")// Bought and Sold Boolean Signal⋯//Trading Inputs-DPR=input(true, "Allow Direct Position Reverse")+DPR=input.bool(true, "Allow Direct Position Reverse")-reverse=input(false, "Reverse Trades")+reverse=input.bool(false, "Reverse Trades")// Entries⋯    if not DPR-        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)+        if SELL and strategy.position_size == 0+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)+        if BUY and strategy.position_size == 0+            strategy.entry("short", strategy.short)    else     -        strategy.entry("long", strategy.long, when=SELL)+        if SELL+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=BUY)+        if BUY+            strategy.entry("short", strategy.short)else    if not DPR -        strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)+        if BUY and strategy.position_size == 0+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)+        if SELL and strategy.position_size == 0+            strategy.entry("short", strategy.short)    else-        strategy.entry("long", strategy.long, when=BUY)+        if BUY+            strategy.entry("long", strategy.long)-        strategy.entry("short", strategy.short, when=SELL)+        if SELL+            strategy.entry("short", strategy.short)SL= i_SLType == "Swing Lo/Hi" ? entry_LL_price : i_SLType == "ATR Stop" ? LongSL_ATR_price : LongStop⋯STP= i_SLType == "Swing Lo/Hi" ? stp : i_SLType == "ATR Stop" ? ATRstp : StratSTP-strategy.exit("TP & SL", "long", limit=TP, stop=SL, when=i_SL)+if i_SL+    strategy.exit("TP & SL", "long", limit=TP, stop=SL)-strategy.exit("TP & SL", "short", limit=STP, stop=SSL, when=i_SL)+if i_SL+    strategy.exit("TP & SL", "short", limit=STP, stop=SSL)/////////////////////// PLOTS //////////////////////////////////////////////////⋯

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: 41 before, 8 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.

⋯// Stop: Above 20 WMA"-//@version=5+//@version=6strategy("CCI Scalping Strat", ⋯

Settings

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

SettingDefaultType and rangeFeeds
Strategy Direction0int (written input.integer) · min -1 · max 1line 21
-----------------Strategy Inputs-------------------trueboolunused
Strategy Stop Mult0int · step .05LongStop ShortStop
CCI Length16intCCI
WMA Length5intWMA
-----------------General Inputs-------------------trueboolunused
Use Stop Loss and Take Profittrueboolexit TP & SL SL SSL TP STP
Type Of StopATR Stopstring · options ["Strategy Stop", "Swing Lo/Hi", "ATR Stop"]SL SSL TP STP
Swing Point Lookback10intLL HH
Swing Point SL Perc Increment2int · step .1LL HH
ATR Length14intATR
ATR Multiple10int · step .1ATR
Take Profit Risk Reward Ratio1.5float · step .1tp stp ATRtp ATRstp StratTP StratSTP
Allow Direct Position Reversetrueboolentry long entry short entry long entry short entry long entry short entry long entry short line 76 line 83
Reverse Tradesfalseboolline 75

What it calculates

  • Lowest (lowest, ta.lowest in v5)Swing Point Lookback (10)LL · line 41
  • Highest (highest, ta.highest in v5)Swing Point Lookback (10)HH · line 42
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, LL, 0LL_price · line 43
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, HH, 0HH_price · line 44
  • ATR (atr, ta.atr in v5)ATR Length (14)ATR · line 50
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, ATRLong, 0ATRLongStop · line 53
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, ATRShort, 0ATRShortStop · line 54
  • CCI (cci, ta.cci in v5)close, CCI Length (16)CCI · line 61
  • WMA (wma, ta.wma in v5)close, WMA Length (5)WMA · line 63
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, WMA, 0LongStop · line 65
  • Valuewhen (valuewhen, ta.valuewhen in v5)bought, WMA, 0ShortStop · line 66

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.

i_SPLSwing Point Lookbacksetting · 10i_PercIncrementSwing Point SL Perc Inc…setting · 2high · low · closehigh · low · closeprice datai_ATRATR Lengthsetting · 14i_ATRMultATR Multiplesetting · 10closecloseprice datai_CCICCI Lengthsetting · 16i_WMAWMA Lengthsetting · 5i_StopStrategy Stop Multsetting · 0i_TPRRRTake Profit Risk Reward…setting · 1.5ohlc4ohlc4price datai_SLTypeType Of Stopsetting · ATR StopLLLowest→ LLHHHighest→ HHLL_priceValuewhen→ LL_priceHH_priceValuewhen→ HH_priceATRATR→ ATRATRLongStopValuewhen→ ATRLongStopATRShortStopValuewhen→ ATRShortStopCCICCI→ CCIWMAWMA→ WMALongStopValuewhen→ LongStopShortStopValuewhen→ ShortStopentry_LL_priceentry_LL_pricevalueentry_HH_priceentry_HH_pricevaluetptpvaluestpstpvalueATRLong, ATRShortATRLong · ATRShort2 valuesLongSL_ATR_priceLongSL_ATR_pricevalueShortSL_ATR_priceShortSL_ATR_pricevalueATRtpATRtpvalueATRstpATRstpvalueStratTPStratTPvalueStratSTPStratSTPvalueSLSLvalueSSLSSLvalueTPTPvalueSTPSTPvalueBUYBUYconditionSELLSELLconditionboughtboughtconditionentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:TP & SLexit TP & SLstrategy.exitplot:96plotplotplot:97SLplotplot:98SSLplotplot:99TPplotplot:100STPplotplotshape:102Bullish Setupplotshapeplotshape:104Bearish Setupplotshape

Order rules

OrderFires whenBy defaultLine
Open long longSELL and strategy.position_size == 0On77
Open short shortBUY and strategy.position_size == 0On78
Open long longSELL(close < WMA) and crossunder(CCI , 100)On80
Open short shortBUY(close > WMA) and crossover(CCI , -100)On81
Open long longBUY and strategy.position_size == 0On84
Open short shortSELL and strategy.position_size == 0On85
Open long longBUY(close > WMA) and crossover(CCI , -100)On87
Open short shortSELL(close < WMA) and crossunder(CCI , 100)On88
Exit TP & SL stop and limiti_SLOn93
Exit TP & SL stop and limiti_SLOn94

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.

11/11trades 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−66.2%+102.5%4149%0.4873.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+17.0%+5.5%4558%1.4019.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−59.8%+9.8%4657%0.8289.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−19.7%+8.4%4353%0.6543.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−67.2%+16.7%3951%0.6780.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−15.9%+21.5%4556%0.7745.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−68.8%+148.3%3962%0.6180.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+22.3%+17.1%4050%1.4812.6%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (CCI Length 8, WMA Length 9) made +265.4% before 26 Dec 2025 and −53.8% after it, worse than the defaults' −17.7% after. Tuning on the past did not carry forward. 46% of the 48 combinations made money in-sample and 38% out-of-sample.

Before 26 Dec 2025 · in-sample
WMA Length ↓ · CCI Length →810111416192227
3+29%−2%−49%−60%−49%−50%−25%−9%
4+150%+73%+2%−35%−30%−46%−16%−11%
5+78%+16%−8%−48%−48%−52%−26%−11%
6+222%+111%+64%+10%−23%−51%−31%−12%
7+240%+109%+21%+47%+23%−32%−28%−8%
9+265%+134%+205%+38%+98%+18%+19%−28%
From 26 Dec 2025 · out-of-sample
WMA Length ↓ · CCI Length →810111416192227
3−9%−43%−9%−8%−11%−13%−23%−26%
4−14%−19%−22%−14%−24%−14%−26%−25%
5−54%−39%−34%−11%−18%−12%−18%−25%
6+122%−21%−30%+0%−4%+10%+17%+64%
7+128%−10%+41%+77%+71%+61%+17%+67%
9−54%−73%+8%+120%+22%+34%+18%+49%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market1644%−$3,321.32
Sideways market1753%−$2,486.81
Falling market850%−$810.69

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

How bad could the drawdown be?

80.4%

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

0%92%
All 41 trades
SideEntryExitBarsP&L
short18 Feb 2024 51,642.604 Mar 2024 66,908.5015−$2,964.06
short6 Mar 2024 63,724.0021 Mar 2024 67,840.5015−$460.14
long21 Mar 2024 67,840.502 Apr 2024 69,649.8012$170.06
short2 Apr 2024 69,649.8019 Apr 2024 63,470.1017$593.37
long19 Apr 2024 63,470.1020 May 2024 66,274.0031$318.20
short20 May 2024 66,274.0017 Jun 2024 66,676.9028−$52.69
long17 Jun 2024 66,676.9027 Aug 2024 62,834.0071−$444.20
short27 Aug 2024 62,834.003 Sep 2024 59,132.107$416.31
long3 Sep 2024 59,132.1016 Sep 2024 59,132.0013−$6.08
short16 Sep 2024 59,132.005 Oct 2024 62,086.0019−$384.41
long5 Oct 2024 62,086.0022 Oct 2024 67,377.5017$606.51
short22 Oct 2024 67,377.5011 Nov 2024 86,562.9020−$2,226.10
short26 Nov 2024 93,010.0025 Dec 2024 98,663.6029−$342.82
long25 Dec 2024 98,663.608 Jan 2025 96,954.6014−$94.63
short8 Jan 2025 96,954.604 Feb 2025 101,329.0027−$235.59
long4 Feb 2025 101,329.0022 Feb 2025 96,182.0018−$252.38
short22 Feb 2025 96,182.002 Mar 2025 86,064.508$484.71
long2 Mar 2025 86,064.5028 Apr 2025 93,749.3057$453.39
short28 Apr 2025 93,749.307 Jun 2025 104,288.0040−$631.95
long7 Jun 2025 104,288.0012 Jun 2025 108,645.005$202.66
short12 Jun 2025 108,645.0024 Jun 2025 105,334.0012$152.90
long24 Jun 2025 105,334.001 Jul 2025 107,147.007$86.97
short1 Jul 2025 107,147.005 Aug 2025 115,055.0035−$402.31
long5 Aug 2025 115,055.0015 Aug 2025 118,295.0010$136.42
short15 Aug 2025 118,295.0023 Aug 2025 116,936.008$54.80
long23 Aug 2025 116,936.0016 Sep 2025 115,350.0024−$74.37
short16 Sep 2025 115,350.0025 Sep 2025 113,307.009$86.35
long25 Sep 2025 113,307.008 Oct 2025 121,333.0013$363.39
short8 Oct 2025 121,333.0020 Oct 2025 108,643.0012$576.71
long20 Oct 2025 108,643.008 Jan 2026 91,364.2080−$979.52
short8 Jan 2026 91,364.2027 Jan 2026 88,347.1019$166.06
long27 Jan 2026 88,347.105 Feb 2026 64,451.209−$1,441.92
long9 Feb 2026 70,330.407 Mar 2026 68,114.0026−$125.14
short7 Mar 2026 68,114.0031 Mar 2026 66,797.4024$69.53
long31 Mar 2026 66,797.4013 Apr 2026 70,741.6013$222.41
short13 Apr 2026 70,741.6021 May 2026 77,552.2038−$392.58
long21 May 2026 77,552.201 Jul 2026 57,931.6041−$926.04
long2 Jul 2026 60,024.008 Jul 2026 63,364.006$149.27
short8 Jul 2026 63,364.003 Aug 2026 63,570.0026−$11.64
long3 Aug 2026 63,570.008 Sep 2026 79,112.0036$697.02
short8 Sep 2026 79,112.0011 Oct 2026 82,988.4033−$177.28

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 Scalping Strategy this page—v4 strategy−66.2%4173.0%
Positive Bars - Strategy by tweakerIDlowest highest valuewhen atrv4 strategy−40.3%754.7%
Big Bar Strategy by tweakerIDlowest highest valuewhen atrv4 strategy−56.6%1357.1%
SuperTrend Multi Time Frame Long and Short Trading Strategy by ranga_technologiesatr highest lowest valuewhenv5 strategyNo trades on this market
Inside Bar Strategy w- SL by tweakerIDlowest highest valuewhen atrv4 strategy−61.3%2565.0%
Modulo Logic + EMA Strat by tweakerIDlowest highest valuewhen atrv4 strategy−50.8%1654.7%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 27 msYes 1,000 bars in 78 msNot measured
PineTSNo v5 and v6 only—Not measured

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

Source

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © tweakerID// ---From the "Bitcoin Trading Strategies" book, by David Hanson---// After testing, works better with an ATR stop instead of the Strategy Stop. This paramater// can be changed from the strategy Inputs panel.// "CCI Scalping Strategy// Recommended Timeframe: 5 minutes// Indicators: 20 Period CCI, 20 WMA// Long when: Price closes above 20 WMA and CCI is below -100, enter when CCI crosses above -100.// Stop: Above 20 WMA"//@version=4strategy("CCI Scalping Strat",      overlay=true,      default_qty_type=strategy.percent_of_equity,      default_qty_value=100,      initial_capital=10000,      commission_value=0.04,      calc_on_every_tick=false,      slippage=0)direction = input(0, title = "Strategy Direction", type=input.integer, minval=-1, maxval=1)strategy.risk.allow_entry_in(direction == 0 ? strategy.direction.all : (direction < 0 ? strategy.direction.short : strategy.direction.long))/////////////////////// STRATEGY INPUTS ////////////////////////////////////////title1=input(true, "-----------------Strategy Inputs-------------------")  i_Stop = input(0, step=.05, title="Strategy Stop Mult")*.01i_CCI=input(16, title="CCI Length")i_WMA=input(5, title="WMA Length")/////////////////////// BACKTESTER /////////////////////////////////////////////title2=input(true, "-----------------General Inputs-------------------")  // Backtester General Inputsi_SL=input(true, title="Use Stop Loss and Take Profit")i_SLType=input(defval="ATR Stop", title="Type Of Stop", options=["Strategy Stop", "Swing Lo/Hi", "ATR Stop"])i_SPL=input(defval=10, title="Swing Point Lookback")i_PercIncrement=input(defval=2, step=.1, title="Swing Point SL Perc Increment")*0.01i_ATR = input(14, title="ATR Length")i_ATRMult = input(10, step=.1, title="ATR Multiple")i_TPRRR = input(1.5, step=.1, title="Take Profit Risk Reward Ratio")// Bought and Sold Boolean Signalbought = strategy.position_size > strategy.position_size[1]  or strategy.position_size < strategy.position_size[1]// Price Action Stop and Take ProfitLL=(lowest(i_SPL))*(1-i_PercIncrement)HH=(highest(i_SPL))*(1+i_PercIncrement)LL_price = valuewhen(bought, LL, 0)HH_price = valuewhen(bought, HH, 0)entry_LL_price = strategy.position_size > 0 ? LL_price : na entry_HH_price = strategy.position_size < 0 ? HH_price : na tp=strategy.position_avg_price + (strategy.position_avg_price - entry_LL_price)*i_TPRRRstp=strategy.position_avg_price - (entry_HH_price - strategy.position_avg_price)*i_TPRRR// ATR StopATR=atr(i_ATR)*i_ATRMultATRLong = ohlc4 - ATRATRShort = ohlc4 + ATRATRLongStop = valuewhen(bought, ATRLong, 0)ATRShortStop = valuewhen(bought, ATRShort, 0)LongSL_ATR_price = strategy.position_size > 0 ? ATRLongStop : na ShortSL_ATR_price = strategy.position_size < 0 ? ATRShortStop : na ATRtp=strategy.position_avg_price + (strategy.position_avg_price - LongSL_ATR_price)*i_TPRRRATRstp=strategy.position_avg_price - (ShortSL_ATR_price - strategy.position_avg_price)*i_TPRRR/////////////////////// STRATEGY LOGIC ///////////////////////////////////////////CCICCI=cci(close, i_CCI)//WMAWMA=wma(close, i_WMA)//StopsLongStop=valuewhen(bought, WMA, 0)*(1-i_Stop)ShortStop=valuewhen(bought, WMA, 0)*(1+i_Stop)StratTP=strategy.position_avg_price + (strategy.position_avg_price - LongStop)*i_TPRRRStratSTP=strategy.position_avg_price - (ShortStop - strategy.position_avg_price)*i_TPRRRBUY = (close > WMA) and crossover(CCI , -100)SELL = (close < WMA) and crossunder(CCI , 100)//Trading InputsDPR=input(true, "Allow Direct Position Reverse")reverse=input(false, "Reverse Trades")// Entriesif reverse    if not DPR        strategy.entry("long", strategy.long, when=SELL and strategy.position_size == 0)        strategy.entry("short", strategy.short, when=BUY and strategy.position_size == 0)    else             strategy.entry("long", strategy.long, when=SELL)        strategy.entry("short", strategy.short, when=BUY)else    if not DPR         strategy.entry("long", strategy.long, when=BUY and strategy.position_size == 0)        strategy.entry("short", strategy.short, when=SELL and strategy.position_size == 0)    else        strategy.entry("long", strategy.long, when=BUY)        strategy.entry("short", strategy.short, when=SELL)SL= i_SLType == "Swing Lo/Hi" ? entry_LL_price : i_SLType == "ATR Stop" ? LongSL_ATR_price : LongStopSSL= i_SLType == "Swing Lo/Hi" ? entry_HH_price : i_SLType == "ATR Stop" ? ShortSL_ATR_price : ShortStopTP= i_SLType == "Swing Lo/Hi" ? tp : i_SLType == "ATR Stop" ? ATRtp : StratTPSTP= i_SLType == "Swing Lo/Hi" ? stp : i_SLType == "ATR Stop" ? ATRstp : StratSTPstrategy.exit("TP & SL", "long", limit=TP, stop=SL, when=i_SL)strategy.exit("TP & SL", "short", limit=STP, stop=SSL, when=i_SL)/////////////////////// PLOTS //////////////////////////////////////////////////plot(WMA)plot(i_SL and strategy.position_size > 0 ? SL : na , title='SL', style=plot.style_cross, color=color.red)plot(i_SL and strategy.position_size < 0 ? SSL : na , title='SSL', style=plot.style_cross, color=color.red)plot(i_SL and strategy.position_size > 0 ? TP : na, title='TP', style=plot.style_cross, color=color.green)plot(i_SL and strategy.position_size < 0 ? STP : na, title='STP', style=plot.style_cross, color=color.green)// Draw price action setup arrowsplotshape(BUY ? 1 : na, style=shape.triangleup, location=location.belowbar,  color=color.green, title="Bullish Setup", size=size.auto)plotshape(SELL ? 1 : na, style=shape.triangledown, location=location.abovebar,  color=color.red, title="Bearish Setup", size=size.auto)