Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Short Term RSI and SMA Percentage Change

A Pine Script v5 strategy built on RSI (close, 14) and SMA (close, 9). 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 commits 100% of equity and pays 0.1% commission. 4 settings; defaults include Length 14, Trail Long Loss (%) 5 and Trail Short Loss (%) 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 Short Term RSI and SMA Percentage Change repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
How did Short Term RSI and SMA Percentage Change do on BTCUSDT 1D with default settings?
−1.39%
From 26 Jan 2024 to 21 Oct 2026, over 32 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Short Term RSI and SMA Percentage Change 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: 32 before, 32 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 Short Term RSI and SMA Percentage Change use a stop loss?
Yes
strategy.exit sets a stop on line 49.
Does Short Term RSI and SMA Percentage Change run in Zeal Terminal?
Yes
It compiles in 22 ms and runs 1,000 bars in 61 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • 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 (4)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,011$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
−1.39%
−$13.92
Buy and hold
+102.5%
same period
Closed trades
32
12 won · 20 lost
Profitable
37.5%
of closed trades
Profit factor
0.98
gross profit ÷ gross loss
Max drawdown
29.21%
−$309.12

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long 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

    “Show Date Range” is declared but never read.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    1 setting has no label

    In the settings dialog length (line 17) shows 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.

Settings

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

SettingDefaultType and rangeFeeds
Show Date Rangetrueboolunused
Length (no label in the script)14intrsi
Trail Long Loss (%)5float · min 0.0 · step 0.1longStopPrice stopValue
Trail Short Loss (%)5float · min 0.0 · step 0.1shortStopPrice stopValue

What it calculates

  • RSIclose, Length (14)rsi · line 18
  • SMAclose, 9SMA9 · line 21
  • SMAclose, 100SMA100 · line 22

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 datalengthLengthsetting · 14shortTrailPercTrail Short Loss (%)setting · 5timetimeprice datalongTrailPercTrail Long Loss (%)setting · 5rsiRSI→ rsiSMA9SMA→ SMA9SMA100SMA→ SMA100buyMAbuyMAvaluestopValuestopValuevaluetimePeriodtimePeriodconditionbuyCondition1buyCondition1conditionbuyCondition2buyCondition2conditionbuyCondition3buyCondition3conditionnotInTradenotInTradeconditionlongStopPricelongStopPriceconditionshortStopPriceshortStopPriceconditionentry:LongOpen Longstrategy.entryexit:Exitexit Exitstrategy.exitplot:23plotplotplot:24plotplot

Order rules

OrderFires whenBy defaultLine
Open Long long(buyCondition1 and buyCondition2 and buyCondition3 and timePeriod)On30
Exit Exit stop and limitevery barOn49

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.

3/3trades 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 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−1.4%+102.5%3238%0.9829.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+9.2%+5.5%650%1.9511.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+89.4%+9.8%3644%1.8917.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+6.1%+8.4%1136%1.2311.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−28.1%+16.7%5836%0.8245.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.9%+21.5%1741%1.0217.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+29.4%+148.3%3834%1.3033.6%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.6%+17.1%1136%1.1117.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 market1644%−$66.59
Sideways market1631%$53.66
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?

42.4%

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

