Pine Script v5 · Strategy
SRJ RSI Outperformer Strategy
A Pine Script v5 strategy built on RSI (close, 14) and SMA (rsi1, 14). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 6 settings; defaults include Length Of Fast RSI 14, Length Of Slow RSI 28 and Length Of Moving Average 14.
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 SRJ RSI Outperformer Strategy 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 SRJ RSI Outperformer Strategy do on BTCUSDT 1D with default settings?
- +0.64%
- From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does SRJ RSI Outperformer 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: 8 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.
- Does SRJ RSI Outperformer Strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 27.
- Does SRJ RSI Outperformer Strategy run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 20 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- SMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.64%
- $6,396.54
- Buy and hold
- +102.5%
- same period
- Closed trades
- 8
- 2 won · 6 lost
- Profitable
- 25.0%
- of closed trades
- Profit factor
- 1.23
- gross profit ÷ gross loss
- Max drawdown
- 2.44%
- −$24,964.90
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 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Length Of Fast RSI | 14 | int · min 1 | rsi1 |
| Length Of Slow RSI | 28 | int · min 1 | rsi2 |
| Length Of Moving Average | 14 | int · min 1 | ma1 ma2 |
| Length Of Deciding Moving Average | 100 | int · min 1 | longcondition exitcondition |
| Target Profit Percentage | 20 | int · min 1 | exit Long Exit |
| Stoploss Percentage | 10 | int · min 1 | exit Long Exit |
What it calculates
- RSIclose, Length Of Fast RSI (14)
rsi1 · line 11 - RSIclose, Length Of Slow RSI (28)
rsi2 · line 12 - SMArsi1, Length Of Moving Average (14)
ma1 · line 15 - SMAdivergence2, Length Of Moving Average (14)
ma2 · line 16
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 Entry long | (longcondition) | On | 23 |
| Exit Long Exit stop and limit | (exitcondition) | On | 27 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +0.6% | +102.5% | 8 | 25% | 1.23 | 2.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.8% | +5.5% | 9 | 33% | 2.07 | 0.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.2% | +9.8% | 6 | 67% | 4.50 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.0% | +8.4% | 12 | 33% | 2.11 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +0.0% | +16.7% | 7 | 43% | 1.48 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 8 | 38% | 2.68 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.0% | +148.3% | 8 | 50% | 3.30 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 12 | 42% | 1.87 | 0.0% | 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 | 25% | −$10,197.00 |
| Sideways market | 4 | 25% | $16,593.50 |
| 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?
2.7%
The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 1.3% to 2.7%; the tick is what actually happened, 1.6%. Order luck alone moves it this much.
All 8 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 21 May 2024 71,446.60 | 15 Jun 2024 66,044.00 | 25 | −$5,402.63 |
| long | 24 Aug 2024 64,037.20 | 27 Aug 2024 62,834.00 | 3 | −$1,203.24 |
| long | 16 Oct 2024 67,074.10 | 6 Dec 2024 96,945.60 | 51 | $29,871.50 |
| long | 24 Jan 2025 103,910.00 | 3 Feb 2025 97,700.60 | 10 | −$6,209.76 |
| long | 7 Jul 2025 109,204.00 | 2 Aug 2025 113,298.00 | 26 | $4,094.07 |
| long | 15 Sep 2025 115,268.00 | 23 Sep 2025 112,651.00 | 8 | −$2,617.02 |
| long | 4 Oct 2025 122,232.00 | 11 Oct 2025 112,774.00 | 7 | −$9,457.72 |
| long | 27 Sep 2026 84,433.10 | 9 Oct 2026 81,754.50 | 12 | −$2,678.65 |
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 |
|---|---|---|---|---|---|
| SRJ RSI Outperformer Strategy this page | — | v5 strategy | +0.6% | 8 | 2.4% |
| RSI SMA Crossover Strategy by reees | rsi sma | v5 strategy | +39.8% | 42 | 30.8% |
| Short In Downtrend Below MA100 (Coinrule) by Coinrule | sma rsi | v4 strategy | −34.5% | 99 | 45.4% |
| Simple RSI and SMA Long and Short (by Coinrule) by Coinrule | rsi sma | v5 strategy | −3.0% | 2 | 17.7% |
| Maximized Moving Average Crossing (by Coinrule) by Coinrule | sma rsi | v4 strategy | −6.6% | 9 | 13.3% |
| RSI Mean Reversion Strategy by Zeal Terminal | rsi sma | v5 strategy | +2.2% | 16 | 1.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.
- No v6-only features. v6 is not needed to run this script.
Clean v5
VerifiedNothing to change.
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: 8 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.
⋯// © Sapt_Jash-//@version=5+//@version=6strategy("SRJ RSI Outperformer Strategy", overlay=true)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | Yes 1,000 bars in 20 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/// © Sapt_Jash//@version=5strategy("SRJ RSI Outperformer Strategy", overlay=true)srcperiod1 = input.int(14, minval=1, title="Length Of Fast RSI")srcperiod2 = input.int(28, minval=1, title="Length Of Slow RSI")srcperiod3 = input.int(14, minval=1, title="Length Of Moving Average")srcperiod4 = input.int(100, minval=1, title="Length Of Deciding Moving Average")srcperiod5 = input.int(20, minval=1, title="Target Profit Percentage")srcperiod6 = input.int(10, minval=1, title="Stoploss Percentage")rsi1 = ta.rsi(close, srcperiod1)rsi2 = ta.rsi(close, srcperiod2)divergence1 = (rsi2/rsi1)divergence2 = (rsi1/divergence1)ma1 = ta.sma(rsi1, srcperiod3)ma2 = ta.sma(divergence2, srcperiod3)//Long Conditions//longcondition = (ta.crossover(ma2, ma1) and (close > ta.sma(close, srcperiod4))) //Exit onditions//exitcondition = (ta.crossunder(ma2, ma1) or (ta.crossunder(close, ta.sma(close, srcperiod4))))if (longcondition) strategy.entry("Long Entry", strategy.long) if (exitcondition) strategy.exit("Long Exit", profit = close * (1+(srcperiod5/100)), loss = close * (1-(srcperiod6/100)))