Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

RSI on VWAP Upgraded strategy

A Pine Script v4 strategy built on RSI or VWAP (close, 20). 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 0.08 commission. 12 settings; defaults include RSI Length 20, RSI Oversold level 30 and RSI Overbought level 85.

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 on VWAP Upgraded strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did RSI on VWAP Upgraded strategy do on BTCUSDT 1D with default settings?
−119.75%
From 26 Jan 2024 to 21 Oct 2026, over 4 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can RSI on VWAP Upgraded 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 RSI on VWAP Upgraded strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does RSI on VWAP Upgraded strategy run in Zeal Terminal?
Yes
It compiles in 31 ms and runs 1,000 bars in 53 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI on VWAP
  • Plot
  • Plot
  • 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 (12)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI on VWAP$19,568$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. 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 56, 58) so the engine trades the way the script says.
Net profit
−119.75%
−$119,748.00
Buy and hold
+102.5%
same period
Closed trades
4
0 won · 4 lost
Profitable
0.0%
of closed trades
Profit factor
0.00
gross profit ÷ gross loss
Max drawdown
276.71%
−$276,709.00

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.

  • Note

    Uses an argument v6 removed

    when = on line 56, 57, 58, 59. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 49

    transp = on line 49, 50. 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 security → request.security, rsi → ta.rsi, vwap → ta.vwap, crossover → ta.crossover, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 56, 57, 58, 59). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 10: input(type = input.resolution) → input.timeframe()
  • Line 11: input(type = input.integer) → input.int()
  • Line 12: input(type = input.float) → input.float()
  • Line 13: input(type = input.float) → input.float()
  • Line 14: input(type = input.integer) → input.int()
16 more edits
  • Line 17: input(type = input.bool) → input.bool()
  • Line 18: input(type = input.bool) → input.bool()
  • Line 26: input(type = input.bool) → input.bool()
  • Line 41: security → request.security
  • Line 41: rsi → ta.rsi
  • Line 41: vwap → ta.vwap
  • Line 49: transp = 30 → color.new(rsiVWAP > ovrbgt ? color.red : na, 30)
  • Line 50: transp = 30 → color.new(rsiVWAP < ovrsld ? color.green : na, 30)
  • Line 56: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 56: crossover → ta.crossover
  • Line 57: crossover → ta.crossover
  • Line 57: crossunder → ta.crossunder
  • Line 58: strategy.entry(…, false) → strategy.entry(…, strategy.short)
  • Line 58: crossunder → ta.crossunder
  • Line 59: crossunder → ta.crossunder
  • Line 59: crossover → ta.crossover
