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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| RSI Length | 3 | int · min 1 | rsi |
| RSI Cumulation Length | 3 | int | cumRSI ob os |
| Oversold Level | 94 | int | close Long |
| Overbought Level | 20 | int | entry Long |
| Only Trade When Price is Above EMA? | false | bool | entry Long close Long entry Long close Long line 26 line 29 |
| EMA Length | 100 | int | TrendisLong plot |
| Start Date | 1 | int · min 1 · max 31 | InDateRange |
| Start Month | 1 | int · min 1 · max 12 | InDateRange |
| Start Year | 2010 | int · min 1950 · max 2100 | InDateRange |
| End Date | 1 | int · min 1 · max 31 | InDateRange |
| End Month | 1 | int · min 1 · max 12 | InDateRange |
| End Year | 2099 | int · min 1950 · max 2100 | InDateRange |
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | ta.crossover(cumRSI, os) and TrendisLong | On | 27 |
| Close Long | ta.crossover(cumRSI, ob) | On | 28 |
| Open Long long | ta.crossover(cumRSI, os) | On | 30 |
| Close Long | ta.crossover(cumRSI, ob) | On | 31 |
| Close | (not InDateRange) | On | 33 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +15.9% | +102.5% | 5 | 60% | 1.27 | 51.5% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −11.6% | +5.5% | 3 | 67% | 0.39 | 28.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −30.7% | +9.8% | 5 | 40% | 0.54 | 65.5% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +15.3% | +8.4% | 6 | 67% | 1.65 | 37.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +80.8% | +16.7% | 8 | 63% | 1.41 | 69.2% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +13.4% | +21.5% | 4 | 75% | 1.75 | 36.5% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +38.0% | +148.3% | 6 | 83% | 1.56 | 50.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +17.0% | +17.1% | 5 | 80% | 3.24 | 17.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 4 | 75% | $16,791.90 |
| Sideways market | 1 | 0% | −$12,823.20 |
| Falling market | 0 | — | $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.
All 5 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 3 May 2024 62,882.00 | 11 Nov 2024 88,648.00 | 192 | $11,268.10 |
| long | 24 Dec 2024 98,663.60 | 23 Apr 2025 93,691.10 | 120 | −$2,010.66 |
| long | 1 Jun 2025 105,643.00 | 13 Jul 2025 119,087.00 | 42 | $4,795.41 |
| long | 4 Aug 2025 115,055.00 | 4 Oct 2025 122,391.00 | 61 | $2,739.03 |
| long | 19 Oct 2025 108,643.00 | 21 Aug 2026 78,338.00 | 306 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Cumulative RSI Strategy this page | — | v5 strategy | +15.9% | 5 | 51.5% |
| Triple RSI strategy by Trade_by_DB | rsi | v5 strategy | +3.2% | 2 | 3.3% |
| Hobbiecode - RSI + Close previous day by hobbiecode | rsi | v5 strategy | +1.2% | 63 | 4.2% |
| dirt cheap yet elegant RSI Strategy by SparkyFlary | rsi | v4 strategy | −11.4% | 8 | 20.5% |
| RSI Classic Strategy (by Coinrule) by Coinrule | rsi | v4 strategy | +7.5% | 6 | 7.2% |
| RSITrendStrategy by email_analysts | rsi | v4 strategy | +69.2% | 22 | 38.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.
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.
// 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 31 ms | Not measured |
| PineTS | Not tested | Not tested | 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.
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()