Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

CCI + EMA with RSI Cross Strategy

A Pine Script v5 strategy built on EMA (close, 9), RMA or Change (9) and SMA (hlc3, 20). 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 is one contract and pays no commission. 11 settings; defaults include Fast EMA Length 9, Slow EMA Length 20 and Fast RSI Length 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 + EMA with RSI Cross 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 CCI + EMA with RSI Cross 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 session window, which can leave these candles out. On ETHUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does CCI + EMA with RSI Cross Strategy 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: 14 before, 0 after on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does CCI + EMA with RSI Cross Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does CCI + EMA with RSI Cross Strategy run in Zeal Terminal?
Yes
It compiles in 22 ms and runs 1,000 bars in 58 ms, in the browser.

BTCUSDT · 1D · default settings

  • FastEMA
  • SlowEMA
  • 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 (11)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,000,000$2,025,273Equity from $1,000,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
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, $1,000,000 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.

  • Check

    No stop loss

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

  • 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.

Settings

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

SettingDefaultType and rangeFeeds
EMA Settings
Fast EMA Length9intfastEMA
Slow EMA Length20intslowEMA
RSI Settings
Fast RSI Length9int · min 1up1 down1
Fast RSI Sourceclosesourceup1 down1
Slow RSI Length20int · min 1up2 down2
Slow RSI Sourceclosesourceup2 down2
CCI Settings
CCI Length20int · min 1ma cci
CCI Sourcehlc3sourcema cci
CCI Cutoff50intcciBull cciBear
Stop Settings
Trail Loss ($)0.67float · min 0.0 · step 0.01longStop shortStop stopValue
Session Settings
Session0930-1545sessionsession

What it calculates

  • EMAclose, Fast EMA Length (9)fastEMA · line 8
  • EMAclose, Slow EMA Length (20)slowEMA · line 9
  • RMA / Changemath.max(ta.change(rsiSource1Input), 0), Fast RSI Length (9)up1 · line 23
  • RMA / Change-math.min(ta.change(rsiSource1Input), 0), Fast RSI Length (9)down1 · line 24
  • RMA / Changemath.max(ta.change(rsiSource2Input), 0), Slow RSI Length (20)up2 · line 26
  • RMA / Change-math.min(ta.change(rsiSource2Input), 0), Slow RSI Length (20)down2 · line 27
  • SMACCI Source (hlc3), CCI Length (20)ma · line 34
  • DEVCCI Source (hlc3), CCI Length (20)cci · line 35

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 datafastLenFast EMA Lengthsetting · 9slowLenSlow EMA Lengthsetting · 20rsiLength1InputFast RSI Lengthsetting · 9rsiLength2InputSlow RSI Lengthsetting · 20hlc3hlc3price datacciLengthCCI Lengthsetting · 20trstpTrail Loss ($)setting · 0.67open_sessionSessionsetting · 0930-1545cciCutCCI Cutoffsetting · 50fastEMAEMA→ fastEMAslowEMAEMA→ slowEMAup1RMA / Change→ up1down1RMA / Change→ down1up2RMA / Change→ up2down2RMA / Change→ down2maSMA→ macciDEV→ ccirsirsivaluersi2rsi2valuestopValuestopValuevaluesessionsessionvaluevalidSessionvalidSessionvaluelongConditionlongConditionconditionlongExitlongExitconditionshortConditionshortConditionconditionshortExitshortExitconditionBull, BearBull · Bear2 conditionsrsiBull, rsiBearrsiBull · rsiBear2 conditionscciBull, cciBearcciBull · cciBear2 conditionslongStoplongStopconditionshortStopshortStopconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeplot:10FastEMAplotplot:11SlowEMAplotfill:CloudCloudfillplotshape:53Short Stopplotshapeplotshape:54Long Stopplotshape

Order rules