⋯// © Mysteriown-//@version=4+//@version=5strategy("RSI on VWAP Upgraded strategy", overlay=false, pyramiding = 4, commission_value = 0.08)⋯// ------------------------------------------ //-reso = input(title="Resolution", type=input.resolution, defval="")+reso = input.timeframe(title="Resolution", defval="")-length = input(20, title="RSI Length", type=input.integer)+length = input.int(20, title="RSI Length")-ovrsld = input(30, "RSI Oversold level", type=input.float)+ovrsld = input.float(30, "RSI Oversold level")-ovrbgt = input(85, "RSI Overbought level", type=input.float)+ovrbgt = input.float(85, "RSI Overbought level")-lateleave = input(28, "Number of candles", type=input.integer)+lateleave = input.int(28, "Number of candles")// lateleave : numbers of bars in overbought/oversold zones where the position is closed. The position is closed when this number is reached or when the zone is left (the first condition).// best parameters BTCUSDTPERP M15 : 20 / 30 / 85 / 28-stratbull = input(title="Enter longs ?", type = input.bool, defval=true)+stratbull = input.bool(title="Enter longs ?", defval=true)-stratbear = input(title="Enter shorts ?", type = input.bool, defval=true)+stratbear = input.bool(title="Enter shorts ?", defval=true)stratyear = input(2020, title = "Strategy Start Year")⋯// ------------------------------------------ //-laguerre = input(title="Use Laguerre on RSI ?", type=input.bool, defval=false)+laguerre = input.bool(title="Use Laguerre on RSI ?", defval=false)gamma = input(0.06, title="Laguerre Gamma")⋯// ------------------------------------------ //-rsiV = security(syminfo.tickerid, reso, rsi(vwap(close), length))+rsiV = request.security(syminfo.tickerid, reso, ta.rsi(ta.vwap(close), length))rsiVWAP = laguerre ? laguerre_cal(rsiV,gamma) : rsiV⋯lline = plot(ovrsld, color = color.gray, style=plot.style_line)-fill(prsi,hline, color = rsiVWAP > ovrbgt ? color.red : na, transp = 30)+fill(prsi,hline, color = color.new(rsiVWAP > ovrbgt ? color.red : na, 30))-fill(prsi,lline, color = rsiVWAP < ovrsld ? color.green : na, transp = 30)+fill(prsi,lline, color = color.new(rsiVWAP < ovrsld ? color.green : na, 30))// ------------------------------------------ //⋯timebear = stratbear and time > stratstart-strategy.entry("Long", true, when = timebull and crossover(rsiVWAP, ovrsld), comment="")+strategy.entry("Long", strategy.long, when = timebull and ta.crossover(rsiVWAP, ovrsld), comment="")-strategy.close("Long", when = timebull and crossover(rsiVWAP, ovrbgt)[lateleave] or crossunder(rsiVWAP, ovrbgt), comment="")+strategy.close("Long", when = timebull and ta.crossover(rsiVWAP, ovrbgt)[lateleave] or ta.crossunder(rsiVWAP, ovrbgt), comment="")-strategy.entry("Short", false, when = timebear and crossunder(rsiVWAP, ovrbgt), comment="")+strategy.entry("Short", strategy.short, when = timebear and ta.crossunder(rsiVWAP, ovrbgt), comment="")-strategy.close("Short", when = timebear and crossunder(rsiVWAP, ovrsld)[lateleave] or crossover(rsiVWAP, ovrsld), comment="")+strategy.close("Short", when = timebear and ta.crossunder(rsiVWAP, ovrsld)[lateleave] or ta.crossover(rsiVWAP, ovrsld), comment="")

Clean v5

VerifiedDownload the v5 script

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

  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
  • Line 21: input() → input.int()
  • Line 27: input() → input.float()
  • Line 56: when = timebull and ta.crossover(rsiVWAP, ovrsld) → if block
  • Line 57: when = timebull and ta.crossover(rsiVWAP, ovrbgt)[lateleave] or ta.crossunder(rsiVWAP, ovrbgt) → if block
  • Line 58: when = timebear and ta.crossunder(rsiVWAP, ovrbgt) → if block
  • Line 59: when = timebear and ta.crossunder(rsiVWAP, ovrsld)[lateleave] or ta.crossover(rsiVWAP, ovrsld) → if block
⋯stratbear = input.bool(title="Enter shorts ?", defval=true)-stratyear = input(2020, title = "Strategy Start Year")+stratyear = input.int(2020, title = "Strategy Start Year")-stratmonth = input(1, title = "Strategy Start Month")+stratmonth = input.int(1, title = "Strategy Start Month")-stratday = input(1, title = "Strategy Start Day")+stratday = input.int(1, title = "Strategy Start Day")stratstart = timestamp(stratyear,stratmonth,stratday,0,0)⋯laguerre = input.bool(title="Use Laguerre on RSI ?", defval=false)-gamma = input(0.06, title="Laguerre Gamma")+gamma = input.float(0.06, title="Laguerre Gamma")laguerre_cal(s,g) =>⋯timebear = stratbear and time > stratstart-strategy.entry("Long", strategy.long, when = timebull and ta.crossover(rsiVWAP, ovrsld), comment="")+if timebull and ta.crossover(rsiVWAP, ovrsld)+    strategy.entry("Long", strategy.long, comment="")-strategy.close("Long", when = timebull and ta.crossover(rsiVWAP, ovrbgt)[lateleave] or ta.crossunder(rsiVWAP, ovrbgt), comment="")+if timebull and ta.crossover(rsiVWAP, ovrbgt)[lateleave] or ta.crossunder(rsiVWAP, ovrbgt)+    strategy.close("Long", comment="")-strategy.entry("Short", strategy.short, when = timebear and ta.crossunder(rsiVWAP, ovrbgt), comment="")+if timebear and ta.crossunder(rsiVWAP, ovrbgt)+    strategy.entry("Short", strategy.short, comment="")-strategy.close("Short", when = timebear and ta.crossunder(rsiVWAP, ovrsld)[lateleave] or ta.crossover(rsiVWAP, ovrsld), comment="")+if timebear and ta.crossunder(rsiVWAP, ovrsld)[lateleave] or ta.crossover(rsiVWAP, ovrsld)+    strategy.close("Short", comment="")

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: 4 before, 2 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.

