Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

IFR2

A Pine Script v4 strategy built on RSI (close, 2) and Highest or ATR (2). It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 100% of equity and pays no commission. 7 settings; defaults include RSI oversold level 25, Exit lookback 2 and Close after X candles 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 IFR2 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 37 of 37 trades.
How did IFR2 do on BTCUSDT 1D with default settings?
+12.14%
From 26 Jan 2024 to 21 Oct 2026, over 118 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can IFR2 be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does IFR2 use a stop loss?
No
Its exits set a profit target but no stop.
Does IFR2 run in Zeal Terminal?
Yes
It compiles in 10 ms and runs 1,000 bars in 26 ms, in the browser.

BTCUSDT · 1D · default settings

  • Exit price
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$56,068$101,264Equity from $50,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. Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 21) 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
+12.14%
$6,068.41
Buy and hold
+102.5%
same period
Closed trades
118
1 won · 0 lost
Profitable
0.8%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.76%
−$381.35

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

    strategy.exit is used without a stop, loss or trailing stop.

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

  • Note

    Uses an argument v6 removed

    when = on line 21. The upgraded version below moves each call inside an if block.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames rsi → ta.rsi, crossunder → ta.crossunder, highest → ta.highest, atr → ta.atr, barssince → ta.barssince, tostring → str.tostring.
  • 1 strategy call uses the when = argument (line 21). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 1: //@version=4 → //@version=5
  • Line 11: input(type = input.time) → input.time()
  • Line 12: input(type = input.time) → input.time()
  • Line 14: rsi → ta.rsi
  • Line 20: crossunder → ta.crossunder
  • Line 21: strategy.entry(…, true) → strategy.entry(…, strategy.long)
4 more edits
  • Line 24: highest → ta.highest
  • Line 24: atr → ta.atr
  • Line 28: barssince → ta.barssince
  • Line 29: tostring → str.tostring
-//@version=4+//@version=5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")-var I_INITIAL_DATE = input(0, "Initial date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")+var I_INITIAL_DATE = input.time(0, "Initial date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")-var I_FINAL_DATE = input(0, "Final date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")+var I_FINAL_DATE = input.time(0, "Final date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")// Calculation-ifr2 = rsi(close, 2)+ifr2 = ta.rsi(close, 2)inMarket = strategy.opentrades != 0⋯// Entry order-longCondition = crossunder(ifr2, I_OVERSOLD) and inRange+longCondition = ta.crossunder(ifr2, I_OVERSOLD) and inRange-strategy.entry("Long", true, comment="Entry", when=longCondition)+strategy.entry("Long", strategy.long, comment="Entry", when=longCondition)    // Exit order-exitPrice = highest(I_CANDLE_LOOKBACK) + atr(I_ATR_PERIOD) * I_ATR_EXIT_MULTIPLIER+exitPrice = ta.highest(I_CANDLE_LOOKBACK) + ta.atr(I_ATR_PERIOD) * I_ATR_EXIT_MULTIPLIERstrategy.exit("Long", "Long", limit=exitPrice, comment="Exit")⋯// Exit after X candles-if I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER+if I_CLOSE_AFTER and ta.barssince(opened) >= I_CLOSE_AFTER-    strategy.close_all(comment="It has been " + tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "")  + " since you entered")+    strategy.close_all(comment="It has been " + str.tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "")  + " since you entered")

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.float()
  • Line 10: input() → input.int()
  • Line 21: when = longCondition → if block