OrderFires whenBy defaultLine
Open Long long(longCondition)On64
Close Long(longExit)On70
Open Short short(shortCondition)On75
Close Short(shortExit)On80

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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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 4h−0.0%+8.4%1443%0.970.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%956%1.750.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%944%1.490.1%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 (Slow EMA Length 10, CCI Length 10) made 0.0% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 0% of the 64 combinations made money in-sample and 0% out-of-sample.

Before 26 Dec 2025 · in-sample
CCI Length ↓ · Slow EMA Length →1012141720242834
100%0%0%0%0%0%0%0%
120%0%0%0%0%0%0%0%
140%0%0%0%0%0%0%0%
170%0%0%0%0%0%0%0%
200%0%0%0%0%0%0%0%
240%0%0%0%0%0%0%0%
280%0%0%0%0%0%0%0%
340%0%0%0%0%0%0%0%
From 26 Dec 2025 · out-of-sample
CCI Length ↓ · Slow EMA Length →1012141720242834
100%0%0%0%0%0%0%0%
120%0%0%0%0%0%0%0%
140%0%0%0%0%0%0%0%
170%0%0%0%0%0%0%0%
200%0%0%0%0%0%0%0%
240%0%0%0%0%0%0%0%
280%0%0%0%0%0%0%0%
340%0%0%0%0%0%0%0%

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.

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 + EMA with RSI Cross Strategy this page—v5 strategy0.0%00.0%
Optimized Keltner Channels SL-TP Strategy for BTC by chanu_lev10ksma ema rmav4 strategy−19.4%3670.0%
CCI & EMA strategy by Tradeswithashish by tradeswithashishema sma devv5 strategy+0.1%160.4%
Soheil PKO's 5 min Hitman Scalp - 3MA + Laguerre RSI + ADX [Pt] by PtGamblerema sma rmav5 strategyNo trades on this market
EMA-ADX-VOL-CRYPTO KILLER [15M] by Babehdyorma sma emav4 strategy+4.5%225.3%
Crypto rsi cci mf stoch rsi oscillators all in one strategy by SoftKill21rma sma devv4 strategy+1.6%326.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.

  • 3 settings use the untyped input() (line 6, 7, 33). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 14 trades and the same P&L on ETHUSDT 4h, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 33: input() → input.source()
⋯//EMA-fastLen = input(title='Fast EMA Length', defval=9, group='EMA Settings')+fastLen = input.int(title='Fast EMA Length', defval=9, group='EMA Settings')-slowLen = input(title='Slow EMA Length', defval=20, group='EMA Settings')+slowLen = input.int(title='Slow EMA Length', defval=20, group='EMA Settings')fastEMA = ta.ema(close, fastLen)⋯cciLength = input.int(title='CCI Length', group='CCI Settings', defval=20, minval=1)-src = input(hlc3, title='CCI Source', group='CCI Settings')+src = input.source(hlc3, title='CCI Source', group='CCI Settings')ma = ta.sma(src, cciLength)⋯

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: 14 before, 0 after on ETHUSDT 4h, 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.

