Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

RSI SMA Crossover Strategy

A Pine Script v5 strategy built on RSI (close, 50), SMA (rsi, 25) and Crossover (rsi, sma). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays no commission. 2 settings; defaults include RSI Length 50 and SMA Length 25.

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 SMA Crossover Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did RSI SMA Crossover Strategy do on BTCUSDT 1D with default settings?
+39.79%
From 26 Jan 2024 to 21 Oct 2026, over 42 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does RSI SMA Crossover 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: 42 before, 28 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 RSI SMA Crossover Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI SMA Crossover Strategy run in Zeal Terminal?
Yes
It compiles in 9 ms and runs 1,000 bars in 59 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI
  • SMA
  • Oversold level
  • Overbought level
  • 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI$1,398$2,025Equity from $1,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
+39.79%
$397.92
Buy and hold
+102.5%
same period
Closed trades
42
14 won · 28 lost
Profitable
33.3%
of closed trades
Profit factor
1.50
gross profit ÷ gross loss
Max drawdown
30.75%
−$405.26

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

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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
RSI Length50intrsi
SMA Length25intsma

What it calculates

  • RSIclose, RSI Length (50)rsi · line 11
  • SMArsi, SMA Length (25)sma · line 12
  • Crossoverrsi, smabuy · line 22
  • Crossunderrsi, smasell · line 23

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 datarsiLengthRSI Lengthsetting · 50smaLengthSMA Lengthsetting · 25rsiRSI→ rsismaSMA→ smabuyCrossover→ buysellCrossunder→ sellplotColor, fillColorColourplotColor · fillColorentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeplot:15RSIplotplot:16SMAplotfill:18Fillfillhline:19Oversold levelhlinehline:20Overbought levelhline

Order rules

OrderFires whenBy defaultLine
Open Long longbuy == trueOn25
Close Longsell == trueOn27

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

12/12trades 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. On 0 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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+39.8%+102.5%4233%1.5030.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+9.8%+5.5%4023%1.3110.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+30.3%+9.8%5229%1.2053.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+7.5%+8.4%5516%1.1415.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−11.8%+16.7%5129%0.9249.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+26.3%+21.5%4719%1.5215.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−22.6%+148.3%5125%0.7238.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+5.3%+17.1%5525%1.1510.8%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 market1250%$252.21
Sideways market1833%$1.83
Falling market1217%$143.88

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

How bad could the drawdown be?

34.2%

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

