Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Simple RSI and SMA Long and Short (by Coinrule)

A Pine Script v5 strategy built on RSI (close, 14) and SMA (close, 100). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 30% of equity and pays 0.1% commission. 2 settings; defaults include Length 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 Simple RSI and SMA Long and Short (by Coinrule) repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Simple RSI and SMA Long and Short (by Coinrule) do on BTCUSDT 1D with default settings?
−3.01%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Simple RSI and SMA Long and Short (by Coinrule) run in Pine Script v6?
Yes
Same 2 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 Simple RSI and SMA Long and Short (by Coinrule) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Simple RSI and SMA Long and Short (by Coinrule) run in Zeal Terminal?
Yes
It compiles in 9 ms and runs 1,000 bars in 39 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$970$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
−3.01%
−$30.15
Buy and hold
+102.5%
same period
Closed trades
2
0 won · 2 lost
Profitable
0.0%
of closed trades
Profit factor
0.00
gross profit ÷ gross loss
Max drawdown
17.69%
−$176.92

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

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • 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.

  • Note

    Uses an argument v6 removed

    when = on line 26, 27, 28, 29. 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
Show Date Rangetrueboolunused
Length (no label in the script)14intrsi

What it calculates

  • RSIclose, Length (14)rsi · line 18
  • SMAclose, 100fastEMA · line 20
  • SMAclose, 150slowEMA · line 21

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 · 14timetimeprice datarsiRSI→ rsifastEMASMA→ fastEMAslowEMASMA→ slowEMAbullishbullishconditionbearishbearishconditiontimePeriodtimePeriodconditionnotInTradenotInTradeconditionentry:LongOpen Longstrategy.entryclose:ExitClose Exitstrategy.closeentry:ShortOpen Shortstrategy.entryplot:22plotplotplot:23plotplot

Order rules

OrderFires whenBy defaultLine
Open Long longbullish and timePeriodOn26
Close Exitbearishta.crossover(slowEMA, fastEMA) and rsi < 50On27
Open Short shortbearish and timePeriodOn28
Close Exitbullishta.crossover(fastEMA, slowEMA) and rsi > 50On29

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−3.0%+102.5%20%0.0017.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.6%+5.5%333%0.894.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−33.2%+9.8%540%0.0738.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−2.8%+8.4%250%0.253.8%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−27.1%+16.7%617%0.1233.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+12.3%+21.5%1100%366.870.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−14.5%+148.3%30%0.0042.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+8.7%+17.1%1100%266.851.4%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 market10%−$21.31
Sideways market10%−$8.55
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?

3.0%

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

0%3%
All 2 trades
SideEntryExitBarsP&L
long11 Nov 2024 88,648.002 Apr 2025 82,516.30142−$21.31
short2 Apr 2025 82,516.303 Oct 2026 84,753.60549−$8.55

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
Simple RSI and SMA Long and Short (by Coinrule) this page—v5 strategy−3.0%217.7%
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%
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.

  • 4 strategy calls use the when = argument (line 26, 27, 28, 29). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • 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 2 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()
  • Line 26: when = bullish and timePeriod → if block
  • Line 27: when = bearish → if block
  • Line 28: when = bearish and timePeriod → if block
  • Line 29: when = bullish → if block
⋯         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, 1, 1, 0, 0)⋯//RSI-length = input(14)+length = input.int(14)rsi = ta.rsi(close, length)⋯bearish = ta.crossover(slowEMA, fastEMA) and rsi < 50-strategy.entry("Long", strategy.long, when=bullish and timePeriod)+if bullish and timePeriod+    strategy.entry("Long", strategy.long)-strategy.close("Exit", when=bearish)+if bearish+    strategy.close("Exit")-strategy.entry("Short", strategy.short, when=bearish and timePeriod)+if bearish and timePeriod+    strategy.entry("Short", strategy.short)-strategy.close("Exit", when=bullish)+if bullish+    strategy.close("Exit")

Does it run in Pine Script v6?

Yes

Same 2 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

⋯// © Coinrule-//@version=5+//@version=6strategy('RSI and SMA',⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 9 msYes 1,000 bars in 39 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('RSI and SMA',         overlay=true,         initial_capital=1000,         process_orders_on_close=true,         default_qty_type=strategy.percent_of_equity,         default_qty_value=30,         commission_type=strategy.commission.percent,         commission_value=0.1)showDate = input(defval=true, title='Show Date Range')timePeriod = time >= timestamp(syminfo.timezone, 2022, 1, 1, 0, 0)notInTrade = strategy.position_size <= 0//==================================Buy Conditions============================================//RSIlength = input(14)rsi = ta.rsi(close, length)//SMAfastEMA = ta.sma(close, 100)slowEMA = ta.sma(close, 150)plot(fastEMA, color = color.green)plot(slowEMA, color = color.blue)bullish = ta.crossover(fastEMA, slowEMA) and rsi > 50bearish = ta.crossover(slowEMA, fastEMA) and rsi < 50strategy.entry("Long", strategy.long, when=bullish and timePeriod)strategy.close("Exit", when=bearish)strategy.entry("Short", strategy.short, when=bearish and timePeriod)strategy.close("Exit", when=bullish)