Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Reinforced RSI - The Quant Science

A Pine Script v5 strategy built on RSI (close, 14), Crossunder (rsi, 35) and Crossover (rsi, 75). It has 3 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.07% commission. 6 settings; defaults include RSI lenght: 14, Oversold: 35 and Overbought: 75.

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 Reinforced RSI - The Quant Science repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did Reinforced RSI - The Quant Science do on BTCUSDT 1D with default settings?
−3.94%
From 26 Jan 2024 to 21 Oct 2026, over 7 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Reinforced RSI - The Quant Science run in Pine Script v6?
Yes
Same 7 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 Reinforced RSI - The Quant Science use a stop loss?
Yes
strategy.exit sets a stop on line 67.
Does Reinforced RSI - The Quant Science run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 173 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$961$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 60) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
−3.94%
−$39.38
Buy and hold
+102.5%
same period
Closed trades
7
2 won · 5 lost
Profitable
28.6%
of closed trades
Profit factor
0.30
gross profit ÷ gross loss
Max drawdown
3.94%
−$39.38

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

    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 lenght: 14int · min 1rsi
Oversold: 35int · min 1trigger
Overbought: 75int · min 1exit
Lookback period: 30int · min 0 · max 500probabilities
Take profit: 1.00float · min 0takeprofit
Stop loss: 1.00float · min 0stoploss

What it calculates

  • RSIclose, length = RSI lenght: (14)rsi · line 14
  • Crossunderrsi, Oversold: (35)trigger · line 17
  • Crossoverrsi, Overbought: (75)exit · line 18
  • ValuewhenLONG, close, 0p · line 33
  • ValuewhenCLOSE_LONG_TP, close, 0p2 · line 34

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 datalenght_rsiRSI lenght: setting · 14rsi_value_check_entryOversold: setting · 35rsi_value_check_exitOverbought: setting · 75lookLookback period: setting · 30tpTake profit: setting · 1.00slStop loss: setting · 1.00rsiRSI→ rsitriggerCrossunder→ triggerexitCrossover→ exitpValuewhen→ pp2Valuewhen→ p2entry_conditionentry_conditionvalueTPcondition_exitTPcondition_exitvalueisActiveLongisActiveLongvalueisSellLongisSellLongvaluepositive_percentage_probabilitiespositive_percentage_pro…valuenegative_percentage_probabilitiesnegative_percentage_pro…valuepositive_relative_probabilities, negative_relative_probabilitiespositive_relative_proba…2 valuesprobabilitiesprobabilitiesvaluelots, e, clots · e +13 valuestakeprofittakeprofitvaluestoplossstoplossvalueLONGLONGconditionCLOSE_LONG_TPCLOSE_LONG_TPconditionentry:eOpen estrategy.entryexit:cexit cstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open e longtrigger==true and strategy.opentrades==0 and probabilities >= 51On60
Exit c limitexit==trueOn65
Exit c stop and limittakeprofit and stoplossOn67

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 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−3.9%+102.5%729%0.303.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.6%+5.5%367%1.502.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−9.0%+9.8%1729%0.319.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.3%+8.4%580%2.951.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1.7%+16.7%540%0.502.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+5.0%+21.5%888%5.291.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.9%+148.3%1354%0.871.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%757%1.002.5%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 market0—$0.00
Sideways market425%−$25.07
Falling market333%−$14.31

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

How bad could the drawdown be?

5.6%

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

0%6%
All 7 trades
SideEntryExitBarsP&L
long24 Jun 2024 63,210.0024 Jun 2024 62,577.900−$11.39
long29 Jun 2024 60,427.8029 Jun 2024 61,032.100$8.50
long5 Jul 2024 57,050.005 Jul 2024 56,479.500−$11.36
long8 Jul 2024 55,857.808 Jul 2024 55,299.200−$11.23
long5 Aug 2024 58,161.005 Aug 2024 57,579.400−$11.10
long7 Sep 2024 53,963.007 Sep 2024 54,502.600$8.28
long9 Apr 2025 76,322.409 Apr 2025 75,559.200−$11.07

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
Reinforced RSI - The Quant Science this page—v5 strategy−3.9%73.9%
RSI+PA+DCA Strategy by A3Shrsi valuewhenv4 strategy+22.3%465.1%
Tendency EMA + RSI [Alorse] by alorsersi valuewhenv5 strategy+4.3%41.9%
Fibonacci + RSI - Strategy by MohamedYAbdelazizrsi valuewhenv4 strategy+3.4%219.2%
Momentum Strategy (BTC-USDT; 30m) - STOCH RSI (with source code) by Drun30rsi valuewhenv4 strategy+13.3%1213.6%
Impulse Strategy Signals V2 by danieljordirsi valuewhenv5 strategyNo trades on this market

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

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

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

⋯// © thequantscience-//@version=5+//@version=6strategy("Reinforced RSI - The Quant Science",⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msWith a workaround 1,000 bars in 173 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 60) so the engine trades the way the script says. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// © thequantscience//@version=5strategy("Reinforced RSI - The Quant Science",     overlay = true,     default_qty_type = strategy.percent_of_equity,      default_qty_value = 100,     pyramiding = 1,     currency = currency.EUR,      initial_capital = 1000,     commission_type = strategy.commission.percent,      commission_value = 0.07)lenght_rsi = input.int(defval = 14, minval = 1, title = "RSI lenght: ")rsi = ta.rsi(close, length = lenght_rsi)rsi_value_check_entry = input.int(defval = 35, minval = 1, title = "Oversold: ")rsi_value_check_exit = input.int(defval = 75, minval = 1, title = "Overbought: ")trigger = ta.crossunder(rsi, rsi_value_check_entry)exit = ta.crossover(rsi, rsi_value_check_exit)entry_condition   = trigger TPcondition_exit  = exitlook = input.int(defval = 30, minval = 0, maxval = 500, title = "Lookback period: ")Probabilities(lookback) =>    isActiveLong = false    isActiveLong := nz(isActiveLong[1], false)    isSellLong = false    isSellLong := nz(isSellLong[1], false)    int positive_results = 0    int negative_results = 0    float positive_percentage_probabilities = 0     float negative_percentage_probabilities = 0     LONG = not isActiveLong and entry_condition == true     CLOSE_LONG_TP = not isSellLong and TPcondition_exit == true    p = ta.valuewhen(LONG, close, 0)    p2 = ta.valuewhen(CLOSE_LONG_TP, close, 0)    for i = 1 to lookback        if (LONG[i])            isActiveLong := true            isSellLong := false        if (CLOSE_LONG_TP[i])            isActiveLong := false            isSellLong := true        if p[i] > p2[i]            positive_results += 1        else             negative_results += 1         positive_relative_probabilities = positive_results / lookback        negative_relative_probabilities = negative_results / lookback        positive_percentage_probabilities := positive_relative_probabilities * 100        negative_percentage_probabilities := negative_relative_probabilities * 100    positive_percentage_probabilities    probabilities = Probabilities(look) lots = strategy.equity/closevar float e = 0 var float c = 0 tp = input.float(defval = 1.00, minval = 0, title = "Take profit: ")sl = input.float(defval = 1.00, minval = 0, title = "Stop loss: ")if trigger==true and strategy.opentrades==0 and probabilities >= 51    e := close    strategy.entry(id = "e", direction = strategy.long, qty = lots, limit = e) takeprofit = e + ((e * tp)/100)stoploss = e - ((e * sl)/100)if exit==true    c := close     strategy.exit(id = "c", from_entry = "e", limit = c)if takeprofit and stoploss     strategy.exit(id = "c", from_entry = "e", stop = stoploss, limit = takeprofit)