Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

RSI-VWAP Indicator -

A Pine Script v4 strategy built on RSI or VWAP (close, 16). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is 0 contracts and pays 0.04 commission. 9 settings; defaults include Start of trading StartDate, RSI/VWAP Length 16 and RSI/VWAP Oversold 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 RSI-VWAP Indicator - repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
How did RSI-VWAP Indicator - do on BTCUSDT 1D with default settings?
+2.16%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can RSI-VWAP Indicator - 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 RSI-VWAP Indicator - use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI-VWAP Indicator - run in Zeal Terminal?
Yes
It compiles in 24 ms and runs 1,000 bars in 101 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI/VWAP
  • Overbought
  • Oversold
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (9)
0.3XPosition Size: 0.044275840,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI/VWAP$102,782$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep.
Net profit
+2.16%
$2,157.07
Buy and hold
+102.5%
same period
Closed trades
3
3 won · 0 lost
Profitable
100.0%
of closed trades
Profit factor
1,726.66
gross profit ÷ gross loss
Max drawdown
4.54%
−$4,536.79

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

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, vwap → ta.vwap, max → math.max, tostring → str.tostring, crossover → ta.crossover, crossunder → ta.crossunder.

v4 → v5

VerifiedDownload the v5 script

Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 7: input(type = input.bool) → input.bool()
  • Line 8: input(type = input.time) → input.time()
  • Line 9: input(type = input.integer) → input.int()
  • Line 10: input(type = input.float) → input.float()
  • Line 11: input(type = input.float) → input.float()
24 more edits
  • Line 12: input(type = input.float) → input.float()
  • Line 13: input(type = input.float) → input.float()
  • Line 14: input(type = input.float) → input.float()
  • Line 15: input(type = input.float) → input.float()
  • Line 17: rsi → ta.rsi
  • Line 17: vwap → ta.vwap
  • Line 48: max → math.max
  • Line 48: max → math.max
  • Line 54: tostring → str.tostring
  • Line 55: tostring → str.tostring
  • Line 56: tostring → str.tostring
  • Line 57: tostring → str.tostring
  • Line 58: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 60: tostring → str.tostring
  • Line 61: tostring → str.tostring
  • Line 62: tostring → str.tostring
  • Line 73: crossover → ta.crossover
  • Line 74: tostring → str.tostring
  • Line 78: crossunder → ta.crossunder
  • Line 82: tostring → str.tostring
  • Line 83: tostring → str.tostring
  • Line 87: crossover → ta.crossover
  • Line 90: crossunder → ta.crossunder