⋯// Inputs-var I_OVERSOLD = input(25, "RSI oversold level", minval=1, maxval=100, tooltip="The entry will occur when the RSI is bellow this value.", group="Basic settings")+var I_OVERSOLD = input.int(25, "RSI oversold level", minval=1, maxval=100, tooltip="The entry will occur when the RSI is bellow this value.", group="Basic settings")-var I_CANDLE_LOOKBACK = input(2, "Exit lookback", minval=1, tooltip="If you leave it at 2, the target will be calculated using the highest of the last 2 candles.", group="Basic settings")+var I_CANDLE_LOOKBACK = input.int(2, "Exit lookback", minval=1, tooltip="If you leave it at 2, the target will be calculated using the highest of the last 2 candles.", group="Basic settings")-var I_CLOSE_AFTER = input(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")+var I_CLOSE_AFTER = input.int(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")-var I_ATR_EXIT_MULTIPLIER = input(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")+var I_ATR_EXIT_MULTIPLIER = input.float(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")-var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")+var I_ATR_PERIOD = input.int(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")var I_INITIAL_DATE = input.time(0, "Initial date", tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")⋯longCondition = ta.crossunder(ifr2, I_OVERSOLD) and inRange-strategy.entry("Long", strategy.long, comment="Entry", when=longCondition)+if longCondition+    strategy.entry("Long", strategy.long, comment="Entry")    ⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L29:C3: cannot use 'int' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

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

Settings

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

SettingDefaultType and rangeFeeds
Basic settings
RSI oversold levelThe entry will occur when the RSI is bellow this value.25int · min 1 · max 100longCondition
Exit lookbackIf you leave it at 2, the target will be calculated using the highest of the last 2 candles.2int · min 1exitPrice
Close after X candlesLeave 0 if you want this to be disabled.5intclose_all line 28 close_all
ATR settings
ATR exit multiplier0.0float · step 0.1exitPrice
ATR period20int · min 2exitPrice
Date selection
Initial dateLeave this value as it is to disable.0intinRange
Final dateLeave this value as it is to disable.0intinRange

What it calculates

  • RSI (rsi, ta.rsi in v5)close, 2ifr2 · line 14
  • Highest / ATR (highest, ta.highest in v5)Exit lookback (2)exitPrice · line 24

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 dataI_CANDLE_LOOKBACKExit lookbacksetting · 2I_ATR_PERIODATR periodsetting · 20I_ATR_EXIT_MULTIPLIERATR exit multipliersetting · 0.0timetimeprice dataI_INITIAL_DATEInitial datesetting · 0I_FINAL_DATEFinal datesetting · 0I_OVERSOLDRSI oversold levelsetting · 25I_CLOSE_AFTERClose after X candlessetting · 5ifr2RSI→ ifr2exitPriceHighest / ATR→ exitPriceinRangeinRangevalueopenedopenedconditionlongConditionlongConditionconditioninMarketinMarketconditionentry:LongOpen Longstrategy.entryexit:Longexit Longstrategy.exitclose_all:close_all strategy.close_allplot:26Exit priceplot

Order rules

OrderFires whenBy defaultLine
Open Long longlongConditioncrossunder(ifr2, I_OVERSOLD) and inRangeOn21
Exit Long limitevery barOn25
Close I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTEROn29

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.

37/37trades 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+12.1%+102.5%1181%—0.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.9%+5.5%1211%—0.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+9.2%+9.8%1221%—0.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.6%+8.4%1291%—0.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+14.2%+16.7%1261%—2.7%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−1.0%+21.5%1260%0.002.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.7%+148.3%1211%—1.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.2%+17.1%1271%—0.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 market370%$0.00
Sideways market512%$6,068.41
Falling market300%$0.00

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

How bad could the drawdown be?

0.0%

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

