Pine Script v4 · Strategy
Relative Volume & RSI Pop
A Pine Script v4 strategy built on RSI (price, 14), Crossover (vrsi, 70) and Crossunder (vrsi, 35). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 5 settings; defaults include RSI Period 14, RSI buy 70 and RSI short 35.
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 Relative Volume & RSI Pop repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
- How did Relative Volume & RSI Pop do on BTCUSDT 1D with default settings?
- +38.88%
- From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Relative Volume & RSI Pop 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 Relative Volume & RSI Pop use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Relative Volume & RSI Pop run in Zeal Terminal?
- Yes
- It compiles in 9 ms and runs 1,000 bars in 25 ms, in the browser.
BTCUSDT · 1D · default settings
- RSI
- Upper Band
- Middle Band
- Lower Band
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +38.88%
- $38,879.20
- Buy and hold
- +102.5%
- same period
- Closed trades
- 17
- 8 won · 9 lost
- Profitable
- 47.1%
- of closed trades
- Profit factor
- 3.35
- gross profit ÷ gross loss
- Max drawdown
- 5.67%
- −$5,674.02
One run with the author's default settings, $100,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 33, 37. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 19
transp = on line 19. 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 rsi → ta.rsi, crossover → ta.crossover, crossunder → ta.crossunder, sma → ta.sma.
- 2 strategy calls use the when = argument (line 33, 37). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: //@version=4 → //@version=5
- Line 12: rsi → ta.rsi
- Line 13: crossover → ta.crossover
- Line 14: crossunder → ta.crossunder
- Line 19: transp = 90 → color.new(color.purple, 90)
- Line 22: sma → ta.sma
⋯//Drawdown is typically low as it exits out of the trade once the RSI returns back to "normal levels".-//@version=4+//@version=5strategy(title="Relative Volume & RSI Pop", shorttitle="VOL & RSI Pop", overlay=false, precision=2, margin_long=100, margin_short=100)⋯price = close-vrsi = rsi(price, RSIlength)+vrsi = ta.rsi(price, RSIlength)-RSIco = crossover(vrsi, RSItop)+RSIco = ta.crossover(vrsi, RSItop)-RSIcu = crossunder(vrsi, RSIbottom)+RSIcu = ta.crossunder(vrsi, RSIbottom)plot(vrsi, "RSI", color=color.purple)⋯band0 = hline(30, "Lower Band", color=#C0C0C0)-fill(band1, band0, color=color.purple, transp=90, title="Background")+fill(band1, band0, color=color.new(color.purple, 90), title="Background")//RELATIVE VOLUMERVOLlen = input(14, minval=1, title="RV Period")-av = sma(volume, RVOLlen)+av = ta.sma(volume, RVOLlen)RVOL = volume / av⋯Same 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 8: input() → input.int()
- Line 9: input() → input.int()
- Line 10: input() → input.int()
- Line 21: input() → input.int()
- Line 24: input() → input.float()
- Line 33: when = CloseLong → if block
- Line 37: when = CloseShort → if block
⋯//RSI-RSIlength = input(14, title="RSI Period")+RSIlength = input.int(14, title="RSI Period")-RSItop = input(70, title="RSI buy", minval= 69, maxval=100)+RSItop = input.int(70, title="RSI buy", minval= 69, maxval=100)-RSIbottom = input(35, title="RSI short", minval= 0, maxval=35)+RSIbottom = input.int(35, title="RSI short", minval= 0, maxval=35)price = close⋯//RELATIVE VOLUME-RVOLlen = input(14, minval=1, title="RV Period")+RVOLlen = input.int(14, minval=1, title="RV Period")av = ta.sma(volume, RVOLlen)RVOL = volume / av-RVOLthreshold = input(1.5,title="RV Threshold", minval=0.5, maxval=10)+RVOLthreshold = input.float(1.5,title="RV Threshold", minval=0.5, maxval=10)//TRADE TRIGGERS⋯ -strategy.close("Long", when = CloseLong) +if CloseLong+ strategy.close("Long") if (ShortCondition)⋯ -strategy.close("Short", when = CloseShort)+if CloseShort+ strategy.close("Short")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: 17 before, 17 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.
⋯//Drawdown is typically low as it exits out of the trade once the RSI returns back to "normal levels".-//@version=5+//@version=6strategy(title="Relative Volume & RSI Pop", shorttitle="VOL & RSI Pop", overlay=false, precision=2, margin_long=100, margin_short=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 |
|---|---|---|---|
| RSI Period | 14 | int | vrsi |
| RSI buy | 70 | int · min 69 · max 100 | RSIco |
| RSI short | 35 | int · min 0 · max 35 | RSIcu |
| RV Period | 14 | int · min 1 | av |
| RV Threshold | 1.5 | float · min 0.5 · max 10 | LongCondition ShortCondition |
What it calculates
- RSI (
rsi,ta.rsiin v5)price, RSI Period (14)vrsi · line 12 - Crossover (
crossover,ta.crossoverin v5)vrsi, RSI buy (70)RSIco · line 13 - Crossunder (
crossunder,ta.crossunderin v5)vrsi, RSI short (35)RSIcu · line 14 - SMA (
sma,ta.smain v5)volume, RV Period (14)av · line 22
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 | (LongCondition) | On | 31 |
| Close Long | CloseLongvrsi < 69 | On | 33 |
| Open Short short | (ShortCondition) | On | 35 |
| Close Short | CloseShortvrsi > 35 | On | 37 |
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 | +38.9% | +102.5% | 17 | 47% | 3.35 | 5.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +13.5% | +5.5% | 19 | 26% | 3.14 | 4.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +1.2% | +9.8% | 14 | 43% | 2.60 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.5% | +8.4% | 22 | 41% | 3.34 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 15 | 40% | 0.81 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 18 | 28% | 2.05 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +0.1% | +148.3% | 22 | 27% | 1.25 | 0.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +0.0% | +17.1% | 18 | 22% | 1.15 | 0.1% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (RSI buy 70, RSI short 18) made +16.9% before 26 Dec 2025 and −4.8% after it, worse than the defaults' +25.0% after. Tuning on the past did not carry forward. 73% of the 64 combinations made money in-sample and 75% out-of-sample.
| RSI short ↓ · RSI buy → | 35 | 42 | 49 | 60 | 70 | 84 | 98 | 119 |
|---|---|---|---|---|---|---|---|---|
| 18 | +16% | +16% | +16% | +16% | +17% | +11% | 0% | 0% |
| 21 | +16% | +16% | +16% | +16% | +17% | +11% | 0% | 0% |
| 25 | +6% | +6% | +6% | +6% | +7% | +1% | −10% | −10% |
| 30 | +0% | +0% | +0% | +0% | +1% | −4% | −16% | −16% |
| 35 | +13% | +13% | +13% | +13% | +14% | +8% | −3% | −3% |
| 42 | +13% | +13% | +13% | +13% | +14% | +8% | −3% | −3% |
| 49 | +13% | +13% | +13% | +13% | +14% | +8% | −3% | −3% |
| 60 | +13% | +13% | +13% | +13% | +14% | +8% | −3% | −3% |
| RSI short ↓ · RSI buy → | 35 | 42 | 49 | 60 | 70 | 84 | 98 | 119 |
|---|---|---|---|---|---|---|---|---|
| 18 | −5% | −5% | −5% | −5% | −5% | −10% | −9% | −9% |
| 21 | −2% | −2% | −2% | −2% | −2% | −7% | −6% | −6% |
| 25 | +11% | +11% | +11% | +11% | +11% | +6% | +7% | +7% |
| 30 | +17% | +17% | +17% | +17% | +17% | +11% | +12% | +12% |
| 35 | +25% | +25% | +25% | +25% | +25% | +20% | +20% | +20% |
| 42 | +25% | +25% | +25% | +25% | +25% | +20% | +20% | +20% |
| 49 | +25% | +25% | +25% | +25% | +25% | +20% | +20% | +20% |
| 60 | +25% | +25% | +25% | +25% | +25% | +20% | +20% | +20% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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 | 4 | 50% | $16,268.10 |
| Sideways market | 8 | 50% | $7,415.00 |
| Falling market | 5 | 40% | $15,196.20 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
10.1%
The 95th percentile of the worst drawdown when the same 17 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 4.1% to 10.1%; the tick is what actually happened, 4.5%. Order luck alone moves it this much.
All 17 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 2 May 2024 58,365.00 | 3 May 2024 59,060.60 | 1 | −$695.63 |
| short | 5 Jul 2024 57,050.00 | 7 Jul 2024 58,230.10 | 2 | −$1,180.11 |
| short | 7 Sep 2024 53,963.00 | 8 Sep 2024 54,160.90 | 1 | −$197.89 |
| long | 30 Oct 2024 72,736.40 | 1 Nov 2024 70,292.00 | 2 | −$2,444.40 |
| long | 7 Nov 2024 75,572.00 | 26 Nov 2024 93,010.00 | 19 | $17,438.00 |
| short | 25 Feb 2025 91,552.90 | 3 Mar 2025 94,270.00 | 6 | −$2,717.11 |
| long | 9 May 2025 103,262.00 | 17 May 2025 103,464.00 | 8 | $202.29 |
| long | 11 Jul 2025 116,010.00 | 16 Jul 2025 117,758.00 | 5 | $1,748.07 |
| short | 5 Nov 2025 101,497.00 | 6 Nov 2025 103,885.00 | 1 | −$2,387.93 |
| short | 15 Nov 2025 94,594.00 | 27 Nov 2025 90,484.00 | 12 | $4,109.99 |
| long | 15 Jan 2026 96,951.80 | 16 Jan 2026 95,604.80 | 1 | −$1,346.97 |
| short | 30 Jan 2026 84,650.20 | 14 Feb 2026 68,854.00 | 15 | $15,796.20 |
| short | 24 Feb 2026 64,656.00 | 26 Feb 2026 67,988.00 | 2 | −$3,332.03 |
| short | 2 Jun 2026 71,408.90 | 14 Jun 2026 64,458.00 | 12 | $6,950.89 |
| short | 25 Jun 2026 61,078.00 | 2 Jul 2026 60,024.00 | 7 | $1,054.00 |
| long | 20 Aug 2026 69,334.80 | 2 Sep 2026 77,439.00 | 13 | $8,104.23 |
| long | 22 Sep 2026 86,620.00 | 24 Sep 2026 84,397.60 | 2 | −$2,222.41 |
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 |
|---|---|---|---|---|---|
| Relative Volume & RSI Pop this page | — | v4 strategy | +38.9% | 17 | 5.7% |
| SRJ RSI Outperformer Strategy by Sapt_Jash | rsi sma | v5 strategy | +0.6% | 8 | 2.4% |
| RSI SMA Crossover Strategy by reees | rsi sma | v5 strategy | +39.8% | 42 | 30.8% |
| Short In Downtrend Below MA100 (Coinrule) by Coinrule | sma rsi | v4 strategy | −34.5% | 99 | 45.4% |
| Simple RSI and SMA Long and Short (by Coinrule) by Coinrule | rsi sma | v5 strategy | −3.0% | 2 | 17.7% |
| Maximized Moving Average Crossing (by Coinrule) by Coinrule | sma rsi | v4 strategy | −6.6% | 9 | 13.3% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 9 ms | Yes 1,000 bars in 25 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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © gary_trades//This script is a basic concept to catch breakout moves utilising a spike in relative volume when the RSI is high (for longs) or when the RSI is low (for shorts).//Drawdown is typically low as it exits out of the trade once the RSI returns back to "normal levels".//@version=4strategy(title="Relative Volume & RSI Pop", shorttitle="VOL & RSI Pop", overlay=false, precision=2, margin_long=100, margin_short=100)//RSIRSIlength = input(14, title="RSI Period")RSItop = input(70, title="RSI buy", minval= 69, maxval=100)RSIbottom = input(35, title="RSI short", minval= 0, maxval=35)price = closevrsi = rsi(price, RSIlength)RSIco = crossover(vrsi, RSItop)RSIcu = crossunder(vrsi, RSIbottom)plot(vrsi, "RSI", color=color.purple)band1 = hline(70, "Upper Band", color=#C0C0C0)bandm = hline(50, "Middle Band", color=color.new(#C0C0C0, 50))band0 = hline(30, "Lower Band", color=#C0C0C0)fill(band1, band0, color=color.purple, transp=90, title="Background")//RELATIVE VOLUMERVOLlen = input(14, minval=1, title="RV Period")av = sma(volume, RVOLlen)RVOL = volume / avRVOLthreshold = input(1.5,title="RV Threshold", minval=0.5, maxval=10)//TRADE TRIGGERSLongCondition = RSIco and RVOL > RVOLthresholdCloseLong = vrsi < 69ShortCondition = RSIcu and RVOL > RVOLthresholdCloseShort = vrsi > 35if (LongCondition) strategy.entry("Long", strategy.long) strategy.close("Long", when = CloseLong) if (ShortCondition) strategy.entry("Short", strategy.short) strategy.close("Short", when = CloseShort)