0%49%
All 32 trades
SideEntryExitBarsP&L
long5 May 2024 64,012.0023 May 2024 67,874.3018$58.22
long23 May 2024 67,969.6011 Jun 2024 67,552.6019−$8.59
long12 Jun 2024 68,264.0021 Jun 2024 63,434.309−$76.21
long21 Jul 2024 68,165.3025 Jul 2024 64,155.404−$59.09
long25 Jul 2024 65,799.9031 Jul 2024 64,837.406−$15.18
long1 Aug 2024 65,354.004 Aug 2024 58,423.403−$96.96
long22 Sep 2024 63,578.801 Oct 2024 62,565.109−$14.37
long4 Oct 2024 62,086.0010 Oct 2024 59,678.906−$32.06
long11 Oct 2024 62,540.0023 Oct 2024 65,580.4012$35.16
long23 Oct 2024 66,668.601 Nov 2024 69,099.609$27.20
long1 Nov 2024 69,496.0025 Nov 2024 93,947.4024$285.64
long25 Nov 2024 93,010.005 Dec 2024 93,657.9010$5.47
long5 Dec 2024 96,945.609 Dec 2024 96,054.104−$12.40
long9 Dec 2024 97,276.5018 Dec 2024 100,827.009$37.76
long18 Dec 2024 100,204.0020 Dec 2024 92,588.802−$88.32
long20 Dec 2024 97,805.4027 Dec 2024 94,458.107−$37.83
long2 Jan 2025 96,984.807 Jan 2025 97,123.805−$0.57
long14 Jan 2025 96,560.9027 Jan 2025 100,837.0013$42.53
long27 Jan 2025 102,083.002 Feb 2025 99,486.806−$28.76
long3 Feb 2025 101,329.0024 Feb 2025 93,389.8021−$81.92
long27 Apr 2025 93,749.3029 May 2025 106,111.0032$121.79
long29 May 2025 105,590.005 Jun 2025 100,565.007−$52.53
long6 Jun 2025 104,288.0013 Jun 2025 104,761.007$2.54
long13 Jun 2025 106,067.0021 Jun 2025 101,455.008−$45.91
long23 Jun 2025 105,334.001 Aug 2025 113,957.0039$76.96
long7 Aug 2025 117,472.0015 Aug 2025 117,141.008−$5.01
long15 Aug 2025 117,342.0024 Aug 2025 111,535.009−$53.32
long12 Sep 2025 116,029.0024 Sep 2025 111,220.0012−$42.68
long3 Oct 2025 122,232.0010 Oct 2025 118,426.007−$31.14
long20 Apr 2026 75,841.0016 May 2026 78,099.6026$25.24
long21 Aug 2026 78,338.0010 Sep 2026 77,206.9020−$15.35
long10 Sep 2026 76,568.708 Oct 2026 82,289.0028$66.78

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
Short Term RSI and SMA Percentage Change this page—v5 strategy−1.4%3229.2%
SRJ RSI Outperformer Strategy by Sapt_Jashrsi smav5 strategy+0.6%82.4%
RSI SMA Crossover Strategy by reeesrsi smav5 strategy+39.8%4230.8%
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%

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 12, 17). 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 32 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 12: input() → input.bool()
  • Line 17: input() → input.int()
⋯         commission_value=0.1)-showDate = input(defval=true, title='Show Date Range')+showDate = input.bool(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2022, 5, 1, 0, 0)⋯//RSI-length = input(14)+length = input.int(14)rsi = ta.rsi(close, length)⋯

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

⋯// © Coinrule-//@version=5+//@version=6strategy("Short Term RSI and SMA Percentage Change",⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 22 msYes 1,000 bars in 61 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/// © Coinrule//@version=5strategy("Short Term RSI and SMA Percentage Change",         overlay=true,         initial_capital=1000,         process_orders_on_close=true,         default_qty_type=strategy.percent_of_equity,         default_qty_value=100,         commission_type=strategy.commission.percent,         commission_value=0.1)showDate = input(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2022, 5, 1, 0, 0)notInTrade = strategy.position_size <= 0//==================================Buy Conditions============================================//RSIlength = input(14)rsi = ta.rsi(close, length)buyCondition1 = rsi > 50//MASMA9 = ta.sma(close, 9)SMA100 = ta.sma(close, 100)plot(SMA9, color = color.green)plot(SMA100, color = color.blue)buyCondition2 = (SMA9 > SMA100)//Calculating MA Percentage ChangebuyMA = (close/SMA9)buyCondition3 = buyMA >= 0.06if (buyCondition1 and buyCondition2 and buyCondition3 and timePeriod) //and buyCondition    strategy.entry("Long", strategy.long)//==================================Sell Conditions============================================// Configure trail stop level with input optionslongTrailPerc = input.float(title='Trail Long Loss (%)', minval=0.0, step=0.1, defval=5) * 0.01shortTrailPerc = input.float(title='Trail Short Loss (%)', minval=0.0, step=0.1, defval=5) * 0.01// Determine trail stop loss priceslongStopPrice = 0.0shortStopPrice = 0.0longStopPrice := if strategy.position_size > 0    stopValue = close * (1 - longTrailPerc)    math.max(stopValue, longStopPrice[1])else    0shortStopPrice := if strategy.position_size < 0    stopValue = close * (1 + shortTrailPerc)    math.min(stopValue, shortStopPrice[1])else    999999    strategy.exit('Exit', stop = longStopPrice, limit = shortStopPrice)