Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

RSI Divergence X Ichimoku Cloud X 200EMA

A Pine Script v4 strategy built on EMA (close, 200), RSI (close, 14) and Pivotlow (osc, 5). 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. 12 settings; defaults include Len 14, Src close and Lb R 5.

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 RSI Divergence X Ichimoku Cloud X 200EMA repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did RSI Divergence X Ichimoku Cloud X 200EMA do on BTCUSDT 1D with default settings?
−196,793.00%
From 26 Jan 2024 to 21 Oct 2026, over 7 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can RSI Divergence X Ichimoku Cloud X 200EMA 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 RSI Divergence X Ichimoku Cloud X 200EMA use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI Divergence X Ichimoku Cloud X 200EMA run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 57 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • Pivotlow
  • Pivothigh
  • Crossover
  • 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 (12)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct5RSI$-396,519,000$202,527Equity from $100,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.
Net profit
−196,793.00%
−$196,793,000.00
Buy and hold
+102.5%
same period
Closed trades
7
4 won · 3 lost
Profitable
57.1%
of closed trades
Profit factor
0.69
gross profit ÷ gross loss
Max drawdown
1,854.60%
−$583,127,000.00

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

    1 setting does nothing

    “Displacement” is declared but never read.

  • 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

    12 settings have no label

    In the settings dialog len (line 6), src (line 7), lbR (line 8), lbL (line 9), takeProfitLevellong (line 10), takeProfitLevelshort (line 11), rangeUpper (line 12), rangeLower (line 13), conversionPeriods (line 17), basePeriods (line 18), laggingSpan2Periods (line 19), displacement (line 20) show an empty name. The labels on this page come from the variable names.

  • 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 56, 57, 58, 59. 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 ema → ta.ema, avg → math.avg, lowest → ta.lowest, highest → ta.highest, max → math.max, min → math.min, rsi → ta.rsi, barssince → ta.barssince, pivotlow → ta.pivotlow, pivothigh → ta.pivothigh, valuewhen → ta.valuewhen, crossover → ta.crossover.
  • 4 strategy calls use the when = argument (line 56, 57, 58, 59). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 15: ema → ta.ema
  • Line 21: avg → math.avg
  • Line 21: lowest → ta.lowest
  • Line 21: highest → ta.highest
  • Line 24: avg → math.avg
16 more edits
  • Line 26: max → math.max
  • Line 27: min → math.min
  • Line 29: rsi → ta.rsi
  • Line 31: barssince → ta.barssince
  • Line 33: pivotlow → ta.pivotlow
  • Line 34: pivothigh → ta.pivothigh
  • Line 36: valuewhen → ta.valuewhen
  • Line 37: valuewhen → ta.valuewhen
  • Line 40: valuewhen → ta.valuewhen
  • Line 41: valuewhen → ta.valuewhen
  • Line 44: valuewhen → ta.valuewhen
  • Line 45: valuewhen → ta.valuewhen
  • Line 48: valuewhen → ta.valuewhen
  • Line 49: valuewhen → ta.valuewhen
  • Line 53: crossover → ta.crossover
  • Line 55: crossover → ta.crossover
