Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

R3 ETF Strategy

A Pine Script v5 strategy built on RSI (close, 2) and Crossover (RSI, 70). It has 4 order rules, 2 entries 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 0.0035 commission. 8 settings; defaults include RSI Length 2, Today's Min RSI for Entry 10 and Exit RSI 70.

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 R3 ETF Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did R3 ETF Strategy do on BTCUSDT 1D with default settings?
+17.26%
From 26 Jan 2024 to 21 Oct 2026, over 25 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does R3 ETF 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: 25 before, 50 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 R3 ETF Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does R3 ETF Strategy run in Zeal Terminal?
Yes
It compiles in 12 ms and runs 1,000 bars in 32 ms, in the browser.

BTCUSDT · 1D · default settings

  • 200 Day EMA
  • 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 (8)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1,172,630$2,025,273Equity from $1,000,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
+17.26%
$172,587.00
Buy and hold
+102.5%
same period
Closed trades
25
17 won · 8 lost
Profitable
68.0%
of closed trades
Profit factor
1.33
gross profit ÷ gross loss
Max drawdown
31.40%
−$476,724.00

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 stop loss

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

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

  • Note

    Uses an argument v6 removed

    when = on line 30. 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
Start Timetimestamp('01 Jan 2010 05:00 +0000')timeInDateRange
End Timetimestamp('01 Jan 2099 00:00 +0000')timeInDateRange
RSI Length2intRSI
Today's Min RSI for EntryThe RSI must be below this number today to qualify for trade entry10intRule2
Exit RSIThe strategy will sell when the RSI crosses over this number70intExit
Max RSI 3 Days Ago for EntryThe RSI must be below this number 3 days ago to qualify for trade entry60intRule2
Only enter trades when above qualifier EMA?When this is selected, a trade will only be entered when the price is above the EMA qualifier line.falseboolentry Long entry Long line 25 line 27
EMA Trade Qualifier Length200intRule1 200 Day EMA

