Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Cumulative RSI Strategy

A Pine Script v5 strategy built on RSI (close, 3). It has 5 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 110% of equity and pays .0035 commission. 12 settings; defaults include RSI Length 3, RSI Cumulation Length 3 and Oversold Level 94.

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 Cumulative RSI 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 Cumulative RSI Strategy do on BTCUSDT 1D with default settings?
+15.88%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Cumulative RSI Strategy run in Pine Script v6?
Yes
Same 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Cumulative RSI Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Cumulative RSI Strategy run in Zeal Terminal?
Yes
It compiles in 13 ms and runs 1,000 bars in 31 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$28,969$50,632Equity from $25,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
+15.88%
$3,968.76
Buy and hold
+102.5%
same period
Closed trades
5
3 won · 2 lost
Profitable
60.0%
of closed trades
Profit factor
1.27
gross profit ÷ gross loss
Max drawdown
51.48%
−$21,513.50

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

    Every trade uses all the equity

    default_qty_value is 110% of equity.

  • Note

    Uses an argument v6 removed

    when = on line 27, 28, 30, 31. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
RSI Length3int · min 1rsi
RSI Cumulation Length3intcumRSI ob os
Oversold Level94intclose Long
Overbought Level20intentry Long
Only Trade When Price is Above EMA?falseboolentry Long close Long entry Long close Long line 26 line 29
EMA Length100intTrendisLong plot
Start Date1int · min 1 · max 31InDateRange
Start Month1int · min 1 · max 12InDateRange
Start Year2010int · min 1950 · max 2100InDateRange
End Date1int · min 1 · max 31InDateRange
End Month1int · min 1 · max 12InDateRange
End Year2099int · min 1950 · max 2100InDateRange

What it calculates

  • RSIclose, RSI Length (3)rsi · line 8

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 datarlenRSI Lengthsetting · 3cumlenRSI Cumulation Lengthsetting · 3timetimeprice datastartYearStart Yearsetting · 2010startMonthStart Monthsetting · 1startDateStart Datesetting · 1endYearEnd Yearsetting · 2099endMonthEnd Monthsetting · 1endDateEnd Datesetting · 1emaEMA Lengthsetting · 100osOverbought Levelsetting · 20obOversold Levelsetting · 94rsiRSI→ rsicumRSIcumRSIvalueInDateRangeInDateRangeconditionTrendisLongTrendisLongconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeclose_all:close_all strategy.close_allplot:16plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longta.crossover(cumRSI, os) and TrendisLongOn27
Close Longta.crossover(cumRSI, ob)On28
Open Long longta.crossover(cumRSI, os)On30
Close Longta.crossover(cumRSI, ob)On31
Close (not InDateRange)On33

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 1D+15.9%+102.5%560%1.2751.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−11.6%+5.5%367%0.3928.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−30.7%+9.8%540%0.5465.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+15.3%+8.4%667%1.6537.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+80.8%+16.7%863%1.4169.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+13.4%+21.5%475%1.7536.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+38.0%+148.3%683%1.5650.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+17.0%+17.1%580%3.2417.3%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 market475%$16,791.90
Sideways market10%−$12,823.20
Falling market0—$0.00

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

How bad could the drawdown be?

34.5%

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

0%40%
All 5 trades
SideEntryExitBarsP&L
long3 May 2024 62,882.0011 Nov 2024 88,648.00192$11,268.10
long24 Dec 2024 98,663.6023 Apr 2025 93,691.10120−$2,010.66
long1 Jun 2025 105,643.0013 Jul 2025 119,087.0042$4,795.41
long4 Aug 2025 115,055.004 Oct 2025 122,391.0061$2,739.03
long19 Oct 2025 108,643.0021 Aug 2026 78,338.00306−$12,823.20

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
Cumulative RSI Strategy this page—v5 strategy+15.9%551.5%
Triple RSI strategy by Trade_by_DBrsiv5 strategy+3.2%23.3%
Hobbiecode - RSI + Close previous day by hobbiecodersiv5 strategy+1.2%634.2%
dirt cheap yet elegant RSI Strategy by SparkyFlaryrsiv4 strategy−11.4%820.5%
RSI Classic Strategy (by Coinrule) by Coinrulersiv4 strategy+7.5%67.2%
RSITrendStrategy by email_analystsrsiv4 strategy+69.2%2238.6%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 4 strategy calls use the when = argument (line 27, 28, 30, 31). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 5 settings use the untyped input() (line 7, 10, 11, 13, 14). 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 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 7: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 13: input() → input.bool()
  • Line 14: input() → input.int()
  • Line 27: when = ta.crossover(cumRSI, os) and TrendisLong → if block
