Pine Script v5 · Strategy
BTC-USD - RSI
A Pine Script v5 strategy built on RSI (close, 14). It has 6 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 8 settings; defaults include Length 14, Buy Level 1 27 and Buy Level 2 18.
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 BTC-USD - RSI repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 24 of 24 trades.
- How did BTC-USD - RSI do on BTCUSDT 1D with default settings?
- −20.00%
- From 26 Jan 2024 to 21 Oct 2026, over 104 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does BTC-USD - RSI 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: 104 before, 0 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 BTC-USD - RSI use a stop loss?
- Yes
- strategy.exit sets a stop on line 35, 36.
- Does BTC-USD - RSI run in Zeal Terminal?
- Yes
- It compiles in 16 ms and runs 1,000 bars in 32 ms, in the browser.
BTCUSDT · 1D · default settings
- Overbought Zone
- Overbought Zone
- Oversold Zone
- Oversold Zone
- RSI
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- −20.00%
- −$1,000.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 104
- 56 won · 48 lost
- Profitable
- 53.8%
- of closed trades
- Profit factor
- 0.58
- gross profit ÷ gross loss
- Max drawdown
- 22.33%
- −$1,150.00
One run with the author's default settings, $5,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 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.
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 |
|---|---|---|---|
| LengthRSI period | 14 | int | vrsi |
| Buy Level 1Level where 1st buy triggers | 27 | int | long1 hline |
| Buy Level 2Level where 2nd buy triggers | 18 | int | long1 long2 hline |
| Sell Level 1Level where 1st sell triggers | 68 | int | short1 hline |
| Sell Level 2Level where 2nd sell triggers | 80 | int | short1 short2 hline |
| target PipsFixed pip stop loss distance | 2500 | int | exit Long Exit exit Short Exit |
| Stop PipsFixed pip stop loss distance | 5000 | int | exit Long Exit exit Short Exit |
| Lot SizeTrading Lot size | 1 | int | entry Long entry Short exit Long Exit exit Short Exit |
What it calculates
- RSIclose, Length (14)
vrsi · line 16
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 | (long1 and strategy.position_size == 0) | On | 25 |
| Open Long long | (long2 and strategy.position_size == 0) | On | 27 |
| Open Short short | (short1 and strategy.position_size == 0) | On | 30 |
| Open Short short | (short2 and strategy.position_size == 0) | On | 32 |
| Exit Long Exit stop and limit | every bar | On | 35 |
| Exit Short Exit stop and limit | every bar | On | 36 |
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 | −20.0% | +102.5% | 104 | 54% | 0.58 | 22.3% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −11.0% | +5.5% | 74 | 57% | 0.66 | 14.9% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −10.0% | +9.8% | 88 | 59% | 0.72 | 13.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.5% | +8.4% | 41 | 66% | 0.96 | 3.9% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +1.0% | +16.7% | 11 | 73% | 1.33 | 1.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +1.0% | +21.5% | 2 | 100% | — | 0.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −2.5% | +148.3% | 46 | 63% | 0.85 | 5.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +2.0% | +17.1% | 16 | 75% | 1.50 | 1.5% | 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 | 50 | 58% | −$325.00 |
| Sideways market | 47 | 47% | −$700.00 |
| Falling market | 7 | 71% | $25.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
23.9%
The 95th percentile of the worst drawdown when the same 104 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 20.0% to 23.9%; the tick is what actually happened, 22.3%. Order luck alone moves it this much.
All 104 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 22 Feb 2024 51,849.40 | 22 Feb 2024 51,899.40 | 0 | −$50.00 |
| short | 23 Feb 2024 51,288.40 | 23 Feb 2024 51,338.40 | 0 | −$50.00 |
| short | 24 Feb 2024 50,744.20 | 24 Feb 2024 50,719.20 | 0 | $25.00 |
| short | 25 Feb 2024 51,568.20 | 25 Feb 2024 51,543.20 | 0 | $25.00 |
| short | 26 Feb 2024 51,728.80 | 26 Feb 2024 51,703.80 | 0 | $25.00 |
| short | 27 Feb 2024 54,476.50 | 27 Feb 2024 54,451.50 | 0 | $25.00 |
| short | 6 Mar 2024 63,724.00 | 6 Mar 2024 63,699.00 | 0 | $25.00 |
| short | 7 Mar 2024 66,074.00 | 7 Mar 2024 66,049.00 | 0 | $25.00 |
| short | 8 Mar 2024 66,823.20 | 8 Mar 2024 66,798.20 | 0 | $25.00 |
| short | 9 Mar 2024 68,124.20 | 9 Mar 2024 68,099.20 | 0 | $25.00 |
| short | 10 Mar 2024 68,313.30 | 10 Mar 2024 68,288.30 | 0 | $25.00 |
| short | 11 Mar 2024 68,955.90 | 11 Mar 2024 68,930.90 | 0 | $25.00 |
| short | 12 Mar 2024 72,078.10 | 12 Mar 2024 72,128.10 | 0 | −$50.00 |
| short | 13 Mar 2024 71,452.00 | 13 Mar 2024 71,427.00 | 0 | $25.00 |
| short | 14 Mar 2024 73,072.40 | 14 Mar 2024 73,122.40 | 0 | −$50.00 |
| short | 15 Mar 2024 71,388.90 | 15 Mar 2024 71,438.90 | 0 | −$50.00 |
| long | 25 Jun 2024 60,293.30 | 25 Jun 2024 60,318.30 | 0 | $25.00 |
| long | 6 Aug 2024 54,018.80 | 6 Aug 2024 53,968.80 | 0 | −$50.00 |
| short | 19 Oct 2024 68,428.00 | 19 Oct 2024 68,478.00 | 0 | −$50.00 |
| short | 20 Oct 2024 68,378.00 | 20 Oct 2024 68,353.00 | 0 | $25.00 |
| short | 21 Oct 2024 69,032.00 | 21 Oct 2024 69,082.00 | 0 | −$50.00 |
| short | 30 Oct 2024 72,736.40 | 30 Oct 2024 72,786.40 | 0 | −$50.00 |
| short | 31 Oct 2024 72,344.80 | 31 Oct 2024 72,394.80 | 0 | −$50.00 |
| short | 7 Nov 2024 75,572.00 | 7 Nov 2024 75,547.00 | 0 | $25.00 |
| short | 8 Nov 2024 75,857.90 | 8 Nov 2024 75,832.90 | 0 | $25.00 |
| short | 9 Nov 2024 76,509.80 | 9 Nov 2024 76,559.80 | 0 | −$50.00 |
| short | 10 Nov 2024 76,677.50 | 10 Nov 2024 76,652.50 | 0 | $25.00 |
| short | 11 Nov 2024 80,370.00 | 11 Nov 2024 80,345.00 | 0 | $25.00 |
| short | 15 Nov 2024 87,325.60 | 15 Nov 2024 87,300.60 | 0 | $25.00 |
| short | 16 Nov 2024 91,032.10 | 16 Nov 2024 91,082.10 | 0 | −$50.00 |
| short | 17 Nov 2024 90,588.00 | 17 Nov 2024 90,638.00 | 0 | −$50.00 |
| short | 18 Nov 2024 89,856.00 | 18 Nov 2024 89,831.00 | 0 | $25.00 |
| short | 19 Nov 2024 90,464.10 | 19 Nov 2024 90,439.10 | 0 | $25.00 |
| short | 20 Nov 2024 92,310.80 | 20 Nov 2024 92,285.80 | 0 | $25.00 |
| short | 21 Nov 2024 94,286.60 | 21 Nov 2024 94,261.60 | 0 | $25.00 |
| short | 24 Nov 2024 97,672.40 | 24 Nov 2024 97,722.40 | 0 | −$50.00 |
| short | 25 Nov 2024 97,900.10 | 25 Nov 2024 97,950.10 | 0 | −$50.00 |
| short | 30 Nov 2024 97,460.00 | 30 Nov 2024 97,435.00 | 0 | $25.00 |
| short | 9 Dec 2024 101,110.00 | 9 Dec 2024 101,160.00 | 0 | −$50.00 |
| short | 17 Dec 2024 106,059.00 | 17 Dec 2024 106,034.00 | 0 | $25.00 |
| short | 18 Dec 2024 106,134.00 | 18 Dec 2024 106,184.00 | 0 | −$50.00 |
| long | 27 Feb 2025 84,250.10 | 27 Feb 2025 84,200.10 | 0 | −$50.00 |
| long | 28 Feb 2025 84,708.60 | 28 Feb 2025 84,733.60 | 0 | $25.00 |
| long | 1 Mar 2025 84,349.90 | 1 Mar 2025 84,299.90 | 0 | −$50.00 |
| short | 25 Apr 2025 93,980.50 | 25 Apr 2025 93,955.50 | 0 | $25.00 |
| short | 26 Apr 2025 94,638.70 | 26 Apr 2025 94,688.70 | 0 | −$50.00 |
| short | 27 Apr 2025 94,628.00 | 27 Apr 2025 94,678.00 | 0 | −$50.00 |
| short | 29 Apr 2025 95,011.20 | 29 Apr 2025 95,061.20 | 0 | −$50.00 |
| short | 2 May 2025 96,489.90 | 2 May 2025 96,464.90 | 0 | $25.00 |
| short | 3 May 2025 96,887.10 | 3 May 2025 96,862.10 | 0 | $25.00 |
| short | 9 May 2025 103,262.00 | 9 May 2025 103,237.00 | 0 | $25.00 |
| short | 10 May 2025 102,972.00 | 10 May 2025 102,947.00 | 0 | $25.00 |
| short | 11 May 2025 104,810.00 | 11 May 2025 104,860.00 | 0 | −$50.00 |
| short | 12 May 2025 104,118.00 | 12 May 2025 104,168.00 | 0 | −$50.00 |
| short | 13 May 2025 102,791.00 | 13 May 2025 102,766.00 | 0 | $25.00 |
| short | 14 May 2025 104,104.00 | 14 May 2025 104,154.00 | 0 | −$50.00 |
| short | 15 May 2025 103,508.00 | 15 May 2025 103,558.00 | 0 | −$50.00 |
| short | 16 May 2025 103,764.00 | 16 May 2025 103,739.00 | 0 | $25.00 |
| short | 17 May 2025 103,464.00 | 17 May 2025 103,514.00 | 0 | −$50.00 |
| short | 19 May 2025 106,454.00 | 19 May 2025 106,504.00 | 0 | −$50.00 |
| short | 20 May 2025 105,574.00 | 20 May 2025 105,549.00 | 0 | $25.00 |
| short | 21 May 2025 106,850.00 | 21 May 2025 106,825.00 | 0 | $25.00 |
| short | 22 May 2025 109,644.00 | 22 May 2025 109,619.00 | 0 | $25.00 |
| short | 23 May 2025 111,696.00 | 23 May 2025 111,746.00 | 0 | −$50.00 |
| short | 11 Jul 2025 116,010.00 | 11 Jul 2025 115,985.00 | 0 | $25.00 |
| short | 12 Jul 2025 117,528.00 | 12 Jul 2025 117,503.00 | 0 | $25.00 |
| short | 13 Jul 2025 117,420.00 | 13 Jul 2025 117,395.00 | 0 | $25.00 |
| short | 14 Jul 2025 119,087.00 | 14 Jul 2025 119,062.00 | 0 | $25.00 |
| short | 15 Jul 2025 119,841.00 | 15 Jul 2025 119,891.00 | 0 | −$50.00 |
| short | 17 Jul 2025 118,630.00 | 17 Jul 2025 118,605.00 | 0 | $25.00 |
| short | 18 Jul 2025 119,178.00 | 18 Jul 2025 119,228.00 | 0 | −$50.00 |
| short | 23 Jul 2025 119,954.00 | 23 Jul 2025 120,004.00 | 0 | −$50.00 |
| short | 14 Aug 2025 123,306.00 | 14 Aug 2025 123,356.00 | 0 | −$50.00 |
| short | 4 Oct 2025 122,232.00 | 4 Oct 2025 122,282.00 | 0 | −$50.00 |
| short | 5 Oct 2025 122,391.00 | 5 Oct 2025 122,366.00 | 0 | $25.00 |
| short | 6 Oct 2025 123,482.00 | 6 Oct 2025 123,457.00 | 0 | $25.00 |
| short | 7 Oct 2025 124,659.00 | 7 Oct 2025 124,709.00 | 0 | −$50.00 |
| long | 21 Nov 2025 86,637.20 | 21 Nov 2025 86,662.20 | 0 | $25.00 |
| long | 22 Nov 2025 85,129.40 | 22 Nov 2025 85,154.40 | 0 | $25.00 |
| long | 23 Nov 2025 84,739.80 | 23 Nov 2025 84,689.80 | 0 | −$50.00 |
| short | 15 Jan 2026 96,951.80 | 15 Jan 2026 97,001.80 | 0 | −$50.00 |
| long | 1 Feb 2026 78,741.10 | 1 Feb 2026 78,766.10 | 0 | $25.00 |
| long | 2 Feb 2026 76,968.20 | 2 Feb 2026 76,918.20 | 0 | −$50.00 |
| long | 4 Feb 2026 75,770.20 | 4 Feb 2026 75,795.20 | 0 | $25.00 |
| long | 5 Feb 2026 73,165.80 | 5 Feb 2026 73,190.80 | 0 | $25.00 |
| short | 7 May 2026 81,447.00 | 7 May 2026 81,497.00 | 0 | −$50.00 |
| short | 11 May 2026 82,210.10 | 11 May 2026 82,260.10 | 0 | −$50.00 |
| long | 3 Jun 2026 66,760.80 | 3 Jun 2026 66,785.80 | 0 | $25.00 |
| long | 4 Jun 2026 64,142.80 | 4 Jun 2026 64,167.80 | 0 | $25.00 |
| long | 5 Jun 2026 63,886.00 | 5 Jun 2026 63,911.00 | 0 | $25.00 |
| long | 8 Jun 2026 63,332.00 | 8 Jun 2026 63,357.00 | 0 | $25.00 |
| long | 9 Jun 2026 63,086.00 | 9 Jun 2026 63,111.00 | 0 | $25.00 |
| long | 10 Jun 2026 61,730.00 | 10 Jun 2026 61,680.00 | 0 | −$50.00 |
| long | 11 Jun 2026 61,511.00 | 11 Jun 2026 61,536.00 | 0 | $25.00 |
| short | 20 Aug 2026 69,334.80 | 20 Aug 2026 69,309.80 | 0 | $25.00 |
| short | 26 Aug 2026 78,539.10 | 26 Aug 2026 78,589.10 | 0 | −$50.00 |
| short | 29 Aug 2026 77,845.90 | 29 Aug 2026 77,820.90 | 0 | $25.00 |
| short | 30 Aug 2026 78,230.00 | 30 Aug 2026 78,280.00 | 0 | −$50.00 |
| short | 31 Aug 2026 77,682.00 | 31 Aug 2026 77,657.00 | 0 | $25.00 |
| short | 1 Sep 2026 78,581.30 | 1 Sep 2026 78,631.30 | 0 | −$50.00 |
| short | 4 Sep 2026 81,270.40 | 4 Sep 2026 81,320.40 | 0 | −$50.00 |
| short | 22 Sep 2026 86,620.00 | 22 Sep 2026 86,670.00 | 0 | −$50.00 |
| short | 23 Sep 2026 86,208.60 | 23 Sep 2026 86,258.60 | 0 | −$50.00 |
| short | 5 Oct 2026 86,530.00 | 5 Oct 2026 86,580.00 | 0 | −$50.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 |
|---|---|---|---|---|---|
| BTC-USD - RSI this page | — | v5 strategy | −20.0% | 104 | 22.3% |
| Triple RSI strategy by Trade_by_DB | rsi | v5 strategy | +3.2% | 2 | 3.3% |
| Hobbiecode - RSI + Close previous day by hobbiecode | rsi | v5 strategy | +1.2% | 63 | 4.2% |
| dirt cheap yet elegant RSI Strategy by SparkyFlary | rsi | v4 strategy | −11.4% | 8 | 20.5% |
| RSI Classic Strategy (by Coinrule) by Coinrule | rsi | v4 strategy | +7.5% | 6 | 7.2% |
| RSITrendStrategy by email_analysts | rsi | v4 strategy | +69.2% | 22 | 38.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.
- 8 settings use the untyped input() (line 7, 8, 9, 10, 11, 12, 13, 14). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Same 104 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 9: input() → input.int()
- Line 10: input() → input.int()
- Line 11: input() → input.int()
- Line 12: input() → input.int()
- Line 13: input() → input.int()
- Line 14: input() → input.int()
⋯// User input-length = input(title = "Length", defval=14, tooltip="RSI period")+length = input.int(title = "Length", defval=14, tooltip="RSI period")-first_buy_level = input(title = "Buy Level 1", defval=27, tooltip="Level where 1st buy triggers")+first_buy_level = input.int(title = "Buy Level 1", defval=27, tooltip="Level where 1st buy triggers")-second_buy_level = input(title = "Buy Level 2", defval=18, tooltip="Level where 2nd buy triggers")+second_buy_level = input.int(title = "Buy Level 2", defval=18, tooltip="Level where 2nd buy triggers")-first_sell_level = input(title = "Sell Level 1", defval=68, tooltip="Level where 1st sell triggers")+first_sell_level = input.int(title = "Sell Level 1", defval=68, tooltip="Level where 1st sell triggers")-second_sell_level = input(title = "Sell Level 2", defval=80, tooltip="Level where 2nd sell triggers")+second_sell_level = input.int(title = "Sell Level 2", defval=80, tooltip="Level where 2nd sell triggers")-takeProfit= input(title="target Pips", defval=2500, tooltip="Fixed pip stop loss distance")+takeProfit= input.int(title="target Pips", defval=2500, tooltip="Fixed pip stop loss distance")-stopLoss = input(title="Stop Pips", defval=5000, tooltip="Fixed pip stop loss distance")+stopLoss = input.int(title="Stop Pips", defval=5000, tooltip="Fixed pip stop loss distance")-lot = input(title = "Lot Size", defval = 1, tooltip="Trading Lot size")+lot = input.int(title = "Lot Size", defval = 1, tooltip="Trading Lot size")// Get RSI⋯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: 104 before, 0 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.
⋯// Ramy's Algorithm-//@version=5+//@version=6strategy("BTC/USD - RSI", overlay=false, initial_capital = 5000)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 16 ms | With a workaround 1,000 bars in 32 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
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.
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/// © Rawadabdo// Ramy's Algorithm//@version=5strategy("BTC/USD - RSI", overlay=false, initial_capital = 5000)// User inputlength = input(title = "Length", defval=14, tooltip="RSI period")first_buy_level = input(title = "Buy Level 1", defval=27, tooltip="Level where 1st buy triggers")second_buy_level = input(title = "Buy Level 2", defval=18, tooltip="Level where 2nd buy triggers")first_sell_level = input(title = "Sell Level 1", defval=68, tooltip="Level where 1st sell triggers")second_sell_level = input(title = "Sell Level 2", defval=80, tooltip="Level where 2nd sell triggers")takeProfit= input(title="target Pips", defval=2500, tooltip="Fixed pip stop loss distance")stopLoss = input(title="Stop Pips", defval=5000, tooltip="Fixed pip stop loss distance")lot = input(title = "Lot Size", defval = 1, tooltip="Trading Lot size")// Get RSIvrsi = ta.rsi(close, length)// Entry Conditionslong1 = (vrsi <= first_buy_level and vrsi>second_buy_level)long2 = (vrsi <= second_buy_level)short1= (vrsi >= first_sell_level and vrsi<second_sell_level)short2= (vrsi >= second_sell_level)// Entry Orders// Buy Ordersif (long1 and strategy.position_size == 0) strategy.entry("Long", strategy.long, qty=lot, comment="Buy") if (long2 and strategy.position_size == 0) strategy.entry("Long", strategy.long, qty=lot, comment="Buy")// Short Ordersif (short1 and strategy.position_size == 0) strategy.entry("Short", strategy.short,qty=lot, comment="Sell") if (short2 and strategy.position_size == 0) strategy.entry("Short", strategy.short,qty=lot, comment="Sell") // Exit our trade if our stop loss or take profit is hitstrategy.exit(id="Long Exit", from_entry="Long",qty = lot, profit=takeProfit, loss=stopLoss)strategy.exit(id="Short Exit", from_entry="Short", qty = lot, profit=takeProfit, loss=stopLoss)// plot data to the charthline(first_sell_level, "Overbought Zone", color=color.red, linestyle=hline.style_dashed, linewidth = 2)hline(second_sell_level, "Overbought Zone", color=color.green, linestyle=hline.style_dashed, linewidth = 2)hline(first_buy_level, "Oversold Zone", color=color.red, linestyle=hline.style_dashed, linewidth = 2)hline(second_buy_level, "Oversold Zone", color=color.green, linestyle=hline.style_dashed, linewidth = 2)plot (vrsi, title = "RSI", color = color.blue, linewidth=2)