What it calculates

  • RSIclose, RSI Length (2)RSI · line 11
  • CrossoverRSI, Exit RSI (70)Exit · 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 dataRSILenRSI Lengthsetting · 2ExitRSIExit RSIsetting · 70timetimeprice dataStartTimeStart Timesetting · timestamp('01 Jan 2…EndTimeEnd Timesetting · timestamp('01 Jan 2…QEMAEMA Trade Qualifier Len…setting · 200Day3RSIMaxMax RSI 3 Days Ago for …setting · 60TodaysMinRSIToday's Min RSI for Ent…setting · 10RSIRSI→ RSIExitCrossover→ ExitInDateRangeInDateRangeconditionRule1Rule1conditionRule2Rule2conditionRule3Rule3conditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeclose_all:close_all strategy.close_allplot:23200 Day EMAplot

Order rules

OrderFires whenBy defaultLine
Open Long long(InDateRange and Rule1 and Rule2 and Rule3 and EMAQualInput==true)On26
Open Long long(InDateRange and Rule2 and Rule3 and EMAQualInput==false)On28
Close LongExitOn30
Close (not InDateRange)On32

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.

7/7trades 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+17.3%+102.5%2568%1.3331.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−7.3%+5.5%2365%0.6018.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+19.9%+9.8%2167%1.2839.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−11.8%+8.4%1765%0.5023.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+11.4%+16.7%2861%1.1236.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−1.1%+21.5%2475%0.9522.5%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+58.1%+148.3%3077%2.0628.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−9.8%+17.1%2075%0.5116.1%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 market875%$285,134.00
Sideways market1070%−$15,768.90
Falling market757%−$96,778.60

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

How bad could the drawdown be?

27.1%

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

0%31%
All 25 trades
SideEntryExitBarsP&L
long28 Apr 2024 63,118.603 May 2024 62,882.005−$3,748.77
long19 Jun 2024 64,974.4030 Jun 2024 62,772.0011−$33,768.90
long5 Jul 2024 56,628.809 Jul 2024 58,050.004$24,155.30
long4 Aug 2024 58,161.008 Aug 2024 61,686.004$59,797.50
long1 Sep 2024 57,301.909 Sep 2024 57,042.008−$4,745.64
long2 Oct 2024 60,649.304 Oct 2024 62,086.002$24,676.40
long10 Oct 2024 60,326.4011 Oct 2024 62,540.001$39,129.00
long4 Nov 2024 67,850.006 Nov 2024 75,572.002$125,816.00
long23 Dec 2024 94,881.5024 Dec 2024 98,663.601$49,081.70
long25 Feb 2025 88,680.402 Mar 2025 94,270.005$80,704.10
long9 Mar 2025 80,734.4015 Mar 2025 84,338.406$60,760.70
long30 May 2025 103,985.002 Jun 2025 105,858.003$25,603.90
long21 Jun 2025 102,120.0023 Jun 2025 105,334.002$45,554.40
long31 Jul 2025 115,764.004 Aug 2025 115,055.004−$9,144.75
long23 Sep 2025 111,999.0028 Sep 2025 112,164.005$2,187.98
long16 Oct 2025 108,194.0020 Oct 2025 110,532.004$32,109.90
long14 Nov 2025 94,594.0024 Nov 2025 88,300.0010−$101,014.00
long15 Dec 2025 86,432.1019 Dec 2025 88,136.904$27,953.00
long19 Jan 2026 92,631.0027 Jan 2026 89,250.008−$52,746.00
long1 Feb 2026 76,968.2013 Feb 2026 68,854.0012−$146,788.00
long29 Mar 2026 66,010.9031 Mar 2026 68,284.502$42,899.90
long18 May 2026 77,001.9025 May 2026 77,322.007$5,356.79
long29 May 2026 73,460.8011 Jun 2026 63,626.0013−$173,216.00
long10 Sep 2026 76,568.7014 Sep 2026 78,189.204$23,716.40
long8 Oct 2026 81,754.4011 Oct 2026 83,773.103$28,255.60

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
R3 ETF Strategy this page—v5 strategy+17.3%2531.4%
Triple RSI strategy by Trade_by_DBrsiv5 strategy+3.2%23.3%
Hobbiecode - RSI + Close previous day by hobbiecodersiv5 strategy+1.2%634.2%
dirt cheap yet elegant RSI Strategy by SparkyFlaryrsiv4 strategy−11.4%820.5%
RSI Classic Strategy (by Coinrule) by Coinrulersiv4 strategy+7.5%67.2%
RSITrendStrategy by email_analystsrsiv4 strategy+69.2%2238.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.

  • 1 strategy call uses the when = argument (line 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 25 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 30: when = Exit → if block
⋯if (InDateRange)-    strategy.close("Long", when = Exit, alert_message="Close Long")+    if Exit+        strategy.close("Long", alert_message="Close Long")if (not InDateRange)⋯

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

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-// @version = 5+// @version = 6// Author = TradeAutomation⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 12 msYes 1,000 bars in 32 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/// @version = 5// Author = TradeAutomationstrategy(title="R3 ETF Strategy", shorttitle="R3 ETF Strategy", process_orders_on_close=true, overlay=true, commission_type=strategy.commission.cash_per_contract, commission_value=0.0035, initial_capital = 1000000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)// Backtest Date Range Inputs // StartTime = input.time(defval=timestamp('01 Jan 2010 05:00 +0000'), title='Start Time')EndTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End Time')InDateRange = time>=StartTime and time<=EndTime// Calculations and Inputs //RSILen = input.int(2, "RSI Length")RSI = ta.rsi(close, RSILen)TodaysMinRSI = input.int(10, "Today's Min RSI for Entry", tooltip = "The RSI must be below this number today to qualify for trade entry")ExitRSI = input.int(70, "Exit RSI", tooltip = "The strategy will sell when the RSI crosses over this number")Day3RSIMax = input.int(60, "Max RSI 3 Days Ago for Entry", tooltip = "The RSI must be below this number 3 days ago to qualify for trade entry")EMAQualInput = input.bool(false, "Only enter trades when above qualifier EMA?", tooltip="When this is selected, a trade will only be entered when the price is above the EMA qualifier line.")QEMA = ta.ema(close, input.int(200, "EMA Trade Qualifier Length"))// Strategy Rules //Rule1 = close>QEMARule2 = RSI[3]<Day3RSIMax and RSI<TodaysMinRSIRule3 = RSI<RSI[1] and RSI[1]<RSI[2] and RSI[2]<RSI[3] Exit = ta.crossover(RSI, ExitRSI)// Plot //plot(QEMA, "200 Day EMA")// Entry & Exit Functions //if (InDateRange and Rule1 and Rule2 and Rule3 and EMAQualInput==true)    strategy.entry("Long", strategy.long, alert_message="Long")if (InDateRange and Rule2 and Rule3 and EMAQualInput==false)    strategy.entry("Long", strategy.long, alert_message="Long")if (InDateRange)    strategy.close("Long", when = Exit, alert_message="Close Long")if (not InDateRange)    strategy.close_all(alert_message="Out of Date Range")