Pine Script v4 · Strategy
Simple RSI strategy
A Pine Script v4 strategy built on RMA or Change (max(change(src), 0), 5), Highest (high, p) and Lowest (low, p). It has 14 order rules, 7 entries among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 20% of equity and pays 0.075% commission. 5 settings; defaults include Over Bought 80, Over Sold 25 and RSI Length 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 Simple RSI strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 45 of 45 trades.
- How did Simple RSI strategy do on BTCUSDT 1D with default settings?
- −10.98%
- From 26 Jan 2024 to 21 Oct 2026, over 119 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Simple RSI strategy 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 Simple RSI strategy use a stop loss?
- Yes
- strategy.exit sets a stop on line 63, 64, 65, 66, 67, 68, 69.
- Does Simple RSI strategy run in Zeal Terminal?
- Yes
- It compiles in 21 ms and runs 1,000 bars in 52 ms, in the browser.
BTCUSDT · 1D · default settings
- HLine
- HLine
- HLine
- HLine
- HLine
- HLine
- HLine
- HLine
- HLine
- Plot
- Plot
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Net profit
- −10.98%
- −$1,097.71
- Buy and hold
- +102.5%
- same period
- Closed trades
- 119
- 81 won · 38 lost
- Profitable
- 68.1%
- of closed trades
- Profit factor
- 0.78
- gross profit ÷ gross loss
- Max drawdown
- 24.44%
- −$2,572.03
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.
-
Note
4 settings have no label
In the settings dialog OverBought (line 7), OverSold (line 8), ProfitTarget_Percent (line 49), LossTarget_Percent (line 52) show an empty name. The labels on this page come from the variable names.
-
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 55, 56, 57, 58, 59, 60, 61. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 14
transp = on line 14. v5 folds the transparency into the colour with color.new(c, transp).
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 rma → ta.rma, max → math.max, change → ta.change, min → math.min, highest → ta.highest, lowest → ta.lowest.
- 7 strategy calls use the when = argument (line 55, 56, 57, 58, 59, 60, 61). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 119 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 1: //@version=4 → //@version=5
- Line 14: transp = 98 → color.new(color.purple, 98)
- Line 17: rma → ta.rma
- Line 17: max → math.max
- Line 17: change → ta.change
- Line 18: rma → ta.rma
4 more edits
- Line 18: min → math.min
- Line 18: change → ta.change
- Line 22: highest → ta.highest
- Line 23: lowest → ta.lowest
-//@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/⋯//band50 = hline(50, color=black, linewidth=1)-fill(band1, band0, color=color.purple, transp=98)+fill(band1, band0, color=color.new(color.purple, 98))src = closelen = input(5, minval=1, title="RSI Length")-up = rma(max(change(src), 0), len)+up = ta.rma(math.max(ta.change(src), 0), len)-down = rma(-min(change(src), 0), len)+down = ta.rma(-math.min(ta.change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)⋯//scale-hh = highest(high, p)+hh = ta.highest(high, p)-ll = lowest(low, p)+ll = ta.lowest(low, p)scale = hh - ll⋯Same 119 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 7: input() → input.int()
- Line 8: input() → input.int()
- Line 16: input() → input.int()
- Line 49: input() → input.int()
- Line 52: input() → input.int()
- Line 55: when = strategy.opentrades == 0 and longsignal → if block
6 more edits
- Line 56: when = strategy.opentrades == 1 and longsignal → if block
- Line 57: when = strategy.opentrades == 2 and longsignal → if block
- Line 58: when = strategy.opentrades == 3 and longsignal → if block
- Line 59: when = strategy.opentrades == 4 and longsignal → if block
- Line 60: when = strategy.opentrades == 5 and longsignal → if block
- Line 61: when = strategy.opentrades == 6 and longsignal → if block
⋯look = 0-OverBought = input(80, minval=50)+OverBought = input.int(80, minval=50)-OverSold = input(25, maxval=50)+OverSold = input.int(25, maxval=50)bandmx = hline(100)⋯src = close-len = input(5, minval=1, title="RSI Length")+len = input.int(5, minval=1, title="RSI Length")up = ta.rma(math.max(ta.change(src), 0), len)⋯//set take profit-ProfitTarget_Percent = input(3)+ProfitTarget_Percent = input.int(3)Profit_Ticks = close * (ProfitTarget_Percent / 100) / syminfo.mintick//set take profit-LossTarget_Percent = input(10)+LossTarget_Percent = input.int(10)Loss_Ticks = close * (LossTarget_Percent / 100) / syminfo.mintick//Order Placing-strategy.entry("Entry 1", strategy.long, when=strategy.opentrades == 0 and longsignal)+if strategy.opentrades == 0 and longsignal+ strategy.entry("Entry 1", strategy.long)-strategy.entry("Entry 2", strategy.long, when=strategy.opentrades == 1 and longsignal)+if strategy.opentrades == 1 and longsignal+ strategy.entry("Entry 2", strategy.long)-strategy.entry("Entry 3", strategy.long, when=strategy.opentrades == 2 and longsignal)+if strategy.opentrades == 2 and longsignal+ strategy.entry("Entry 3", strategy.long)-strategy.entry("Entry 4", strategy.long, when=strategy.opentrades == 3 and longsignal)+if strategy.opentrades == 3 and longsignal+ strategy.entry("Entry 4", strategy.long)-strategy.entry("Entry 5", strategy.long, when=strategy.opentrades == 4 and longsignal)+if strategy.opentrades == 4 and longsignal+ strategy.entry("Entry 5", strategy.long)-strategy.entry("Entry 6", strategy.long, when=strategy.opentrades == 5 and longsignal)+if strategy.opentrades == 5 and longsignal+ strategy.entry("Entry 6", strategy.long)-strategy.entry("Entry 7", strategy.long, when=strategy.opentrades == 6 and longsignal)+if strategy.opentrades == 6 and longsignal+ strategy.entry("Entry 7", strategy.long)if strategy.position_size > 0⋯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: 119 before, 119 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.
-//@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 |
|---|---|---|---|
| Over Bought (no label in the script) | 80 | int · min 50 | band1 hline |
| Over Sold (no label in the script) | 25 | int · max 50 | band0 long golong hline |
| RSI Length | 5 | int · min 1 | up down |
| Profit Target Percent (no label in the script) | 3 | int | Profit_Ticks |
| Loss Target Percent (no label in the script) | 10 | int | Loss_Ticks |
What it calculates
- RMA / Change (
rma,ta.rmain v5)max(change(src), 0), RSI Length (5)up · line 17 - RMA / Change (
rma,ta.rmain v5)-min(change(src), 0), RSI Length (5)down · line 18 - Highest (
highest,ta.highestin v5)high, phh · line 22 - Lowest (
lowest,ta.lowestin v5)low, pll · line 23
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 Entry 1 long | strategy.opentrades == 0 and longsignal | On | 55 |
| Open Entry 2 long | strategy.opentrades == 1 and longsignal | On | 56 |
| Open Entry 3 long | strategy.opentrades == 2 and longsignal | On | 57 |
| Open Entry 4 long | strategy.opentrades == 3 and longsignal | On | 58 |
| Open Entry 5 long | strategy.opentrades == 4 and longsignal | On | 59 |
| Open Entry 6 long | strategy.opentrades == 5 and longsignal | On | 60 |
| Open Entry 7 long | strategy.opentrades == 6 and longsignal | On | 61 |
| Exit Exit 1 stop and limit | strategy.position_size > 0 | On | 63 |
| Exit Exit 2 stop and limit | strategy.position_size > 0 | On | 64 |
| Exit Exit 3 stop and limit | strategy.position_size > 0 | On | 65 |
| Exit Exit 4 stop and limit | strategy.position_size > 0 | On | 66 |
| Exit Exit 5 stop and limit | strategy.position_size > 0 | On | 67 |
| Exit Exit 6 stop and limit | strategy.position_size > 0 | On | 68 |
| Exit Exit 7 stop and limit | strategy.position_size > 0 | On | 69 |
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 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 | −11.0% | +102.5% | 119 | 68% | 0.78 | 24.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +2.6% | +5.5% | 92 | 74% | 1.12 | 21.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +0.8% | +9.8% | 148 | 71% | 1.01 | 22.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −17.1% | +8.4% | 108 | 69% | 0.55 | 29.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +12.9% | +16.7% | 133 | 70% | 1.27 | 14.4% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −11.8% | +21.5% | 114 | 60% | 0.67 | 28.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +13.3% | +148.3% | 113 | 72% | 1.46 | 13.6% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +4.3% | +17.1% | 91 | 79% | 1.22 | 15.9% | 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 | 19 | 95% | $807.82 |
| Sideways market | 63 | 63% | −$953.70 |
| Falling market | 37 | 62% | −$951.83 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
20.6%
The 95th percentile of the worst drawdown when the same 119 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 11.6% to 20.6%; the tick is what actually happened, 21.9%. Order luck alone moves it this much.
All 119 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 14 Apr 2024 63,924.50 | 15 Apr 2024 65,894.40 | 1 | $58.54 |
| long | 18 Apr 2024 61,277.40 | 19 Apr 2024 63,470.10 | 1 | $68.86 |
| long | 1 May 2024 60,672.00 | 3 May 2024 60,136.80 | 2 | −$20.88 |
| long | 2 May 2024 58,365.00 | 3 May 2024 60,136.80 | 1 | $1.77 |
| long | 2 May 2024 58,365.00 | 3 May 2024 60,832.40 | 1 | $79.33 |
| long | 3 May 2024 59,060.60 | 3 May 2024 60,832.40 | 0 | $1.34 |
| long | 3 May 2024 59,060.60 | 3 May 2024 62,443.80 | 0 | $109.82 |
| long | 15 Jun 2024 66,044.00 | 24 Jun 2024 59,723.00 | 9 | −$199.93 |
| long | 19 Jun 2024 65,175.30 | 24 Jun 2024 58,854.30 | 5 | −$201.99 |
| long | 20 Jun 2024 64,974.40 | 24 Jun 2024 58,653.40 | 4 | −$202.33 |
| long | 21 Jun 2024 64,870.00 | 24 Jun 2024 58,549.00 | 3 | −$202.42 |
| long | 22 Jun 2024 64,143.60 | 25 Jun 2024 62,102.10 | 3 | −$66.34 |
| long | 22 Jun 2024 64,143.60 | 4 Jul 2024 58,122.70 | 12 | −$3.52 |
| long | 25 Jun 2024 60,293.30 | 4 Jul 2024 58,122.70 | 9 | −$70.16 |
| long | 5 Jul 2024 57,050.00 | 6 Jul 2024 58,327.70 | 1 | $39.02 |
| long | 6 Jul 2024 56,628.80 | 6 Jul 2024 58,327.70 | 0 | $0.31 |
| long | 6 Jul 2024 56,628.80 | 10 Jul 2024 58,748.90 | 4 | $66.62 |
| long | 3 Aug 2024 61,498.30 | 5 Aug 2024 55,682.20 | 2 | −$181.46 |
| long | 4 Aug 2024 60,698.00 | 5 Aug 2024 54,881.90 | 1 | −$183.31 |
| long | 5 Aug 2024 58,161.00 | 5 Aug 2024 52,344.90 | 0 | −$187.98 |
| long | 6 Aug 2024 54,018.80 | 7 Aug 2024 56,022.00 | 1 | $63.28 |
| long | 8 Aug 2024 55,133.80 | 9 Aug 2024 61,686.00 | 1 | $210.16 |
| long | 2 Sep 2024 57,301.80 | 3 Sep 2024 59,132.10 | 1 | $55.80 |
| long | 7 Sep 2024 53,963.00 | 9 Sep 2024 55,609.10 | 2 | $53.49 |
| long | 8 Sep 2024 54,160.90 | 9 Sep 2024 55,807.00 | 1 | $53.31 |
| long | 2 Oct 2024 60,804.90 | 4 Oct 2024 62,471.90 | 2 | $48.34 |
| long | 3 Oct 2024 60,649.30 | 4 Oct 2024 62,471.90 | 1 | $0.10 |
| long | 3 Oct 2024 60,649.30 | 6 Oct 2024 62,627.50 | 3 | $57.90 |
| long | 23 Dec 2024 95,186.30 | 24 Dec 2024 97,727.90 | 1 | $47.55 |
| long | 24 Dec 2024 94,881.50 | 24 Dec 2024 97,727.90 | 0 | $0.13 |
| long | 24 Dec 2024 94,881.50 | 24 Dec 2024 98,032.70 | 0 | $59.64 |
| long | 3 Feb 2025 97,700.60 | 4 Feb 2025 101,329.00 | 1 | $67.99 |
| long | 25 Feb 2025 91,552.90 | 26 Feb 2025 82,684.80 | 1 | −$189.03 |
| long | 26 Feb 2025 88,680.40 | 27 Feb 2025 86,777.60 | 1 | −$43.84 |
| long | 27 Feb 2025 84,250.10 | 27 Feb 2025 86,777.60 | 0 | $1.44 |
| long | 27 Feb 2025 84,250.10 | 28 Feb 2025 80,209.50 | 1 | −$89.72 |
| long | 28 Feb 2025 84,708.60 | 2 Mar 2025 86,931.90 | 2 | $46.12 |
| long | 28 Feb 2025 84,708.60 | 2 Mar 2025 87,290.50 | 2 | $0.39 |
| long | 1 Mar 2025 84,349.90 | 2 Mar 2025 87,290.50 | 1 | $61.91 |
| long | 11 Mar 2025 78,595.90 | 12 Mar 2025 82,933.00 | 1 | $100.88 |
| long | 7 Apr 2025 78,430.00 | 8 Apr 2025 80,804.90 | 1 | $54.66 |
| long | 9 Apr 2025 76,322.40 | 10 Apr 2025 82,615.20 | 1 | $154.64 |
| long | 6 Jun 2025 101,509.00 | 7 Jun 2025 104,637.00 | 1 | $56.92 |
| long | 22 Jun 2025 102,120.00 | 23 Jun 2025 103,993.00 | 1 | $32.88 |
| long | 23 Jun 2025 100,964.00 | 23 Jun 2025 103,993.00 | 0 | $0.50 |
| long | 23 Jun 2025 100,964.00 | 23 Jun 2025 105,149.00 | 0 | $77.12 |
| long | 2 Aug 2025 113,298.00 | 7 Aug 2025 115,996.00 | 5 | $44.06 |
| long | 3 Aug 2025 112,546.00 | 7 Aug 2025 115,996.00 | 4 | $0.30 |
| long | 3 Aug 2025 112,546.00 | 7 Aug 2025 116,748.00 | 4 | $70.28 |
| long | 20 Aug 2025 112,873.00 | 22 Aug 2025 116,248.00 | 2 | $56.73 |
| long | 23 Sep 2025 112,651.00 | 28 Sep 2025 112,284.00 | 5 | −$9.57 |
| long | 24 Sep 2025 111,999.00 | 28 Sep 2025 112,284.00 | 4 | $0.04 |
| long | 24 Sep 2025 111,999.00 | 1 Oct 2025 115,420.00 | 7 | $57.06 |
| long | 26 Sep 2025 108,994.00 | 1 Oct 2025 115,420.00 | 5 | $2.35 |
| long | 26 Sep 2025 108,994.00 | 1 Oct 2025 115,940.00 | 5 | $120.94 |
| long | 11 Oct 2025 112,774.00 | 12 Oct 2025 113,964.00 | 1 | $18.48 |
| long | 12 Oct 2025 110,644.00 | 12 Oct 2025 113,964.00 | 0 | $0.87 |
| long | 12 Oct 2025 110,644.00 | 20 Oct 2025 109,691.00 | 8 | −$20.28 |
| long | 17 Oct 2025 108,194.00 | 20 Oct 2025 109,691.00 | 3 | $1.21 |
| long | 17 Oct 2025 108,194.00 | 20 Oct 2025 111,454.00 | 3 | $55.52 |
| long | 18 Oct 2025 106,432.00 | 20 Oct 2025 111,454.00 | 2 | $4.40 |
| long | 18 Oct 2025 106,432.00 | 27 Oct 2025 116,094.00 | 9 | $172.14 |
| long | 5 Nov 2025 101,497.00 | 9 Nov 2025 104,567.00 | 4 | $60.05 |
| long | 15 Nov 2025 94,594.00 | 20 Nov 2025 86,440.70 | 5 | −$182.70 |
| long | 15 Nov 2025 94,594.00 | 21 Nov 2025 85,930.30 | 6 | −$1.67 |
| long | 16 Nov 2025 95,596.20 | 21 Nov 2025 85,930.30 | 5 | −$216.05 |
| long | 17 Nov 2025 94,261.40 | 21 Nov 2025 85,597.70 | 4 | −$195.54 |
| long | 18 Nov 2025 92,215.10 | 21 Nov 2025 84,297.10 | 3 | −$180.16 |
| long | 18 Nov 2025 92,215.10 | 21 Nov 2025 83,551.40 | 3 | −$0.36 |
| long | 19 Nov 2025 92,960.80 | 21 Nov 2025 83,551.40 | 2 | −$213.53 |
| long | 22 Nov 2025 85,129.40 | 23 Nov 2025 87,281.90 | 1 | $45.28 |
| long | 23 Nov 2025 84,739.80 | 23 Nov 2025 87,281.90 | 0 | $0.19 |
| long | 23 Nov 2025 84,739.80 | 23 Nov 2025 87,671.60 | 0 | $62.72 |
| long | 16 Dec 2025 86,432.10 | 17 Dec 2025 89,068.00 | 1 | $55.82 |
| long | 21 Jan 2026 88,427.70 | 23 Jan 2026 91,114.50 | 2 | $55.93 |
| long | 26 Jan 2026 86,670.40 | 27 Jan 2026 89,320.80 | 1 | $56.63 |
| long | 30 Jan 2026 84,650.20 | 31 Jan 2026 76,224.10 | 1 | −$197.92 |
| long | 31 Jan 2026 84,260.50 | 31 Jan 2026 75,834.40 | 0 | −$198.61 |
| long | 1 Feb 2026 78,741.10 | 2 Feb 2026 79,277.30 | 1 | $9.98 |
| long | 2 Feb 2026 76,968.20 | 2 Feb 2026 79,277.30 | 0 | $0.96 |
| long | 2 Feb 2026 76,968.20 | 5 Feb 2026 71,422.00 | 3 | −$135.15 |
| long | 3 Feb 2026 78,738.60 | 5 Feb 2026 71,422.00 | 2 | −$0.98 |
| long | 3 Feb 2026 78,738.60 | 5 Feb 2026 71,044.30 | 2 | −$186.50 |
| long | 4 Feb 2026 75,770.20 | 5 Feb 2026 68,453.60 | 1 | −$182.53 |
| long | 5 Feb 2026 73,165.80 | 5 Feb 2026 65,849.30 | 0 | −$185.07 |
| long | 6 Feb 2026 62,909.90 | 7 Feb 2026 70,580.30 | 1 | $210.02 |
| long | 24 Feb 2026 64,656.00 | 25 Feb 2026 65,979.90 | 1 | $33.89 |
| long | 25 Feb 2026 64,058.20 | 25 Feb 2026 65,979.90 | 0 | $0.37 |
| long | 25 Feb 2026 64,058.20 | 25 Feb 2026 66,577.80 | 0 | $66.94 |
| long | 23 May 2026 75,539.50 | 25 May 2026 77,851.40 | 2 | $52.57 |
| long | 28 May 2026 74,449.30 | 2 Jun 2026 67,308.40 | 5 | −$176.97 |
| long | 29 May 2026 73,617.50 | 2 Jun 2026 66,476.60 | 4 | −$178.52 |
| long | 30 May 2026 73,460.80 | 2 Jun 2026 66,319.90 | 3 | −$178.71 |
| long | 2 Jun 2026 71,408.90 | 3 Jun 2026 64,732.80 | 1 | −$169.09 |
| long | 3 Jun 2026 66,760.80 | 5 Jun 2026 60,372.20 | 2 | −$163.92 |
| long | 4 Jun 2026 64,142.80 | 7 Jun 2026 62,711.20 | 3 | −$39.61 |
| long | 5 Jun 2026 63,886.00 | 7 Jun 2026 62,711.20 | 2 | −$0.65 |
| long | 5 Jun 2026 63,886.00 | 7 Jun 2026 62,883.00 | 2 | −$27.99 |
| long | 6 Jun 2026 61,056.50 | 7 Jun 2026 62,883.00 | 1 | $1.62 |
| long | 6 Jun 2026 61,056.50 | 11 Jun 2026 63,356.30 | 5 | $56.25 |
| long | 7 Jun 2026 60,884.60 | 11 Jun 2026 63,356.30 | 4 | $2.60 |
| long | 7 Jun 2026 60,884.60 | 11 Jun 2026 63,575.30 | 4 | $65.87 |
| long | 10 Jun 2026 61,730.00 | 11 Jun 2026 63,575.30 | 1 | $2.08 |
| long | 10 Jun 2026 61,730.00 | 15 Jun 2026 65,858.40 | 5 | $102.27 |
| long | 11 Jun 2026 61,511.00 | 15 Jun 2026 65,858.40 | 4 | $2.73 |
| long | 11 Jun 2026 61,511.00 | 15 Jun 2026 65,969.30 | 4 | $113.18 |
| long | 26 Jun 2026 59,794.60 | 1 Jul 2026 60,383.50 | 5 | $14.18 |
| long | 27 Jun 2026 60,097.30 | 1 Jul 2026 60,383.50 | 4 | $0.01 |
| long | 27 Jun 2026 60,097.30 | 2 Jul 2026 61,377.70 | 5 | $33.60 |
| long | 28 Jun 2026 60,029.00 | 2 Jul 2026 61,377.70 | 4 | $0.21 |
| long | 28 Jun 2026 60,029.00 | 2 Jul 2026 61,553.40 | 4 | $40.37 |
| long | 29 Jun 2026 59,577.00 | 2 Jul 2026 61,553.40 | 3 | $0.50 |
| long | 29 Jun 2026 59,577.00 | 2 Jul 2026 61,829.70 | 3 | $60.84 |
| long | 1 Jul 2026 58,624.70 | 2 Jul 2026 61,829.70 | 1 | $0.58 |
| long | 1 Jul 2026 58,624.70 | 2 Jul 2026 61,898.00 | 1 | $90.13 |
| long | 15 Aug 2026 63,043.60 | 18 Aug 2026 64,836.00 | 3 | $47.05 |
| long | 17 Aug 2026 62,900.00 | 18 Aug 2026 64,836.00 | 1 | $0.09 |
| long | 17 Aug 2026 62,900.00 | 18 Aug 2026 64,979.50 | 1 | $55.01 |
| long | 9 Oct 2026 81,754.50 | 12 Oct 2026 84,267.70 | 3 | $51.68 |
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 |
|---|---|---|---|---|---|
| Simple RSI strategy this page | — | v4 strategy | −11.0% | 119 | 24.4% |
| Wilder's Volatility Trailing Stop Strategy with various MA's by SparkyFlary | rma lowest highest | v4 strategy | +16.9% | 15 | 41.6% |
| HiLo Extension by Saravanan_Ragavan | lowest highest rma | v4 strategy | No trades on this market | ||
| Directional Movement Index by wojak_bogdanoff | lowest highest rma | v5 strategy | +49.7% | 35 | 19.4% |
| Alex Days HiLo Rajib by 14rajib | highest lowest | v4 strategy | No trades on this market | ||
| Donchian Strat EXMO by pskoroplas | highest lowest | v4 strategy | +12.1% | 22 | 68.0% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 21 ms | Yes 1,000 bars in 52 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not 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. 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/// © RafaelZionistrategy(title='Simple RSI strategy', overlay=false, pyramiding=5, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=20, commission_type=strategy.commission.percent, commission_value=0.075)SWperiod = 1look = 0OverBought = input(80, minval=50)OverSold = input(25, maxval=50)bandmx = hline(100)bandmn = hline(0)band1 = hline(OverBought)band0 = hline(OverSold)//band50 = hline(50, color=black, linewidth=1)fill(band1, band0, color=color.purple, transp=98)src = closelen = input(5, minval=1, title="RSI Length")up = rma(max(change(src), 0), len)down = rma(-min(change(src), 0), len)rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)p = 100//scalehh = highest(high, p)ll = lowest(low, p)scale = hh - ll//dynamic OHLCdyno = (open - ll) / scale * 100dynl = (low - ll) / scale * 100dynh = (high - ll) / scale * 100dync = (close - ll) / scale * 100//candle colorcolor_1 = close > open ? 1 : 0//drawcandlehline(78.6)hline(61.8)hline(50)hline(38.2)hline(23.6)plotcandle(dyno, dynh, dynl, dync, title="Candle", color=color_1 == 1 ? color.green : color.red)plot(10, color=color.green)plot(55, color=color.black)plot(80, color=color.black)plot(90, color=color.red)long = rsi <= OverSold ? 5 : na//Strategygolong = rsi <= OverSold ? 5 : nalongsignal = golong //based on https://www.tradingview.com/script/7NNJ0sXB-Pyramiding-Entries-On-Early-Trends-by-Coinrule///set take profitProfitTarget_Percent = input(3)Profit_Ticks = close * (ProfitTarget_Percent / 100) / syminfo.mintick//set take profitLossTarget_Percent = input(10)Loss_Ticks = close * (LossTarget_Percent / 100) / syminfo.mintick//Order Placingstrategy.entry("Entry 1", strategy.long, when=strategy.opentrades == 0 and longsignal)strategy.entry("Entry 2", strategy.long, when=strategy.opentrades == 1 and longsignal)strategy.entry("Entry 3", strategy.long, when=strategy.opentrades == 2 and longsignal)strategy.entry("Entry 4", strategy.long, when=strategy.opentrades == 3 and longsignal)strategy.entry("Entry 5", strategy.long, when=strategy.opentrades == 4 and longsignal)strategy.entry("Entry 6", strategy.long, when=strategy.opentrades == 5 and longsignal)strategy.entry("Entry 7", strategy.long, when=strategy.opentrades == 6 and longsignal)if strategy.position_size > 0 strategy.exit(id="Exit 1", from_entry="Entry 1", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 2", from_entry="Entry 2", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 3", from_entry="Entry 3", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 4", from_entry="Entry 4", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 5", from_entry="Entry 5", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 6", from_entry="Entry 6", profit=Profit_Ticks, loss=Loss_Ticks) strategy.exit(id="Exit 7", from_entry="Entry 7", profit=Profit_Ticks, loss=Loss_Ticks)