0%39%
All 42 trades
SideEntryExitBarsP&L
long16 May 2024 66,206.501 Jun 2024 67,540.0016$20.14
long4 Jun 2024 68,809.908 Jun 2024 69,355.604$8.09
long15 Jul 2024 60,797.903 Aug 2024 61,498.3019$11.85
long22 Aug 2024 61,156.0029 Aug 2024 59,034.907−$36.07
long13 Sep 2024 58,132.302 Oct 2024 60,804.9019$46.16
long7 Oct 2024 62,819.908 Oct 2024 62,224.001−$9.96
long13 Oct 2024 63,206.2014 Oct 2024 62,870.001−$5.53
long15 Oct 2024 66,084.004 Nov 2024 68,776.0020$42.15
long7 Nov 2024 75,572.0027 Nov 2024 91,965.2020$233.58
long28 Nov 2024 95,863.101 Dec 2024 96,408.003$7.45
long16 Dec 2024 104,464.0019 Dec 2024 100,204.003−$53.74
long7 Jan 2025 102,236.008 Jan 2025 96,954.601−$65.30
long16 Jan 2025 100,497.0027 Jan 2025 102,620.0011$25.32
long30 Jan 2025 103,733.001 Feb 2025 102,430.002−$15.38
long3 Mar 2025 94,270.004 Mar 2025 86,221.201−$103.20
long20 Mar 2025 86,845.9030 Mar 2025 82,648.5010−$53.43
long2 Apr 2025 85,158.403 Apr 2025 82,516.301−$32.64
long4 Apr 2025 83,213.107 Apr 2025 78,430.003−$58.60
long10 Apr 2025 82,615.2011 Apr 2025 79,607.301−$34.98
long12 Apr 2025 83,423.8030 May 2025 105,590.0048$246.01
long10 Jun 2025 110,263.0012 Jun 2025 108,645.002−$17.20
long26 Jun 2025 107,341.001 Jul 2025 107,147.005−$2.09
long3 Jul 2025 108,850.0029 Jul 2025 118,062.0026$97.55
long11 Aug 2025 119,294.0012 Aug 2025 118,686.001−$6.37
long13 Aug 2025 120,134.0015 Aug 2025 118,295.002−$19.04
long11 Sep 2025 113,960.0023 Sep 2025 112,651.0012−$14.07
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$16.28
long3 Dec 2025 91,277.9016 Dec 2025 86,432.1013−$63.41
long17 Dec 2025 87,863.4018 Dec 2025 86,243.201−$20.86
long20 Dec 2025 88,136.9026 Dec 2025 87,225.306−$11.48
long28 Dec 2025 87,877.0030 Dec 2025 87,237.102−$8.00
long31 Dec 2025 88,485.5021 Jan 2026 88,427.7021−$0.71
long22 Feb 2026 67,975.9024 Feb 2026 64,656.002−$53.23
long26 Feb 2026 67,988.0028 Mar 2026 66,407.3030−$24.10
long1 Apr 2026 68,284.503 Apr 2026 66,902.002−$20.50
long6 Apr 2026 69,034.2016 May 2026 79,113.2040$144.85
long21 Jun 2026 64,298.0022 Jun 2026 63,312.001−$17.44
long23 Jun 2026 64,020.0024 Jun 2026 62,734.601−$22.48
long3 Jul 2026 61,560.001 Aug 2026 62,887.9029$23.66
long5 Aug 2026 64,106.6011 Aug 2026 63,970.006−$2.39
long18 Aug 2026 64,532.1010 Sep 2026 78,306.4023$238.70
long19 Sep 2026 80,883.908 Oct 2026 83,321.8019$40.90

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 SMA Crossover Strategy this page—v5 strategy+39.8%4230.8%
SRJ RSI Outperformer Strategy by Sapt_Jashrsi smav5 strategy+0.6%82.4%
Short In Downtrend Below MA100 (Coinrule) by Coinrulesma rsiv4 strategy−34.5%9945.4%
Simple RSI and SMA Long and Short (by Coinrule) by Coinrulersi smav5 strategy−3.0%217.7%
Maximized Moving Average Crossing (by Coinrule) by Coinrulesma rsiv4 strategy−6.6%913.3%
RSI Mean Reversion Strategy by Zeal Terminalrsi smav5 strategy+2.2%161.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.

  • 2 settings use the untyped input() (line 8, 9). 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 42 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
⋯// inputs-rsiLength = input(title='RSI Length', defval=50)+rsiLength = input.int(title='RSI Length', defval=50)-smaLength = input(title='SMA Length', defval=25)+smaLength = input.int(title='SMA Length', defval=25)// data/series⋯

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

⋯//-//@version=5+//@version=6//⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msYes 1,000 bars in 59 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/// © reees////@version=5//strategy('RSI Crossover Strategy', shorttitle='RSI Cross', default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=1000, calc_on_every_tick=true)// inputsrsiLength = input(title='RSI Length', defval=50)smaLength = input(title='SMA Length', defval=25)// data/seriesrsi = ta.rsi(close, rsiLength)sma = ta.sma(rsi, smaLength)// plotplotColor = rsi > sma ? color.green : color.redrsiPlot = plot(rsi, color=color.new(plotColor, 0), title='RSI')smaPlot = plot(sma, color=color.new(color.black, 0), title='SMA')fillColor = rsi > sma ? color.lime : color.redfill(rsiPlot, smaPlot, color=color.new(fillColor, 75))oversoldLine = hline(30, title='Oversold level')overboughtLine = hline(70, title='Overbought level')// strategybuy = ta.crossover(rsi, sma)sell = ta.crossunder(rsi, sma)if buy == true    strategy.entry('Long', strategy.long, comment='Buy')if sell == true    strategy.close('Long', comment='Sell')