Pine Script v4 · Strategy
IFR2 - RSI2
A Pine Script v4 strategy built on RSI (close, 2), SMA (close, 200) and EMA (close, 200). It has 2 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade is 100 contracts and pays no commission. 8 settings; defaults include Valor minimo de entrada 25, Quantidade de ações 200 and Inicio Dia 1.
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 - RSI2 repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did IFR2 - RSI2 do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can IFR2 - RSI2 be converted to Pine Script v5?
- Not tested
- The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
- Does IFR2 - RSI2 use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does IFR2 - RSI2 run in Zeal Terminal?
- Yes
- It compiles in 18 ms and runs 1,000 bars in 50 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- EMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $10,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
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
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 39, 45. 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, sma → ta.sma, ema → ta.ema.
- 2 strategy calls use the when = argument (line 39, 45). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 3: //@version=4 → //@version=5
- Line 13: rsi → ta.rsi
- Line 14: sma → ta.sma
- Line 15: ema → ta.ema
- Line 25: input(type = input.integer) → input.int()
- Line 26: input(type = input.integer) → input.int()
6 more edits
- Line 27: input(type = input.integer) → input.int()
- Line 28: input(type = input.integer) → input.int()
- Line 29: input(type = input.integer) → input.int()
- Line 30: input(type = input.integer) → input.int()
- Line 39: strategy.order(…, true) → strategy.order(…, strategy.long)
- Line 45: strategy.order(…, false) → strategy.order(…, strategy.short)
⋯// © jocker.soad-//@version=4+//@version=5strategy("My Script", overlay=true, initial_capital=10000, default_qty_value=100)⋯var valorLucro = 0.0-valueRsi = rsi(close, 2)+valueRsi = ta.rsi(close, 2)-valueSma = sma(close, 200)+valueSma = ta.sma(close, 200)-valueEma = ema(close, 200)+valueEma = ta.ema(close, 200)lastHighPrice = high[2]⋯// plotshape(comprado, style=shape.triangledown, color=color.blue)-startDate = input(title="Inicio Dia", type=input.integer, defval=1, minval=1, maxval=31)+startDate = input.int(title="Inicio Dia", defval=1, minval=1, maxval=31)-startMonth = input(title="Inicio Mes", type=input.integer, defval=1, minval=1, maxval=12)+startMonth = input.int(title="Inicio Mes", defval=1, minval=1, maxval=12)-startYear = input(title="Inicio Ano", type=input.integer, defval=2018, minval=1800, maxval=2100)+startYear = input.int(title="Inicio Ano", defval=2018, minval=1800, maxval=2100)-endDate = input(title="Final Dia", type=input.integer, defval=1, minval=1, maxval=31)+endDate = input.int(title="Final Dia", defval=1, minval=1, maxval=31)-endMonth = input(title="Final Mes", type=input.integer, defval=12, minval=1, maxval=12)+endMonth = input.int(title="Final Mes", defval=12, minval=1, maxval=12)-endYear = input(title="Final Ano", type=input.integer, defval=2020, minval=1800, maxval=2100)+endYear = input.int(title="Final Ano", defval=2020, minval=1800, maxval=2100)inDateRange = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))⋯ valorComprado := close- strategy.order("buy", true, qtdAtivos, when=buyValidation)+ strategy.order("buy", strategy.long, qtdAtivos, when=buyValidation) ⋯ valorComprado := 0- strategy.order("sell", false, qtdAtivos, when=sellValidation)+ strategy.order("sell", strategy.short, qtdAtivos, when=sellValidation) ⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 5: input() → input.int()
- Line 6: input() → input.int()
- Line 39: when = buyValidation → if block
- Line 45: when = sellValidation → if block
⋯strategy("My Script", overlay=true, initial_capital=10000, default_qty_value=100)-min = input(title="Valor minimo de entrada", defval=25)+min = input.int(title="Valor minimo de entrada", defval=25)-qtdAtivos = input(title="Quantidade de ações", defval=200)+qtdAtivos = input.int(title="Quantidade de ações", defval=200)// overBuyLine = hline(80)⋯ valorComprado := close- strategy.order("buy", strategy.long, qtdAtivos, when=buyValidation)+ if buyValidation+ strategy.order("buy", strategy.long, qtdAtivos) ⋯ valorComprado := 0- strategy.order("sell", strategy.short, qtdAtivos, when=sellValidation)+ if sellValidation+ strategy.order("sell", strategy.short, qtdAtivos) ⋯Does it run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © jocker.soad-//@version=5+//@version=6strategy("My Script", overlay=true, initial_capital=10000, default_qty_value=100)⋯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 |
|---|---|---|---|
| Valor minimo de entrada | 25 | int | buyValidation |
| Quantidade de ações | 200 | int | order buy order sell |
| Inicio Dia | 1 | int (written input.integer) · min 1 · max 31 | inDateRange |
| Inicio Mes | 1 | int (written input.integer) · min 1 · max 12 | inDateRange |
| Inicio Ano | 2018 | int (written input.integer) · min 1800 · max 2100 | inDateRange |
| Final Dia | 1 | int (written input.integer) · min 1 · max 31 | inDateRange |
| Final Mes | 12 | int (written input.integer) · min 1 · max 12 | inDateRange |
| Final Ano | 2020 | int (written input.integer) · min 1800 · max 2100 | inDateRange |
What it calculates
- RSI (
rsi,ta.rsiin v5)close, 2valueRsi · line 13 - SMA (
sma,ta.smain v5)close, 200valueSma · line 14 - EMA (
ema,ta.emain v5)close, 200valueEma · line 15
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 |
|---|---|---|---|
| order buy long | buyValidationvalueRsi <= min | On | 39 |
| order sell short | sellValidationclose >= lastHighPrice | On | 45 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 - RSI2 this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| MACD, RSI, & RVOL Strategy by BobBarker42069 | rsi ema sma | v4 strategy | +32.6% | 1 | 1.5% |
| Vin's Playzone Strategy by Vvaz_ | ema rsi sma | v5 strategy | −908.1% | 21 | 3,570.5% |
| Momentum Explosion 2CCI RSI by capam | ema sma rsi | v4 strategy | +24.1% | 6 | 42.3% |
| 3 x EMA + Stochastic RSI + ATR by tomimarson | ema rsi sma | v4 strategy | −42.3% | 18 | 44.8% |
| Take Profit On Trend (by BHD_Trade_Bot) by BHD_Trade_Bot | ema rsi sma | v4 strategy | +54.8% | 9 | 13.1% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | With a workaround 1,000 bars in 50 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 39, 45) so the engine trades the way the script says.
“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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © jocker.soad//@version=4strategy("My Script", overlay=true, initial_capital=10000, default_qty_value=100)min = input(title="Valor minimo de entrada", defval=25)qtdAtivos = input(title="Quantidade de ações", defval=200)// overBuyLine = hline(80)// overSellLine = hline(min)var comprado = falsevar valorComprado = 0.0var qtdDiasComprado = 0var valorLucro = 0.0valueRsi = rsi(close, 2)valueSma = sma(close, 200)valueEma = ema(close, 200)lastHighPrice = high[2]buyValidation = valueRsi <= minsellValidation = close >= lastHighPrice// plot(lastHighPrice, trackprice=true, offset=-99999, color=color.olive, linewidth=3, style=plot.style_area)// plot(valueRsi)// plot(valueSma)// plot(valueEma)// plotshape(sellValidation, style=shape.triangledown, color=color.blue)// plotshape(comprado, style=shape.triangledown, color=color.blue)startDate = input(title="Inicio Dia", type=input.integer, defval=1, minval=1, maxval=31)startMonth = input(title="Inicio Mes", type=input.integer, defval=1, minval=1, maxval=12)startYear = input(title="Inicio Ano", type=input.integer, defval=2018, minval=1800, maxval=2100)endDate = input(title="Final Dia", type=input.integer, defval=1, minval=1, maxval=31)endMonth = input(title="Final Mes", type=input.integer, defval=12, minval=1, maxval=12)endYear = input(title="Final Ano", type=input.integer, defval=2020, minval=1800, maxval=2100)inDateRange = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))if inDateRange if close >= valueEma if comprado == false and buyValidation qtdDiasComprado := 0 comprado := true valorComprado := close strategy.order("buy", true, qtdAtivos, when=buyValidation) if sellValidation and comprado == true comprado := false valorLucro := valorLucro + (close - valorComprado) valorComprado := 0 strategy.order("sell", false, qtdAtivos, when=sellValidation) if comprado == true and sellValidation == false qtdDiasComprado := qtdDiasComprado + 1// plot(valorLucro, color=color.lime)