⋯// © tradethrills-//@version=4+//@version=5strategy("RSI Divergence X Ichimoku Cloud X 200EMA", overlay=true)⋯//200 EMA-ema200 = ema(close, 200)+ema200 = ta.ema(close, 200)//Ichimoku Cloud Indicator⋯displacement = input(26, minval=1)-donchian(len) => avg(lowest(len), highest(len))+donchian(len) => math.avg(ta.lowest(len), ta.highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)-leadLine1 = avg(conversionLine, baseLine)+leadLine1 = math.avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)-abovecloud =  max(leadLine1, leadLine2)+abovecloud =  math.max(leadLine1, leadLine2)-belowcloud = min(leadLine1, leadLine2)+belowcloud = math.min(leadLine1, leadLine2)//RSI Divergence Strategy-osc = rsi(src, len)+osc = ta.rsi(src, len)_inrange(cond) =>-    bars = barssince(cond == true)+    bars = ta.barssince(cond == true)    rangeLower <= bars and bars <= rangeUpper-pricelowfound = na(pivotlow(osc, lbL, lbR)) ? false : true+pricelowfound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true-pricehighfound = na(pivothigh(osc, lbL, lbR)) ? false : true+pricehighfound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true//Regular Bullish-osc_higherlow = osc[lbR] > valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])+osc_higherlow = osc[lbR] > ta.valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])-price_lowerlow = low[lbR] < valuewhen(pricelowfound, low[lbR], 1)+price_lowerlow = low[lbR] < ta.valuewhen(pricelowfound, low[lbR], 1)bullCond = price_lowerlow and osc_higherlow and pricelowfound//Hidden Bullish-osc_lowerlow = osc[lbR] < valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])+osc_lowerlow = osc[lbR] < ta.valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])-price_higherlow = low[lbR] > valuewhen(pricelowfound, low[lbR], 1)+price_higherlow = low[lbR] > ta.valuewhen(pricelowfound, low[lbR], 1)hiddenbullCond = price_higherlow and osc_lowerlow and pricelowfound//Regular Bearish-osc_lowerhigh = osc[lbR] < valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])+osc_lowerhigh = osc[lbR] < ta.valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])-price_higherhigh = high[lbR] > valuewhen(pricehighfound, high[lbR], 1)+price_higherhigh = high[lbR] > ta.valuewhen(pricehighfound, high[lbR], 1)bearCond = price_higherhigh and osc_lowerhigh and pricehighfound//Hidden Bearish-osc_higherhigh = osc[lbR] > valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])+osc_higherhigh = osc[lbR] > ta.valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])-price_lowerhigh = high[lbR] < valuewhen(pricehighfound, high[lbR], 1)+price_lowerhigh = high[lbR] < ta.valuewhen(pricehighfound, high[lbR], 1)hiddenbearCond = price_lowerhigh and osc_higherhigh and pricehighfound⋯longCondition = (bullCond or hiddenbullCond) and (abovecloud > ema200)-closelongCondition = crossover(osc, takeProfitLevellong) +closelongCondition = ta.crossover(osc, takeProfitLevellong) shortCondition = (bearCond or hiddenbearCond) and (ema200 > belowcloud)-closeshortCondition = crossover(osc, takeProfitLevelshort)+closeshortCondition = ta.crossover(osc, takeProfitLevelshort)strategy.entry("Long", strategy.long, 10000.0, when=longCondition)⋯

Clean v5

VerifiedDownload the v5 script

Same 7 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 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
10 more edits
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
  • Line 56: when = longCondition → if block
  • Line 57: when = closelongCondition → if block
  • Line 58: when = shortCondition → if block
  • Line 59: when = closeshortCondition → if block
⋯//RSI Indicator-len = input(defval=14, minval=1)+len = input.int(defval=14, minval=1)-src = input(defval=close)+src = input.source(defval=close)-lbR = input(defval=5)+lbR = input.int(defval=5)-lbL = input(defval=5)+lbL = input.int(defval=5)-takeProfitLevellong = input(minval = 70, defval = 75)+takeProfitLevellong = input.int(minval = 70, defval = 75)-takeProfitLevelshort = input(minval = 30, defval = 25)+takeProfitLevelshort = input.int(minval = 30, defval = 25)-rangeUpper = input(defval=60)+rangeUpper = input.int(defval=60)-rangeLower = input(defval=5)+rangeLower = input.int(defval=5)//200 EMA⋯//Ichimoku Cloud Indicator-conversionPeriods = input(9, minval=1)+conversionPeriods = input.int(9, minval=1)-basePeriods = input(26, minval=1)+basePeriods = input.int(26, minval=1)-laggingSpan2Periods = input(52, minval=1)+laggingSpan2Periods = input.int(52, minval=1)-displacement = input(26, minval=1)+displacement = input.int(26, minval=1)donchian(len) => math.avg(ta.lowest(len), ta.highest(len))⋯closeshortCondition = ta.crossover(osc, takeProfitLevelshort)-strategy.entry("Long", strategy.long, 10000.0, when=longCondition)+if longCondition+    strategy.entry("Long", strategy.long, 10000.0)-strategy.close("Long", when=closelongCondition)+if closelongCondition+    strategy.close("Long")-strategy.entry("Short", strategy.short, 10000.0, when=shortCondition)+if shortCondition+    strategy.entry("Short", strategy.short, 10000.0)-strategy.close("Short", when=closeshortCondition)+if closeshortCondition+    strategy.close("Short")

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