0%1%
All 118 trades
SideEntryExitBarsP&L
long4 Feb 2024 42,582.9010 Feb 2024 47,751.106$6,068.41
long22 Feb 2024 51,288.4022 Feb 2024 51,288.400$0.00
long15 Mar 2024 69,499.9015 Mar 2024 69,499.900$0.00
long19 Mar 2024 61,937.4019 Mar 2024 61,937.400$0.00
long2 Apr 2024 65,464.002 Apr 2024 65,464.000$0.00
long12 Apr 2024 67,116.5012 Apr 2024 67,116.500$0.00
long15 Apr 2024 63,420.0015 Apr 2024 63,420.000$0.00
long17 Apr 2024 61,277.4017 Apr 2024 61,277.400$0.00
long24 Apr 2024 64,289.6024 Apr 2024 64,289.600$0.00
long26 Apr 2024 63,770.0026 Apr 2024 63,770.000$0.00
long30 Apr 2024 60,672.0030 Apr 2024 60,672.000$0.00
long7 May 2024 62,312.107 May 2024 62,312.100$0.00
long29 May 2024 67,652.4029 May 2024 67,652.400$0.00
long7 Jun 2024 69,355.607 Jun 2024 69,355.600$0.00
long11 Jun 2024 67,314.2011 Jun 2024 67,314.200$0.00
long13 Jun 2024 66,773.0013 Jun 2024 66,773.000$0.00
long18 Jun 2024 65,175.3018 Jun 2024 65,175.300$0.00
long3 Jul 2024 60,208.603 Jul 2024 60,208.600$0.00
long7 Jul 2024 55,857.807 Jul 2024 55,857.800$0.00
long23 Jul 2024 65,936.0023 Jul 2024 65,936.000$0.00
long29 Jul 2024 66,784.7029 Jul 2024 66,784.700$0.00
long2 Aug 2024 61,498.302 Aug 2024 61,498.300$0.00
long15 Aug 2024 57,541.1015 Aug 2024 57,541.100$0.00
long27 Aug 2024 59,415.0027 Aug 2024 59,415.000$0.00
long5 Sep 2024 56,180.005 Sep 2024 56,180.000$0.00
long16 Sep 2024 58,214.0016 Sep 2024 58,214.000$0.00
long30 Sep 2024 63,327.6030 Sep 2024 63,327.600$0.00
long9 Oct 2024 60,636.009 Oct 2024 60,636.000$0.00
long21 Oct 2024 67,377.5021 Oct 2024 67,377.500$0.00
long23 Oct 2024 66,668.6023 Oct 2024 66,668.600$0.00
long1 Nov 2024 69,496.001 Nov 2024 69,496.000$0.00
long25 Nov 2024 93,010.0025 Nov 2024 93,010.000$0.00
long9 Dec 2024 97,276.509 Dec 2024 97,276.500$0.00
long18 Dec 2024 100,204.0018 Dec 2024 100,204.000$0.00
long27 Dec 2024 94,299.0027 Dec 2024 94,299.000$0.00
long29 Dec 2024 93,738.2029 Dec 2024 93,738.200$0.00
long8 Jan 2025 95,060.608 Jan 2025 95,060.600$0.00
long26 Jan 2025 102,620.0026 Jan 2025 102,620.000$0.00
long1 Feb 2025 100,636.001 Feb 2025 100,636.000$0.00
long5 Feb 2025 96,612.405 Feb 2025 96,612.400$0.00
long11 Feb 2025 95,778.2011 Feb 2025 95,778.200$0.00
long16 Feb 2025 96,118.1016 Feb 2025 96,118.100$0.00
long24 Feb 2025 91,552.9024 Feb 2025 91,552.900$0.00
long7 Mar 2025 86,801.807 Mar 2025 86,801.800$0.00
long28 Mar 2025 84,424.4028 Mar 2025 84,424.400$0.00
long6 Apr 2025 78,430.006 Apr 2025 78,430.000$0.00
long4 May 2025 94,277.604 May 2025 94,277.600$0.00
long17 May 2025 103,127.0017 May 2025 103,127.000$0.00
long28 May 2025 107,782.0028 May 2025 107,782.000$0.00
long4 Jun 2025 104,697.004 Jun 2025 104,697.000$0.00
long12 Jun 2025 105,672.0012 Jun 2025 105,672.000$0.00
long14 Jun 2025 105,415.0014 Jun 2025 105,415.000$0.00
long17 Jun 2025 104,551.0017 Jun 2025 104,551.000$0.00
long20 Jun 2025 103,298.0020 Jun 2025 103,298.000$0.00
long1 Jul 2025 105,681.001 Jul 2025 105,681.000$0.00
long20 Jul 2025 117,265.0020 Jul 2025 117,265.000$0.00
long25 Jul 2025 117,614.0025 Jul 2025 117,614.000$0.00
long31 Jul 2025 115,764.0031 Jul 2025 115,764.000$0.00
long15 Aug 2025 117,342.0015 Aug 2025 117,342.000$0.00
long18 Aug 2025 116,227.0018 Aug 2025 116,227.000$0.00
long21 Aug 2025 112,500.0021 Aug 2025 112,500.000$0.00
long25 Aug 2025 110,112.0025 Aug 2025 110,112.000$0.00
long29 Aug 2025 108,377.0029 Aug 2025 108,377.000$0.00
long31 Aug 2025 108,246.0031 Aug 2025 108,246.000$0.00
long6 Sep 2025 110,188.006 Sep 2025 110,188.000$0.00
long19 Sep 2025 115,632.0019 Sep 2025 115,632.000$0.00
long21 Sep 2025 115,232.0021 Sep 2025 115,232.000$0.00
long25 Sep 2025 108,994.0025 Sep 2025 108,994.000$0.00
long10 Oct 2025 112,775.0010 Oct 2025 112,775.000$0.00
long15 Oct 2025 110,763.0015 Oct 2025 110,763.000$0.00
long29 Oct 2025 110,021.0029 Oct 2025 110,021.000$0.00
long3 Nov 2025 106,583.003 Nov 2025 106,583.000$0.00
long6 Nov 2025 101,346.006 Nov 2025 101,346.000$0.00
long12 Nov 2025 101,654.0012 Nov 2025 101,654.000$0.00
long19 Nov 2025 91,555.0019 Nov 2025 91,555.000$0.00
long1 Dec 2025 86,286.001 Dec 2025 86,286.000$0.00
long5 Dec 2025 89,330.005 Dec 2025 89,330.000$0.00
long12 Dec 2025 90,268.4012 Dec 2025 90,268.400$0.00
long17 Dec 2025 86,243.2017 Dec 2025 86,243.200$0.00
long23 Dec 2025 87,486.0023 Dec 2025 87,486.000$0.00
long25 Dec 2025 87,225.3025 Dec 2025 87,225.300$0.00
long29 Dec 2025 87,237.1029 Dec 2025 87,237.100$0.00
long7 Jan 2026 91,364.207 Jan 2026 91,364.200$0.00
long18 Jan 2026 93,673.1018 Jan 2026 93,673.100$0.00
long24 Jan 2026 89,225.3024 Jan 2026 89,225.300$0.00
long29 Jan 2026 84,650.2029 Jan 2026 84,650.200$0.00
long3 Feb 2026 75,770.203 Feb 2026 75,770.200$0.00
long11 Feb 2026 67,082.5011 Feb 2026 67,082.500$0.00
long17 Feb 2026 67,503.5017 Feb 2026 67,503.500$0.00
long23 Feb 2026 64,656.0023 Feb 2026 64,656.000$0.00
long7 Mar 2026 67,262.907 Mar 2026 67,262.900$0.00
long18 Mar 2026 71,246.5018 Mar 2026 71,246.500$0.00
long21 Mar 2026 68,918.1021 Mar 2026 68,918.100$0.00
long26 Mar 2026 68,820.3026 Mar 2026 68,820.300$0.00
long12 Apr 2026 70,741.0012 Apr 2026 70,741.000$0.00
long19 Apr 2026 73,801.8019 Apr 2026 73,801.800$0.00
long28 Apr 2026 76,342.8028 Apr 2026 76,342.800$0.00
long12 May 2026 80,504.5012 May 2026 80,504.500$0.00
long16 May 2026 78,148.1016 May 2026 78,148.100$0.00
long22 May 2026 75,539.5022 May 2026 75,539.500$0.00
long26 May 2026 75,930.0026 May 2026 75,930.000$0.00
long1 Jun 2026 71,408.901 Jun 2026 71,408.900$0.00
long10 Jun 2026 61,511.0010 Jun 2026 61,511.000$0.00
long17 Jun 2026 64,509.4017 Jun 2026 64,509.400$0.00
long23 Jun 2026 62,734.6023 Jun 2026 62,734.600$0.00
long30 Jun 2026 58,624.7030 Jun 2026 58,624.700$0.00
long8 Jul 2026 62,290.008 Jul 2026 62,290.000$0.00
long13 Jul 2026 62,334.5013 Jul 2026 62,334.500$0.00
long24 Jul 2026 64,140.0024 Jul 2026 64,140.000$0.00
long27 Jul 2026 63,755.9027 Jul 2026 63,755.900$0.00
long31 Jul 2026 62,887.9031 Jul 2026 62,887.900$0.00
long10 Aug 2026 63,970.0010 Aug 2026 63,970.000$0.00
long8 Sep 2026 78,455.808 Sep 2026 78,455.800$0.00
long13 Sep 2026 76,842.0013 Sep 2026 76,842.000$0.00
long15 Sep 2026 75,644.5015 Sep 2026 75,644.500$0.00
long28 Sep 2026 83,500.0028 Sep 2026 83,500.000$0.00
long7 Oct 2026 83,321.807 Oct 2026 83,321.800$0.00
long12 Oct 2026 81,850.0012 Oct 2026 81,850.000$0.00

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
IFR2 this page—v4 strategy+12.1%1180.8%
Dynamic Stop Loss Demo by Tindtilyhighest rsi atrv5 strategydoes not run in Zeal Terminal
S&P Bear Warning Indicator by gary_tradesatr highestv4 strategyNo trades on this market
SuperTREX strategy by RafaelZionirsi atrv4 strategy−3.8%36.1%
[KL] RSI 14 + 10 Strategy by DojiEmojiatr rsiv4 strategy+4.2%2739.7%
FTB Strategy (Automated) by ZenAndTheArtOfTradingrsi highestv5 strategydoes not run in Zeal Terminal

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 10 msWith a workaround 1,000 bars in 26 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 21) 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. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