⋯// © Mysteriown-//@version=5+//@version=6strategy("RSI on VWAP Upgraded strategy", overlay=false, pyramiding = 4, commission_value = 0.08)⋯

Settings

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

SettingDefaultType and rangeFeeds
Resolutiontimeframe (written input.resolution)rsiV
RSI Length20int (written input.integer)rsiV
RSI Oversold level30floatRSI on VWAP lline plot fill entry Long close Short
RSI Overbought level85floatRSI on VWAP hline plot fill close Long entry Short
Number of candles28int (written input.integer)close Long close Short
Enter longs ?truebooltimebull
Enter shorts ?truebooltimebear
Strategy Start Year2020intstratstart
Strategy Start Month1intstratstart
Strategy Start Day1intstratstart
Use Laguerre on RSI ?falseboolrsiVWAP
Laguerre Gamma0.06floatrsiVWAP

What it calculates

  • RSI / VWAP (rsi, ta.rsi in v5)vwap(close), RSI Length (20)rsiV · line 41

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 dataresoResolutionsetting · lengthRSI Lengthsetting · 20stratyearStrategy Start Yearsetting · 2020stratmonthStrategy Start Monthsetting · 1stratdayStrategy Start Daysetting · 1gammaLaguerre Gammasetting · 0.06timetimeprice dataovrsldRSI Oversold levelsetting · 30ovrbgtRSI Overbought levelsetting · 85lateleaveNumber of candlessetting · 28rsiVRSI / VWAP→ rsiVstratstartstratstartvaluel0l0valuel1l1valuel2l2valuel3l3valuersiVWAPrsiVWAPvaluetimebull, timebeartimebull · timebear2 conditionsentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeplot:46RSI on VWAPplotplot:47plotplotplot:48plotplotfill:49Fillfill × 2fill:50Fillfill × 2

Order rules

OrderFires whenBy defaultLine
Open Long longtimebull and crossover(rsiVWAP, ovrsld)On56
Close Longtimebull and crossover(rsiVWAP, ovrbgt)[lateleave] or crossunder(rsiVWAP, ovrbgt)On57
Open Short shorttimebear and crossunder(rsiVWAP, ovrbgt)On58
Close Shorttimebear and crossunder(rsiVWAP, ovrsld)[lateleave] or crossover(rsiVWAP, ovrsld)On59

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data1 security call(s), none with lookahead on.
  • 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−119.7%+102.5%40%0.00276.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+24.4%+5.5%1070%12.9974.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.9%+9.8%4100%273.153.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.4%+8.4%580%168.302.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.1%+16.7%1100%192.750.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%786%5.390.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1100%15.650.3%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.5%+17.1%888%9.470.2%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 market40%−$119,508.00
Sideways market0—$0.00
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

80.5%

The 95th percentile of the worst drawdown when the same 4 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 80.5% to 80.5%; the tick is what actually happened, 80.5%. Order luck alone moves it this much.