⋯// © tradethrills-//@version=5+//@version=6strategy("RSI Divergence X Ichimoku Cloud X 200EMA", overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Len (no label in the script)14int · min 1osc line 21
Src (no label in the script)closesourceosc
Lb R (no label in the script)5intpricelowfound pricehighfound osc_higherlow price_lowerlow osc_lowerlow price_higherlow osc_lowerhigh price_higherhigh osc_higherhigh price_lowerhigh
Lb L (no label in the script)5intpricelowfound pricehighfound
Take Profit Levellong (no label in the script)75int · min 70closelongCondition
Take Profit Levelshort (no label in the script)25int · min 30closeshortCondition
Range Upper (no label in the script)60intline 32
Range Lower (no label in the script)5intline 32
Conversion Periods (no label in the script)9int · min 1conversionLine
Base Periods (no label in the script)26int · min 1baseLine
Lagging Span2Periods (no label in the script)52int · min 1leadLine2
Displacement (no label in the script)26int · min 1unused

What it calculates

  • EMA (ema, ta.ema in v5)close, 200ema200 · line 15
  • RSI (rsi, ta.rsi in v5)Src (close), Len (14)osc · line 29
  • Pivotlow (pivotlow, ta.pivotlow in v5)osc, Lb L (5), Lb R (5)pricelowfound · line 33
  • Pivothigh (pivothigh, ta.pivothigh in v5)osc, Lb L (5), Lb R (5)pricehighfound · line 34
  • Crossover (crossover, ta.crossover in v5)osc, Take Profit Levellong (75)closelongCondition · line 53
  • Crossover (crossover, ta.crossover in v5)osc, Take Profit Levelshort (25)closeshortCondition · line 55

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 datalenLensetting · 14lbRLb Rsetting · 5lbLLb Lsetting · 5takeProfitLevellongTake Profit Levellongsetting · 75takeProfitLevelshortTake Profit Levelshortsetting · 25conversionPeriodsConversion Periodssetting · 9basePeriodsBase Periodssetting · 26laggingSpan2PeriodsLagging Span2Periodssetting · 52lowlowprice datahighhighprice dataema200EMA→ ema200oscRSI→ oscpricelowfoundPivotlow→ pricelowfoundpricehighfoundPivothigh→ pricehighfoundcloselongConditionCrossover→ closelongConditioncloseshortConditionCrossover→ closeshortConditionconversionLineconversionLinevaluebaseLinebaseLinevalueleadLine1leadLine1valueleadLine2leadLine2valueabovecloud, belowcloudabovecloud · belowcloud2 valueslongConditionlongConditionconditionshortConditionshortConditionconditionbarsbarsconditionosc_higherlow, osc_lowerlowosc_higherlow · osc_low…2 conditionsprice_lowerlow, price_higherlowprice_lowerlow · price_…2 conditionsbullCondbullCondconditionhiddenbullCondhiddenbullCondconditionosc_lowerhigh, osc_higherhighosc_lowerhigh · osc_hig…2 conditionsprice_higherhigh, price_lowerhighprice_higherhigh · pric…2 conditionsbearCondbearCondconditionhiddenbearCondhiddenbearCondconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.close

Order rules

OrderFires whenBy defaultLine
Open Long longlongCondition(bullCond or hiddenbullCond) and (abovecloud > ema200)On56
Close LongcloselongConditionOn57
Open Short shortshortCondition(bearCond or hiddenbearCond) and (ema200 > belowcloud)On58
Close ShortcloseshortConditionOn59

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.

1/1trades 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−196,793.0%+102.5%757%0.691,854.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−170,420.0%+5.5%650%0.10221,260.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−62,689.8%+9.8%838%0.1871,900.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+4,395.2%+8.4%580%3.731,894.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1,643.0%+16.7%540%0.203,303.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+7.8%+21.5%667%1.0481.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−466.0%+148.3%771%0.90644.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+744.4%+17.1%580%3.46296.2%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 market367%$43,002,200.00
Sideways market333%−$358,752,000.00
Falling market1100%$118,958,000.00

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

How bad could the drawdown be?

364,724.0%

The 95th percentile of the worst drawdown when the same 7 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 257.8% to 364,724.0%; the tick is what actually happened, 1,303.9%. Order luck alone moves it this much.