3 more edits
  • Line 28: when = ta.crossover(cumRSI, ob) → if block
  • Line 30: when = ta.crossover(cumRSI, os) → if block
  • Line 31: when = ta.crossover(cumRSI, ob) → if block
⋯rlen  = input.int(title="RSI Length", defval=3, minval=1)-cumlen = input(3, "RSI Cumulation Length")+cumlen = input.int(3, "RSI Cumulation Length")rsi = ta.rsi(close, rlen)cumRSI = math.sum(rsi, cumlen)-ob = (100*cumlen*input(94, "Oversold Level")*.01)+ob = (100*cumlen*input.int(94, "Oversold Level")*.01)-os = (100*cumlen*input(20, "Overbought Level")*.01)+os = (100*cumlen*input.int(20, "Overbought Level")*.01)// Operational Function //-TrendFilterInput = input(false, "Only Trade When Price is Above EMA?")+TrendFilterInput = input.bool(false, "Only Trade When Price is Above EMA?")-ema = ta.ema(close, input(100, "EMA Length"))+ema = ta.ema(close, input.int(100, "EMA Length"))TrendisLong = (close>ema)⋯if (InDateRange and TrendFilterInput==true)-    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os) and TrendisLong, comment="Buy", alert_message="buy")+    if ta.crossover(cumRSI, os) and TrendisLong+        strategy.entry("Long", strategy.long, comment="Buy", alert_message="buy")-    strategy.close("Long", when = ta.crossover(cumRSI, ob) , comment="Sell", alert_message="Sell")+    if ta.crossover(cumRSI, ob)+        strategy.close("Long" , comment="Sell", alert_message="Sell")if (InDateRange and TrendFilterInput==false)-    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os), comment="Buy", alert_message="buy")+    if ta.crossover(cumRSI, os)+        strategy.entry("Long", strategy.long, comment="Buy", alert_message="buy")-    strategy.close("Long", when = ta.crossover(cumRSI, ob), comment="Sell", alert_message="sell")+    if ta.crossover(cumRSI, ob)+        strategy.close("Long", comment="Sell", alert_message="sell")if (not InDateRange)⋯

Does it run in Pine Script v6?

Yes

Same 5 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-// @version=5+// @version=6// Author = TradeAutomation⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 13 msYes 1,000 bars in 31 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/// @version=5// Author = TradeAutomationstrategy(title="Cumulative RSI Strategy", shorttitle="CRSI Strategy", process_orders_on_close=true, overlay=true, commission_type=strategy.commission.cash_per_contract, commission_value=.0035, slippage = 1, margin_long = 75, initial_capital = 25000, default_qty_type=strategy.percent_of_equity, default_qty_value=110)// Cumulative RSI Indicator Calculations //rlen  = input.int(title="RSI Length", defval=3, minval=1)cumlen = input(3, "RSI Cumulation Length")rsi = ta.rsi(close, rlen)cumRSI = math.sum(rsi, cumlen)ob = (100*cumlen*input(94, "Oversold Level")*.01)os = (100*cumlen*input(20, "Overbought Level")*.01)// Operational Function //TrendFilterInput = input(false, "Only Trade When Price is Above EMA?")ema = ta.ema(close, input(100, "EMA Length"))TrendisLong = (close>ema)plot(ema)// Backtest Timeframe Inputs // startDate = input.int(title="Start Date", defval=1, minval=1, maxval=31)startMonth = input.int(title="Start Month", defval=1, minval=1, maxval=12)startYear = input.int(title="Start Year", defval=2010, minval=1950, maxval=2100)endDate = input.int(title="End Date", defval=1, minval=1, maxval=31)endMonth = input.int(title="End Month", defval=1, minval=1, maxval=12)endYear = input.int(title="End Year", defval=2099, minval=1950, maxval=2100)InDateRange = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))// Buy and Sell Functions //if (InDateRange and TrendFilterInput==true)    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os) and TrendisLong, comment="Buy", alert_message="buy")    strategy.close("Long", when = ta.crossover(cumRSI, ob) , comment="Sell", alert_message="Sell")if (InDateRange and TrendFilterInput==false)    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os), comment="Buy", alert_message="buy")    strategy.close("Long", when = ta.crossover(cumRSI, ob), comment="Sell", alert_message="sell")if (not InDateRange)    strategy.close_all()