//@version=4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Coded by Eduardo Mattjestrategy("IFR2", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=50000, process_orders_on_close=true)// Inputsvar I_OVERSOLD = input(25, "RSI oversold level", minval=1, maxval=100, tooltip="The entry will occur when the RSI is bellow this value.", group="Basic settings")var I_CANDLE_LOOKBACK = input(2, "Exit lookback", minval=1, tooltip="If you leave it at 2, the target will be calculated using the highest of the last 2 candles.", group="Basic settings")var I_CLOSE_AFTER = input(5, "Close after X candles", tooltip="Leave 0 if you want this to be disabled.", group="Basic settings")var I_ATR_EXIT_MULTIPLIER = input(0.0, "ATR exit multiplier", step=0.1, inline="ATR settings", group="ATR settings")var I_ATR_PERIOD = input(20, "ATR period", minval=2, inline="ATR settings", group="ATR settings")var I_INITIAL_DATE = input(0, "Initial date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")var I_FINAL_DATE = input(0, "Final date", input.time, tooltip="Leave this value as it is to disable.", inline="Date selection", group="Date selection")// Calculationifr2 = rsi(close, 2)inMarket = strategy.opentrades != 0opened = strategy.opentrades[0] > strategy.opentrades[1]// Range checkinRange = (I_INITIAL_DATE == 0 ? true : time >= I_INITIAL_DATE) and (I_FINAL_DATE == 0 ? true : time <= I_FINAL_DATE)// Entry orderlongCondition = crossunder(ifr2, I_OVERSOLD) and inRangestrategy.entry("Long", true, comment="Entry", when=longCondition)    // Exit orderexitPrice = highest(I_CANDLE_LOOKBACK) + atr(I_ATR_PERIOD) * I_ATR_EXIT_MULTIPLIERstrategy.exit("Long", "Long", limit=exitPrice, comment="Exit")plot(longCondition or inMarket ? exitPrice : na, "Exit price", color.teal, 2, plot.style_linebr, offset=1)// Exit after X candlesif I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER    strategy.close_all(comment="It has been " + tostring(I_CLOSE_AFTER) + " candle" + (I_CLOSE_AFTER > 1 ? "s" : "")  + " since you entered")