0%93%
All 4 trades
SideEntryExitBarsP&L
short18 Feb 2024 51,642.6024 Nov 2025 86,830.00645−$35,298.10
short20 Feb 2024 51,774.7024 Nov 2025 86,830.00643−$35,166.10
short1 Mar 2024 61,131.0024 Nov 2025 86,830.00633−$25,817.40
short6 Mar 2024 63,724.0024 Nov 2025 86,830.00628−$23,226.40

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 on VWAP Upgraded strategy this page—v4 strategy−119.7%4276.7%
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 31 msWith a workaround 1,000 bars in 53 msNot measured
PineTSNo 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 56, 58) 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/// © Mysteriown//@version=4strategy("RSI on VWAP Upgraded strategy", overlay=false, pyramiding = 4, commission_value = 0.08)// pyramiding is the number of positions you can take before closing all of them (be carefull if using it with a trading bot)// commission_value is the commission taken for each buy/sell// ------------------------------------------ //// ----------------- Inputs ----------------- //// ------------------------------------------ //reso = input(title="Resolution", type=input.resolution, defval="")length = input(20, title="RSI Length", type=input.integer)ovrsld = input(30, "RSI Oversold level", type=input.float)ovrbgt = input(85, "RSI Overbought level", type=input.float)lateleave = input(28, "Number of candles", type=input.integer)// lateleave : numbers of bars in overbought/oversold zones where the position is closed. The position is closed when this number is reached or when the zone is left (the first condition).// best parameters BTCUSDTPERP M15 : 20 / 30 / 85 / 28stratbull = input(title="Enter longs ?", type = input.bool, defval=true)stratbear = input(title="Enter shorts ?", type = input.bool, defval=true)stratyear = input(2020, title = "Strategy Start Year")stratmonth = input(1, title = "Strategy Start Month")stratday = input(1, title = "Strategy Start Day")stratstart = timestamp(stratyear,stratmonth,stratday,0,0)// ------------------------------------------ //// --------------- Laguerre ----------------- //// ------------------------------------------ //laguerre = input(title="Use Laguerre on RSI ?", type=input.bool, defval=false)gamma = input(0.06, title="Laguerre Gamma")laguerre_cal(s,g) =>    l0 = 0.0    l1 = 0.0    l2 = 0.0    l3 = 0.0    l0 := (1 - g)*s+g*nz(l0[1])    l1 := -g*l0+nz(l0[1])+g*nz(l1[1])    l2 := -g*l1+nz(l1[1])+g*nz(l2[1])    l3 := -g*l2+nz(l2[1])+g*nz(l3[1])    (l0 + 2*l1 + 2*l2 + l3)/6// ------------------------------------------ //// ---------------- Rsi VWAP ---------------- //// ------------------------------------------ //rsiV = security(syminfo.tickerid, reso, rsi(vwap(close), length))rsiVWAP = laguerre ? laguerre_cal(rsiV,gamma) : rsiV// ------------------------------------------ //// ------------------ Plots ----------------- //// ------------------------------------------ //prsi = plot(rsiVWAP, color = rsiVWAP>ovrbgt ? color.red : rsiVWAP<ovrsld ? color.green : color.white, title="RSI on VWAP", linewidth=1, style=plot.style_line)hline = plot(ovrbgt, color = color.gray, style=plot.style_line)lline = plot(ovrsld, color = color.gray, style=plot.style_line)fill(prsi,hline, color = rsiVWAP > ovrbgt ? color.red : na, transp = 30)fill(prsi,lline, color = rsiVWAP < ovrsld ? color.green : na, transp = 30)// ------------------------------------------ //// ---------------- Positions --------------- //// ------------------------------------------ //timebull = stratbull and time > stratstarttimebear = stratbear and time > stratstartstrategy.entry("Long", true, when = timebull and crossover(rsiVWAP, ovrsld), comment="")strategy.close("Long", when = timebull and crossover(rsiVWAP, ovrbgt)[lateleave] or crossunder(rsiVWAP, ovrbgt), comment="")strategy.entry("Short", false, when = timebear and crossunder(rsiVWAP, ovrbgt), comment="")strategy.close("Short", when = timebear and crossunder(rsiVWAP, ovrsld)[lateleave] or crossover(rsiVWAP, ovrsld), comment="")