⋯// © rwestbrookjr-//@version=5+//@version=6strategy("CCI + EMA with RSI Cross Strategy", overlay=true, margin_long=100, margin_short=100, process_orders_on_close=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 22 msYes 1,000 bars in 58 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/// © rwestbrookjr//@version=5strategy("CCI + EMA with RSI Cross Strategy", overlay=true, margin_long=100, margin_short=100, process_orders_on_close=true)//EMAfastLen = input(title='Fast EMA Length', defval=9, group='EMA Settings')slowLen = input(title='Slow EMA Length', defval=20, group='EMA Settings')fastEMA = ta.ema(close, fastLen)slowEMA = ta.ema(close, slowLen)fema = plot(fastEMA, title='FastEMA', color=color.new(color.green, 0), linewidth=1, style=plot.style_line)sema = plot(slowEMA, title='SlowEMA', color=color.new(color.red, 0), linewidth=1, style=plot.style_line)fill(fema, sema, color=fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title='Cloud')// Bull and Bear Alerts//Bull = ta.crossover(fastEMA, slowEMA)Bull = fastEMA > slowEMA//Bear = ta.crossunder(fastEMA, slowEMA)Bear = fastEMA < slowEMA//RSIsrsiLength1Input = input.int(9, minval=1, title="Fast RSI Length", group="RSI Settings")rsiSource1Input = input.source(close, "Fast RSI Source", group="RSI Settings")rsiLength2Input = input.int(20, minval=1, title="Slow RSI Length", group="RSI Settings")rsiSource2Input = input.source(close, "Slow RSI Source", group="RSI Settings")up1 = ta.rma(math.max(ta.change(rsiSource1Input), 0), rsiLength1Input)down1 = ta.rma(-math.min(ta.change(rsiSource1Input), 0), rsiLength1Input)rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))up2 = ta.rma(math.max(ta.change(rsiSource2Input), 0), rsiLength2Input)down2 = ta.rma(-math.min(ta.change(rsiSource2Input), 0), rsiLength2Input)rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))rsiBull = rsi > rsi2 and rsi > rsi[1]rsiBear = rsi < rsi2 and rsi < rsi[1]//CCIcciLength = input.int(title='CCI Length', group='CCI Settings', defval=20, minval=1)src = input(hlc3, title='CCI Source', group='CCI Settings')ma = ta.sma(src, cciLength)cci = (src - ma) / (0.015 * ta.dev(src, cciLength))cciCut = input.int(title = 'CCI Cutoff', group='CCI Settings', defval = 50)cciBull = cci > cciCutcciBear = cci < cciCut * -1//Trail Stop Setuptrstp = input.float(title="Trail Loss ($)", group='Stop Settings', minval = 0.0, step = 0.01, defval = 0.67)longStop = 0.0, shortStop = 0.0longStop := if Bull or strategy.position_size > 0    stopValue = slowEMA - trstp    math.max(stopValue, longStop[1])else    0.0shortStop := if Bear or strategy.position_size < 0    stopValue = slowEMA + trstp    math.min(stopValue, shortStop[1])else    999999    plotshape(title='Short Stop', series=shortStop != 999999 and strategy.opentrades > 0 and strategy.position_size < 0 ? shortStop : na, style=shape.cross, color=color.yellow, location=location.absolute)plotshape(title='Long Stop', series=longStop != 0.0 and strategy.opentrades > 0 and strategy.position_size > 0 ? longStop : na,style=shape.cross, color=color.yellow, location=location.absolute)//Session Setupopen_session=input.session(title='Session',group='Session Settings', defval="0930-1545")session = time("1", open_session)validSession=(na(session) ? 0 : 1)//Trade Signals//longCondition = Bull and cci > cciCut and ta.crossover(rsi,rsi2) and validSessionlongCondition = cciBull and ta.crossover(rsi,rsi2) and close > slowEMA and validSession//longCondition = cciBull and ta.crossover(rsi,rsi2) and Bull and validSessionif (longCondition)    strategy.entry("Long", strategy.long, 100)    //longExit = close > strategy.opentrades.entry_price(0) + 1.5 or close < strategy.opentrades.entry_price(0) - 0.75longExit = close < longStop or not validSession//longExit = ta.crossunder(low,longStop) or not validSessionif (longExit)    strategy.close("Long")//shortCondition = Bear and cci < (cciCut*-1) and ta.crossunder(rsi,rsi2) and validSessionshortCondition = cciBear and ta.crossunder(rsi,rsi2) and close < slowEMA and validSession//shortCondition = cciBear and ta.crossunder(rsi,rsi2) and Bear and validSessionif (shortCondition)    strategy.entry("Short", strategy.short, 100)//shortExit = close < strategy.opentrades.entry_price(0) - 1.5 or close > strategy.opentrades.entry_price(0) + 0.75shortExit = close > shortStop or not validSession//shortExit = ta.crossover(high, shortStop) or not validSessionif (shortExit)    strategy.close("Short")