⋯// © Xaviz-//@version=4+//@version=5strategy("RSI-VWAP Indicator %", overlay = false, pyramiding = 5, initial_capital = 100000, default_qty_value = 0, commission_value = 0.04, max_labels_count = 500)⋯StartDate           = timestamp(        "01 Jan 2000 00:00 +0000")-Spot                = input(false,      "Spot Trading (no leverage)",   input.bool)+Spot                = input.bool(false,      "Spot Trading (no leverage)")-testPeriodStart     = input(StartDate,  "Start of trading",             input.time)+testPeriodStart     = input.time(StartDate,  "Start of trading")-Length              = input(16,         "RSI/VWAP Length",              input.integer,  minval = 1)+Length              = input.int(16,         "RSI/VWAP Length",  minval = 1)-OverSold            = input(18,         "RSI/VWAP Oversold",            input.float,    minval = 0,  maxval = 100)+OverSold            = input.float(18,         "RSI/VWAP Oversold",    minval = 0,  maxval = 100)-OverBought          = input(80,         "RSI/VWAP Overbought",          input.float,    minval = 0,  maxval = 100)+OverBought          = input.float(80,         "RSI/VWAP Overbought",    minval = 0,  maxval = 100)-EquityPercent       = input(25,         "% Equity on Longs",            input.float,    minval = 0,  maxval = 100)+EquityPercent       = input.float(25,         "% Equity on Longs",    minval = 0,  maxval = 100)-PositionPercent     = input(50,         "% Position on Closings",       input.float,    minval = 0,  maxval = 100)+PositionPercent     = input.float(50,         "% Position on Closings",    minval = 0,  maxval = 100)-Risk                = input(15,         "% Drawdown allowed",           input.float,    minval = 0,  maxval = 100)+Risk                = input.float(15,         "% Drawdown allowed",    minval = 0,  maxval = 100)-MarginRate          = input(1.0,        "% Margin Rate",                input.float,    minval = 0) / 100+MarginRate          = input.float(1.0,        "% Margin Rate",    minval = 0) / 100// RSI with VWAP as source-RsiVwap             = rsi(vwap(close), Length)+RsiVwap             = ta.rsi(ta.vwap(close), Length)//█ Plotting⋯PositionSize            = strategy.position_size * strategy.position_avg_price-Cash                    = Spot ? max(0, Balance - PositionSize) : max(0, Balance - (PositionSize * MarginRate))+Cash                    = Spot ? math.max(0, Balance - PositionSize) : math.max(0, Balance - (PositionSize * MarginRate))Leverage                = PositionSize / Balance⋯ - text =  "Position Size: "   + tostring(strategy.position_size, '#.########') + " "  + syminfo.basecurrency + "\n" ++ text =  "Position Size: "   + str.tostring(strategy.position_size, '#.########') + " "  + syminfo.basecurrency + "\n" +-         "Cash: "            + tostring(Cash, '#.##')                         + " "  + syminfo.currency     + "\n" ++         "Cash: "            + str.tostring(Cash, '#.##')                         + " "  + syminfo.currency     + "\n" +-         "Margin: "          + tostring(Margin, '#.##')                       + " "  + syminfo.currency     + "\n" ++         "Margin: "          + str.tostring(Margin, '#.##')                       + " "  + syminfo.currency     + "\n" +-         "Floating: "        + tostring(Floating, '#.##')                     + " "  + syminfo.currency     + " / "  +         "Floating: "        + str.tostring(Floating, '#.##')                     + " "  + syminfo.currency     + " / "  -                             + tostring(PercentFloating,  '#.##')             + " %" + "\n" ++                             + str.tostring(PercentFloating,  '#.##')             + " %" + "\n" +-         "Realized PnL: "    + tostring(RealizedPnL, '#.##')                  + " "  + syminfo.currency     + " / "  +         "Realized PnL: "    + str.tostring(RealizedPnL, '#.##')                  + " "  + syminfo.currency     + " / "  -                             + tostring(PercentRealizedPnL,  '#.##')          + " %" + "\n" ++                             + str.tostring(PercentRealizedPnL,  '#.##')          + " %" + "\n" +-         "Unrealized PnL: "  + tostring(URealizedPnL, '#.##')                 + " "  + syminfo.currency     + " / "  +         "Unrealized PnL: "  + str.tostring(URealizedPnL, '#.##')                 + " "  + syminfo.currency     + " / "  -                             + tostring(PercentURealizedPnL, '#.##')          + " %")+                             + str.tostring(PercentURealizedPnL, '#.##')          + " %")                             ⋯var bool long = na-if crossover(RsiVwap[1], OverSold) and (time > testPeriodStart)+if ta.crossover(RsiVwap[1], OverSold) and (time > testPeriodStart)-    label.new(bar_index, OverSold, tostring(Leverage, "#.#") + "X", textcolor = Spot ? na : #9598a1, color = color.new(color.lime, 25), style = label.style_diamond, size = size.tiny)+    label.new(bar_index, OverSold, str.tostring(Leverage, "#.#") + "X", textcolor = Spot ? na : #9598a1, color = color.new(color.lime, 25), style = label.style_diamond, size = size.tiny)    long := true⋯// Sell/Closing shapes-if crossunder(RsiVwap[1], OverBought) and (time > testPeriodStart) and not na(long)+if ta.crossunder(RsiVwap[1], OverBought) and (time > testPeriodStart) and not na(long)    label.new(bar_index, OverBought, color = color.new(color.red, 25),  style = label.style_diamond, size = size.tiny)⋯// Alerts-string BuyMessage   = "q=" + tostring(EquityPercent)   + "% t=market"+string BuyMessage   = "q=" + str.tostring(EquityPercent)   + "% t=market"-string SellMessage  = "q=" + tostring(PositionPercent) + "% t=market"+string SellMessage  = "q=" + str.tostring(PositionPercent) + "% t=market"// (copy and paste on the alert window a message similar to this)⋯// Market orders on long-if crossover(RsiVwap, OverSold) and (time > testPeriodStart)+if ta.crossover(RsiVwap, OverSold) and (time > testPeriodStart)    strategy.entry("LONG", strategy.long, qty = QuantityOnLong, alert_message = BuyMessage)// Market orders on close   -if crossunder(RsiVwap, OverBought)+if ta.crossunder(RsiVwap, OverBought)    strategy.close("LONG", qty_percent = PositionPercent, comment = "CLOSE", alert_message = SellMessage)⋯

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L72:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Xaviz-//@version=5+//@version=6strategy("RSI-VWAP Indicator %", overlay = false, pyramiding = 5, initial_capital = 100000, default_qty_value = 0, commission_value = 0.04, max_labels_count = 500)⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Spot Trading (no leverage)falseboolCash Margin QuantityOnLong line 74
Start of tradingStartDatevalueentry LONG line 73 line 78 line 87
RSI/VWAP Length16int · min 1RsiVwap
RSI/VWAP Oversold18int · min 0 · max 100RsiVwapLineColor FillColorOverSold Oversold entry LONG line 73 line 74 line 87
RSI/VWAP Overbought80int · min 0 · max 100RsiVwapLineColor FillColorOverBought Overbought close LONG line 78 line 79 line 90
% Equity on Longs25int · min 0 · max 100QuantityOnLong BuyMessage
% Position on Closings50int · min 0 · max 100QuantityOnClose SellMessage close LONG
% Drawdown allowed15int · min 0 · max 100line 93
% Margin Rate1.0float · min 0Cash Margin

