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
- 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
VerifiedSame 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")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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Basic settings | |||
| RSI oversold levelThe entry will occur when the RSI is bellow this value. | 25 | int · min 1 · max 100 | longCondition |
| Exit lookbackIf you leave it at 2, the target will be calculated using the highest of the last 2 candles. | 2 | int · min 1 | exitPrice |
| Close after X candlesLeave 0 if you want this to be disabled. | 5 | int | close_all line 28 close_all |
| ATR settings | |||
| ATR exit multiplier | 0.0 | float · step 0.1 | exitPrice |
| ATR period | 20 | int · min 2 | exitPrice |
| Date selection | |||
| Initial dateLeave this value as it is to disable. | 0 | int | inRange |
| Final dateLeave this value as it is to disable. | 0 | int | inRange |
What it calculates
- RSI (
rsi,ta.rsiin v5)close, 2ifr2 · line 14 - Highest / ATR (
highest,ta.highestin 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | longConditioncrossunder(ifr2, I_OVERSOLD) and inRange | On | 21 |
| Exit Long limit | every bar | On | 25 |
| Close | I_CLOSE_AFTER and barssince(opened) >= I_CLOSE_AFTER | On | 29 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +12.1% | +102.5% | 118 | 1% | — | 0.8% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.9% | +5.5% | 121 | 1% | — | 0.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +9.2% | +9.8% | 122 | 1% | — | 0.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.6% | +8.4% | 129 | 1% | — | 0.5% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +14.2% | +16.7% | 126 | 1% | — | 2.7% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −1.0% | +21.5% | 126 | 0% | 0.00 | 2.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.7% | +148.3% | 121 | 1% | — | 1.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +1.2% | +17.1% | 127 | 1% | — | 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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 37 | 0% | $0.00 |
| Sideways market | 51 | 2% | $6,068.41 |
| Falling market | 30 | 0% | $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.
All 118 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 4 Feb 2024 42,582.90 | 10 Feb 2024 47,751.10 | 6 | $6,068.41 |
| long | 22 Feb 2024 51,288.40 | 22 Feb 2024 51,288.40 | 0 | $0.00 |
| long | 15 Mar 2024 69,499.90 | 15 Mar 2024 69,499.90 | 0 | $0.00 |
| long | 19 Mar 2024 61,937.40 | 19 Mar 2024 61,937.40 | 0 | $0.00 |
| long | 2 Apr 2024 65,464.00 | 2 Apr 2024 65,464.00 | 0 | $0.00 |
| long | 12 Apr 2024 67,116.50 | 12 Apr 2024 67,116.50 | 0 | $0.00 |
| long | 15 Apr 2024 63,420.00 | 15 Apr 2024 63,420.00 | 0 | $0.00 |
| long | 17 Apr 2024 61,277.40 | 17 Apr 2024 61,277.40 | 0 | $0.00 |
| long | 24 Apr 2024 64,289.60 | 24 Apr 2024 64,289.60 | 0 | $0.00 |
| long | 26 Apr 2024 63,770.00 | 26 Apr 2024 63,770.00 | 0 | $0.00 |
| long | 30 Apr 2024 60,672.00 | 30 Apr 2024 60,672.00 | 0 | $0.00 |
| long | 7 May 2024 62,312.10 | 7 May 2024 62,312.10 | 0 | $0.00 |
| long | 29 May 2024 67,652.40 | 29 May 2024 67,652.40 | 0 | $0.00 |
| long | 7 Jun 2024 69,355.60 | 7 Jun 2024 69,355.60 | 0 | $0.00 |
| long | 11 Jun 2024 67,314.20 | 11 Jun 2024 67,314.20 | 0 | $0.00 |
| long | 13 Jun 2024 66,773.00 | 13 Jun 2024 66,773.00 | 0 | $0.00 |
| long | 18 Jun 2024 65,175.30 | 18 Jun 2024 65,175.30 | 0 | $0.00 |
| long | 3 Jul 2024 60,208.60 | 3 Jul 2024 60,208.60 | 0 | $0.00 |
| long | 7 Jul 2024 55,857.80 | 7 Jul 2024 55,857.80 | 0 | $0.00 |
| long | 23 Jul 2024 65,936.00 | 23 Jul 2024 65,936.00 | 0 | $0.00 |
| long | 29 Jul 2024 66,784.70 | 29 Jul 2024 66,784.70 | 0 | $0.00 |
| long | 2 Aug 2024 61,498.30 | 2 Aug 2024 61,498.30 | 0 | $0.00 |
| long | 15 Aug 2024 57,541.10 | 15 Aug 2024 57,541.10 | 0 | $0.00 |
| long | 27 Aug 2024 59,415.00 | 27 Aug 2024 59,415.00 | 0 | $0.00 |
| long | 5 Sep 2024 56,180.00 | 5 Sep 2024 56,180.00 | 0 | $0.00 |
| long | 16 Sep 2024 58,214.00 | 16 Sep 2024 58,214.00 | 0 | $0.00 |
| long | 30 Sep 2024 63,327.60 | 30 Sep 2024 63,327.60 | 0 | $0.00 |
| long | 9 Oct 2024 60,636.00 | 9 Oct 2024 60,636.00 | 0 | $0.00 |
| long | 21 Oct 2024 67,377.50 | 21 Oct 2024 67,377.50 | 0 | $0.00 |
| long | 23 Oct 2024 66,668.60 | 23 Oct 2024 66,668.60 | 0 | $0.00 |
| long | 1 Nov 2024 69,496.00 | 1 Nov 2024 69,496.00 | 0 | $0.00 |
| long | 25 Nov 2024 93,010.00 | 25 Nov 2024 93,010.00 | 0 | $0.00 |
| long | 9 Dec 2024 97,276.50 | 9 Dec 2024 97,276.50 | 0 | $0.00 |
| long | 18 Dec 2024 100,204.00 | 18 Dec 2024 100,204.00 | 0 | $0.00 |
| long | 27 Dec 2024 94,299.00 | 27 Dec 2024 94,299.00 | 0 | $0.00 |
| long | 29 Dec 2024 93,738.20 | 29 Dec 2024 93,738.20 | 0 | $0.00 |
| long | 8 Jan 2025 95,060.60 | 8 Jan 2025 95,060.60 | 0 | $0.00 |
| long | 26 Jan 2025 102,620.00 | 26 Jan 2025 102,620.00 | 0 | $0.00 |
| long | 1 Feb 2025 100,636.00 | 1 Feb 2025 100,636.00 | 0 | $0.00 |
| long | 5 Feb 2025 96,612.40 | 5 Feb 2025 96,612.40 | 0 | $0.00 |
| long | 11 Feb 2025 95,778.20 | 11 Feb 2025 95,778.20 | 0 | $0.00 |
| long | 16 Feb 2025 96,118.10 | 16 Feb 2025 96,118.10 | 0 | $0.00 |
| long | 24 Feb 2025 91,552.90 | 24 Feb 2025 91,552.90 | 0 | $0.00 |
| long | 7 Mar 2025 86,801.80 | 7 Mar 2025 86,801.80 | 0 | $0.00 |
| long | 28 Mar 2025 84,424.40 | 28 Mar 2025 84,424.40 | 0 | $0.00 |
| long | 6 Apr 2025 78,430.00 | 6 Apr 2025 78,430.00 | 0 | $0.00 |
| long | 4 May 2025 94,277.60 | 4 May 2025 94,277.60 | 0 | $0.00 |
| long | 17 May 2025 103,127.00 | 17 May 2025 103,127.00 | 0 | $0.00 |
| long | 28 May 2025 107,782.00 | 28 May 2025 107,782.00 | 0 | $0.00 |
| long | 4 Jun 2025 104,697.00 | 4 Jun 2025 104,697.00 | 0 | $0.00 |
| long | 12 Jun 2025 105,672.00 | 12 Jun 2025 105,672.00 | 0 | $0.00 |
| long | 14 Jun 2025 105,415.00 | 14 Jun 2025 105,415.00 | 0 | $0.00 |
| long | 17 Jun 2025 104,551.00 | 17 Jun 2025 104,551.00 | 0 | $0.00 |
| long | 20 Jun 2025 103,298.00 | 20 Jun 2025 103,298.00 | 0 | $0.00 |
| long | 1 Jul 2025 105,681.00 | 1 Jul 2025 105,681.00 | 0 | $0.00 |
| long | 20 Jul 2025 117,265.00 | 20 Jul 2025 117,265.00 | 0 | $0.00 |
| long | 25 Jul 2025 117,614.00 | 25 Jul 2025 117,614.00 | 0 | $0.00 |
| long | 31 Jul 2025 115,764.00 | 31 Jul 2025 115,764.00 | 0 | $0.00 |
| long | 15 Aug 2025 117,342.00 | 15 Aug 2025 117,342.00 | 0 | $0.00 |
| long | 18 Aug 2025 116,227.00 | 18 Aug 2025 116,227.00 | 0 | $0.00 |
| long | 21 Aug 2025 112,500.00 | 21 Aug 2025 112,500.00 | 0 | $0.00 |
| long | 25 Aug 2025 110,112.00 | 25 Aug 2025 110,112.00 | 0 | $0.00 |
| long | 29 Aug 2025 108,377.00 | 29 Aug 2025 108,377.00 | 0 | $0.00 |
| long | 31 Aug 2025 108,246.00 | 31 Aug 2025 108,246.00 | 0 | $0.00 |
| long | 6 Sep 2025 110,188.00 | 6 Sep 2025 110,188.00 | 0 | $0.00 |
| long | 19 Sep 2025 115,632.00 | 19 Sep 2025 115,632.00 | 0 | $0.00 |
| long | 21 Sep 2025 115,232.00 | 21 Sep 2025 115,232.00 | 0 | $0.00 |
| long | 25 Sep 2025 108,994.00 | 25 Sep 2025 108,994.00 | 0 | $0.00 |
| long | 10 Oct 2025 112,775.00 | 10 Oct 2025 112,775.00 | 0 | $0.00 |
| long | 15 Oct 2025 110,763.00 | 15 Oct 2025 110,763.00 | 0 | $0.00 |
| long | 29 Oct 2025 110,021.00 | 29 Oct 2025 110,021.00 | 0 | $0.00 |
| long | 3 Nov 2025 106,583.00 | 3 Nov 2025 106,583.00 | 0 | $0.00 |
| long | 6 Nov 2025 101,346.00 | 6 Nov 2025 101,346.00 | 0 | $0.00 |
| long | 12 Nov 2025 101,654.00 | 12 Nov 2025 101,654.00 | 0 | $0.00 |
| long | 19 Nov 2025 91,555.00 | 19 Nov 2025 91,555.00 | 0 | $0.00 |
| long | 1 Dec 2025 86,286.00 | 1 Dec 2025 86,286.00 | 0 | $0.00 |
| long | 5 Dec 2025 89,330.00 | 5 Dec 2025 89,330.00 | 0 | $0.00 |
| long | 12 Dec 2025 90,268.40 | 12 Dec 2025 90,268.40 | 0 | $0.00 |
| long | 17 Dec 2025 86,243.20 | 17 Dec 2025 86,243.20 | 0 | $0.00 |
| long | 23 Dec 2025 87,486.00 | 23 Dec 2025 87,486.00 | 0 | $0.00 |
| long | 25 Dec 2025 87,225.30 | 25 Dec 2025 87,225.30 | 0 | $0.00 |
| long | 29 Dec 2025 87,237.10 | 29 Dec 2025 87,237.10 | 0 | $0.00 |
| long | 7 Jan 2026 91,364.20 | 7 Jan 2026 91,364.20 | 0 | $0.00 |
| long | 18 Jan 2026 93,673.10 | 18 Jan 2026 93,673.10 | 0 | $0.00 |
| long | 24 Jan 2026 89,225.30 | 24 Jan 2026 89,225.30 | 0 | $0.00 |
| long | 29 Jan 2026 84,650.20 | 29 Jan 2026 84,650.20 | 0 | $0.00 |
| long | 3 Feb 2026 75,770.20 | 3 Feb 2026 75,770.20 | 0 | $0.00 |
| long | 11 Feb 2026 67,082.50 | 11 Feb 2026 67,082.50 | 0 | $0.00 |
| long | 17 Feb 2026 67,503.50 | 17 Feb 2026 67,503.50 | 0 | $0.00 |
| long | 23 Feb 2026 64,656.00 | 23 Feb 2026 64,656.00 | 0 | $0.00 |
| long | 7 Mar 2026 67,262.90 | 7 Mar 2026 67,262.90 | 0 | $0.00 |
| long | 18 Mar 2026 71,246.50 | 18 Mar 2026 71,246.50 | 0 | $0.00 |
| long | 21 Mar 2026 68,918.10 | 21 Mar 2026 68,918.10 | 0 | $0.00 |
| long | 26 Mar 2026 68,820.30 | 26 Mar 2026 68,820.30 | 0 | $0.00 |
| long | 12 Apr 2026 70,741.00 | 12 Apr 2026 70,741.00 | 0 | $0.00 |
| long | 19 Apr 2026 73,801.80 | 19 Apr 2026 73,801.80 | 0 | $0.00 |
| long | 28 Apr 2026 76,342.80 | 28 Apr 2026 76,342.80 | 0 | $0.00 |
| long | 12 May 2026 80,504.50 | 12 May 2026 80,504.50 | 0 | $0.00 |
| long | 16 May 2026 78,148.10 | 16 May 2026 78,148.10 | 0 | $0.00 |
| long | 22 May 2026 75,539.50 | 22 May 2026 75,539.50 | 0 | $0.00 |
| long | 26 May 2026 75,930.00 | 26 May 2026 75,930.00 | 0 | $0.00 |
| long | 1 Jun 2026 71,408.90 | 1 Jun 2026 71,408.90 | 0 | $0.00 |
| long | 10 Jun 2026 61,511.00 | 10 Jun 2026 61,511.00 | 0 | $0.00 |
| long | 17 Jun 2026 64,509.40 | 17 Jun 2026 64,509.40 | 0 | $0.00 |
| long | 23 Jun 2026 62,734.60 | 23 Jun 2026 62,734.60 | 0 | $0.00 |
| long | 30 Jun 2026 58,624.70 | 30 Jun 2026 58,624.70 | 0 | $0.00 |
| long | 8 Jul 2026 62,290.00 | 8 Jul 2026 62,290.00 | 0 | $0.00 |
| long | 13 Jul 2026 62,334.50 | 13 Jul 2026 62,334.50 | 0 | $0.00 |
| long | 24 Jul 2026 64,140.00 | 24 Jul 2026 64,140.00 | 0 | $0.00 |
| long | 27 Jul 2026 63,755.90 | 27 Jul 2026 63,755.90 | 0 | $0.00 |
| long | 31 Jul 2026 62,887.90 | 31 Jul 2026 62,887.90 | 0 | $0.00 |
| long | 10 Aug 2026 63,970.00 | 10 Aug 2026 63,970.00 | 0 | $0.00 |
| long | 8 Sep 2026 78,455.80 | 8 Sep 2026 78,455.80 | 0 | $0.00 |
| long | 13 Sep 2026 76,842.00 | 13 Sep 2026 76,842.00 | 0 | $0.00 |
| long | 15 Sep 2026 75,644.50 | 15 Sep 2026 75,644.50 | 0 | $0.00 |
| long | 28 Sep 2026 83,500.00 | 28 Sep 2026 83,500.00 | 0 | $0.00 |
| long | 7 Oct 2026 83,321.80 | 7 Oct 2026 83,321.80 | 0 | $0.00 |
| long | 12 Oct 2026 81,850.00 | 12 Oct 2026 81,850.00 | 0 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| IFR2 this page | — | v4 strategy | +12.1% | 118 | 0.8% |
| Dynamic Stop Loss Demo by Tindtily | highest rsi atr | v5 strategy | does not run in Zeal Terminal | ||
| S&P Bear Warning Indicator by gary_trades | atr highest | v4 strategy | No trades on this market | ||
| SuperTREX strategy by RafaelZioni | rsi atr | v4 strategy | −3.8% | 3 | 6.1% |
| [KL] RSI 14 + 10 Strategy by DojiEmoji | atr rsi | v4 strategy | +4.2% | 27 | 39.7% |
| FTB Strategy (Automated) by ZenAndTheArtOfTrading | rsi highest | v5 strategy | does not run in Zeal Terminal | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 10 ms | With a workaround 1,000 bars in 26 ms | Not measured |
| PineTS | No 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")