0%419,433%
All 7 trades
SideEntryExitBarsP&L
long10 Nov 2024 76,677.5011 Nov 2024 80,370.001$36,925,500.00
long2 Dec 2024 97,185.2030 Mar 2025 82,648.50118−$145,366,000.00
short30 Mar 2025 82,648.505 Jun 2025 104,697.0067−$220,483,000.00
long5 Jun 2025 104,697.0015 Jul 2025 119,841.0040$151,443,000.00
long8 Aug 2025 117,472.009 Dec 2025 90,634.40123−$268,377,000.00
short9 Dec 2025 90,634.403 Feb 2026 78,738.6056$118,958,000.00
short29 Apr 2026 76,342.808 Jun 2026 63,332.0040$130,108,000.00

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
RSI Divergence X Ichimoku Cloud X 200EMA this page—v4 strategy−196,793.0%71,854.6%
RSI Centered Pivots by OztheWozrsi pivotlow pivothighv4 strategy+98.0%4160.2%
RSI5_50 with Divergence by mohaneersi pivotlow pivothighv4 strategy+443.3%25411.3%
TradePro's 2 EMA + Stoch RSI + ATR Strategy by PtGamblerema rsi pivothigh pivotlowv5 strategy−2.7%1822.0%
MACD 5 iN 1 [Pro-Tool] by HamidBoxema rsi pivotlow pivothighv4 strategyNo trades on this market
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 14 msYes 1,000 bars in 57 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/// © tradethrills//@version=4strategy("RSI Divergence X Ichimoku Cloud X 200EMA", overlay=true)//RSI Indicatorlen = input(defval=14, minval=1)src = input(defval=close)lbR = input(defval=5)lbL = input(defval=5)takeProfitLevellong = input(minval = 70, defval = 75)takeProfitLevelshort = input(minval = 30, defval = 25)rangeUpper = input(defval=60)rangeLower = input(defval=5)//200 EMAema200 = ema(close, 200)//Ichimoku Cloud IndicatorconversionPeriods = input(9, minval=1)basePeriods = input(26, minval=1)laggingSpan2Periods = input(52, minval=1)displacement = input(26, minval=1)donchian(len) => avg(lowest(len), highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)leadLine1 = avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)abovecloud =  max(leadLine1, leadLine2)belowcloud = min(leadLine1, leadLine2)//RSI Divergence Strategyosc = rsi(src, len)_inrange(cond) =>    bars = barssince(cond == true)    rangeLower <= bars and bars <= rangeUpperpricelowfound = na(pivotlow(osc, lbL, lbR)) ? false : truepricehighfound = na(pivothigh(osc, lbL, lbR)) ? false : true//Regular Bullishosc_higherlow = osc[lbR] > valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])price_lowerlow = low[lbR] < valuewhen(pricelowfound, low[lbR], 1)bullCond = price_lowerlow and osc_higherlow and pricelowfound//Hidden Bullishosc_lowerlow = osc[lbR] < valuewhen(pricelowfound, osc[lbR], 1) and _inrange(pricelowfound[1])price_higherlow = low[lbR] > valuewhen(pricelowfound, low[lbR], 1)hiddenbullCond = price_higherlow and osc_lowerlow and pricelowfound//Regular Bearishosc_lowerhigh = osc[lbR] < valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])price_higherhigh = high[lbR] > valuewhen(pricehighfound, high[lbR], 1)bearCond = price_higherhigh and osc_lowerhigh and pricehighfound//Hidden Bearishosc_higherhigh = osc[lbR] > valuewhen(pricehighfound, osc[lbR], 1) and _inrange(pricehighfound[1])price_lowerhigh = high[lbR] < valuewhen(pricehighfound, high[lbR], 1)hiddenbearCond = price_lowerhigh and osc_higherhigh and pricehighfound//Entry and ExitlongCondition = (bullCond or hiddenbullCond) and (abovecloud > ema200)closelongCondition = crossover(osc, takeProfitLevellong) shortCondition = (bearCond or hiddenbearCond) and (ema200 > belowcloud)closeshortCondition = crossover(osc, takeProfitLevelshort)strategy.entry("Long", strategy.long, 10000.0, when=longCondition)strategy.close("Long", when=closelongCondition)strategy.entry("Short", strategy.short, 10000.0, when=shortCondition)strategy.close("Short", when=closeshortCondition)