What it calculates

  • RSI / VWAP (rsi, ta.rsi in v5)vwap(close), RSI/VWAP Length (16)RsiVwap · line 17

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.

closecloseprice dataLengthRSI/VWAP Lengthsetting · 16MarginRate% Margin Ratesetting · 1.0EquityPercent% Equity on Longssetting · 25PositionPercent% Position on Closingssetting · 50OverBoughtRSI/VWAP Overboughtsetting · 80OverSoldRSI/VWAP Oversoldsetting · 18timetimeprice datatestPeriodStartStart of tradingsetting · StartDateRsiVwapRSI / VWAP→ RsiVwapEquity, Balance, RealizedPnL, Floating, PositionSizeEquity · Balance +35 valuesPercentFloatingPercentFloatingvaluePercentRealizedPnLPercentRealizedPnLvalueURealizedPnLURealizedPnLvaluePercentURealizedPnLPercentURealizedPnLvalueCashCashvalueLeverageLeveragevalueMarginMarginvalueQuantityOnLongQuantityOnLongvalueQuantityOnCloseQuantityOnClosevalueRsiVwapLineColor, FillColorOverBought, FillColorOverSold, OboughtOsoldColor, labelEquityColourRsiVwapLineColor · FillColorO…entry:LONGOpen LONGstrategy.entryclose:LONGClose LONGstrategy.closeplot:30RSI/VWAPplotplot:32Overboughtplotplot:34Oversoldplotfill:36Fillfill × 2fill:37Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open LONG longcrossover(RsiVwap, OverSold) and (time > testPeriodStart)On88
Close LONGcrossunder(RsiVwap, OverBought)On91

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.

3/3trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+2.2%+102.5%3100%1,726.664.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+10.5%+5.5%6100%11,215.302.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+5.4%+9.8%1100%1,080.232.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−9.4%+8.4%967%0.2814.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+5.5%+21.5%1090%8.815.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+2.6%+17.1%5100%126.201.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 barsTradesWonP&L
Rising market0—$0.00
Sideways market0—$0.00
Falling market3100%$2,158.32

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 3 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.

0%1%
All 3 trades
SideEntryExitBarsP&L
long7 Feb 2026 70,580.3023 Aug 2026 77,074.90197$1,139.77
long7 Feb 2026 70,580.3026 Aug 2026 78,539.10200$699.49
long7 Feb 2026 70,580.3029 Aug 2026 77,845.90203$319.06

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
RSI-VWAP Indicator - this page—v4 strategy+2.2%34.5%
Power Zonessssss by liuenvwap rsiv5 strategy+2.5%45.1%
VWAP and RSI strategy by mohaneersi vwapv4 strategy+164.4%7210.9%
Stochastic RSI Strategy (with SMA and VWAP Filters) by thedoggwalkerrsi vwapv4 strategy−0.0%30.0%
RSI Mean Reversion Bot Strategy by Solutions1978rsi vwapv4 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 24 msYes 1,000 bars in 101 msNot measured
PineTSNo 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/// © Xaviz//@version=4strategy("RSI-VWAP Indicator %", overlay = false, pyramiding = 5, initial_capital = 100000, default_qty_value = 0, commission_value = 0.04, max_labels_count = 500)//█ Initial inputsStartDate           = timestamp(        "01 Jan 2000 00:00 +0000")Spot                = input(false,      "Spot Trading (no leverage)",   input.bool)testPeriodStart     = input(StartDate,  "Start of trading",             input.time)Length              = input(16,         "RSI/VWAP Length",              input.integer,  minval = 1)OverSold            = input(18,         "RSI/VWAP Oversold",            input.float,    minval = 0,  maxval = 100)OverBought          = input(80,         "RSI/VWAP Overbought",          input.float,    minval = 0,  maxval = 100)EquityPercent       = input(25,         "% Equity on Longs",            input.float,    minval = 0,  maxval = 100)PositionPercent     = input(50,         "% Position on Closings",       input.float,    minval = 0,  maxval = 100)Risk                = input(15,         "% Drawdown allowed",           input.float,    minval = 0,  maxval = 100)MarginRate          = input(1.0,        "% Margin Rate",                input.float,    minval = 0) / 100// RSI with VWAP as sourceRsiVwap             = rsi(vwap(close), Length)//█ Plotting// Rsi-vwap Line ColorRsiVwapLineColor    = RsiVwap > OverBought ?     color.new(color.red,  50) :                       RsiVwap < OverSold   ?     color.new(color.lime, 50) :                                                  color.new(color.blue, 50)// Rsi-vwap Fill ColorFillColorOverBought = RsiVwap > OverBought ?     color.new(color.red,  75) : na FillColorOverSold   = RsiVwap < OverSold   ?     color.new(color.lime, 75) : na                      // Overbought/Oversold ColorOboughtOsoldColor   =                            color.new(color.gray, 50)// Rsi-vwap plot                                       RsiVwapLine         = plot(RsiVwap,     "RSI/VWAP",     RsiVwapLineColor, linewidth = 2)// Plot of the top lineOverBoughtLine      = plot(OverBought,  "Overbought",   OboughtOsoldColor)// Plot of the bottom lineOverSoldLine        = plot(OverSold,    "Oversold",     OboughtOsoldColor)// Fill between plots                                                            fill(RsiVwapLine,   OverBoughtLine, FillColorOverBought)fill(RsiVwapLine,   OverSoldLine,   FillColorOverSold)// Information panelEquity                  = strategy.equityBalance                 = strategy.initial_capital + strategy.netprofitRealizedPnL             = strategy.netprofitFloating                = strategy.openprofitPercentFloating         = (Floating / strategy.initial_capital) * 100PercentRealizedPnL      = (RealizedPnL / strategy.initial_capital) * 100URealizedPnL            = Floating + RealizedPnLPercentURealizedPnL     = ((URealizedPnL) / strategy.initial_capital) * 100PositionSize            = strategy.position_size * strategy.position_avg_priceCash                    = Spot ? max(0, Balance - PositionSize) : max(0, Balance - (PositionSize * MarginRate))Leverage                = PositionSize / BalanceMargin                  = Spot ? 0 : PositionSize * MarginRatevar label labelEquity = nalabelEquity := label.new(bar_index, 50, style = label.style_label_left, textcolor = #9598a1, color = #131722, textalign = text.align_left, size = size.normal,  text =  "Position Size: "   + tostring(strategy.position_size, '#.########') + " "  + syminfo.basecurrency + "\n" +         "Cash: "            + tostring(Cash, '#.##')                         + " "  + syminfo.currency     + "\n" +         "Margin: "          + tostring(Margin, '#.##')                       + " "  + syminfo.currency     + "\n" +         "Floating: "        + tostring(Floating, '#.##')                     + " "  + syminfo.currency     + " / "                               + tostring(PercentFloating,  '#.##')             + " %" + "\n" +         "Realized PnL: "    + tostring(RealizedPnL, '#.##')                  + " "  + syminfo.currency     + " / "                               + tostring(PercentRealizedPnL,  '#.##')          + " %" + "\n" +         "Unrealized PnL: "  + tostring(URealizedPnL, '#.##')                 + " "  + syminfo.currency     + " / "                               + tostring(PercentURealizedPnL, '#.##')          + " %")                             // Deleting previous labelslabel.delete(labelEquity[1])//█ Backtest & Alerts// QuantitiesQuantityOnLong      = Spot ? (EquityPercent / 100) * ((strategy.equity / close) - strategy.position_size) :                             (EquityPercent / 100) *  (strategy.equity / close)QuantityOnClose     = (PositionPercent / 100) * strategy.position_size// Buy/Long shapesvar bool long = naif crossover(RsiVwap[1], OverSold) and (time > testPeriodStart)    label.new(bar_index, OverSold, tostring(Leverage, "#.#") + "X", textcolor = Spot ? na : #9598a1, color = color.new(color.lime, 25), style = label.style_diamond, size = size.tiny)    long := true    // Sell/Closing shapesif crossunder(RsiVwap[1], OverBought) and (time > testPeriodStart) and not na(long)    label.new(bar_index, OverBought, color = color.new(color.red, 25),  style = label.style_diamond, size = size.tiny)    // Alertsstring BuyMessage   = "q=" + tostring(EquityPercent)   + "% t=market"string SellMessage  = "q=" + tostring(PositionPercent) + "% t=market"// (copy and paste on the alert window a message similar to this)// {{strategy.order.action}} @ {{strategy.order.price}} | e={{exchange}} a=account s={{ticker}} b={{strategy.order.action}} {{strategy.order.alert_message}}// Market orders on longif crossover(RsiVwap, OverSold) and (time > testPeriodStart)    strategy.entry("LONG", strategy.long, qty = QuantityOnLong, alert_message = BuyMessage)// Market orders on close   if crossunder(RsiVwap, OverBought)    strategy.close("LONG", qty_percent = PositionPercent, comment = "CLOSE", alert_message = SellMessage)// Max Drawdown allowed percentstrategy.risk.max_drawdown(Risk, strategy.percent_of_equity)// by XaviZ