Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

VWAP and RSI strategy

A Pine Script v4 strategy built on EMA (close, 200), RSI (close, 3) and VWAP (hlc3). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 7 settings; defaults include Long EMA 200, short EMA 50 and RSI Period 3.

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 VWAP and RSI 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 VWAP and RSI strategy do on BTCUSDT 1D with default settings?
+164.35%
From 26 Jan 2024 to 21 Oct 2026, over 7 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can VWAP and 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 VWAP and RSI strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does VWAP and RSI strategy run in Zeal Terminal?
Yes
It compiles in 26 ms and runs 1,000 bars in 40 ms, in the browser.

BTCUSDT · 1D · default settings

  • RSI
  • Buy Line
  • Sell Line
  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI$28,893$20,253Equity from $10,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 long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 41, 46) so the engine trades the way the script says.
Net profit
+164.35%
$16,435.20
Buy and hold
+102.5%
same period
Closed trades
7
3 won · 4 lost
Profitable
42.9%
of closed trades
Profit factor
1.70
gross profit ÷ gross loss
Max drawdown
210.92%
−$21,092.10

One run with the author's default settings, $10,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.

  • 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 41, 46, 50, 53. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 47

    transp = on line 47. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 41

    long = on line 41, 46. v5 writes it as direction = strategy.long or strategy.short.

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 ema → ta.ema, rsi → ta.rsi, vwap → ta.vwap, crossunder → ta.crossunder.
  • 4 strategy calls use the when = argument (line 41, 46, 50, 53). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 24: ema → ta.ema
  • Line 25: ema → ta.ema
  • Line 26: rsi → ta.rsi
  • Line 27: vwap → ta.vwap
  • Line 41: long = true → direction = strategy.long
3 more edits
  • Line 46: long = true → direction = strategy.long
  • Line 47: transp = 0 → color.new(add_on_divergence and addCondition ? color.green : na, 0)
  • Line 50: crossunder → ta.crossunder
⋯// © mohanee-//@version=4+//@version=5strategy(title="VWAP and RSI strategy [EEMANI] v2", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯//variables  END-longEMAval= ema(close, longEMA)+longEMAval= ta.ema(close, longEMA)-shortEMAval= ema(close, shortEMA)+shortEMAval= ta.ema(close, shortEMA)-rsiVal=rsi(close,rsi1)+rsiVal=ta.rsi(close,rsi1)-vwapVal=vwap(hlc3)+vwapVal=ta.vwap(hlc3)// Drawings⋯//Entry-strategy.entry(id="VWAP_RSI LE", comment="VR LE" , long=true,  when= longCondition  and strategy.position_size<1 )  //and rsiDipped+strategy.entry(id="VWAP_RSI LE", comment="VR LE" , direction = strategy.long,  when= longCondition  and strategy.position_size<1 )  //and rsiDipped//Add⋯addCondition = add_on_divergence and barCount[1] > 1 and strategy.position_size>=1 and close<=close[barCount[1]] and rsiVal>rsiVal[barCount+1] and   close>open and  close>vwapVal  //and open>vwapVal-strategy.entry(id="VWAP_RSI LE", comment="Add "  , long=true,  when= addCondition )  //and rsiDipped   comment="Add "  +tostring(barCount[1],"####")+strategy.entry(id="VWAP_RSI LE", comment="Add "  , direction = strategy.long,  when= addCondition )  //and rsiDipped   comment="Add "  +tostring(barCount[1],"####")-bgcolor(add_on_divergence and addCondition ? color.green : na,transp=0)+bgcolor(color.new(add_on_divergence and addCondition ? color.green : na, 0))     //Take profit Exit-strategy.close(id="VWAP_RSI LE", comment="TP Exit",   when=crossunder(rsiVal,90) )+strategy.close(id="VWAP_RSI LE", comment="TP Exit",   when=ta.crossunder(rsiVal,90) )//stoploss⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 16: input() → input.int()
  • Line 17: input() → input.int()
  • Line 18: input() → input.int()
  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
  • Line 21: input() → input.bool()
5 more edits
  • Line 22: input() → input.int()
  • Line 41: when = longCondition and strategy.position_size<1 → if block
  • Line 46: when = addCondition → if block
  • Line 50: when = ta.crossunder(rsiVal,90) → if block
  • Line 53: when = close < stopLossVal → if block
⋯// variables  BEGIN-longEMA = input(200, title="Long EMA", minval=1)+longEMA = input.int(200, title="Long EMA", minval=1)-shortEMA = input(50, title="short EMA", minval=1)+shortEMA = input.int(50, title="short EMA", minval=1)-rsi1 = input(3,title="RSI Period", minval=1)+rsi1 = input.int(3,title="RSI Period", minval=1)-rsi_buy_line = input(15,title="RSI Buy Line", minval=5)+rsi_buy_line = input.int(15,title="RSI Buy Line", minval=5)-rsi_sell_line = input(90,title="RSI Sell Line", minval=50)+rsi_sell_line = input.int(90,title="RSI Sell Line", minval=50)-add_on_divergence=input(true,title="Add on RSI divergence")+add_on_divergence=input.bool(true,title="Add on RSI divergence")-stopLoss = input(title="Stop Loss%", defval=5, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=5, minval=1)//variables  END⋯//Entry-strategy.entry(id="VWAP_RSI LE", comment="VR LE" , direction = strategy.long,  when= longCondition  and strategy.position_size<1 )  //and rsiDipped+if longCondition  and strategy.position_size<1+    strategy.entry(id="VWAP_RSI LE", comment="VR LE" , direction = strategy.long )  //and rsiDipped//Add⋯addCondition = add_on_divergence and barCount[1] > 1 and strategy.position_size>=1 and close<=close[barCount[1]] and rsiVal>rsiVal[barCount+1] and   close>open and  close>vwapVal  //and open>vwapVal-strategy.entry(id="VWAP_RSI LE", comment="Add "  , direction = strategy.long,  when= addCondition )  //and rsiDipped   comment="Add "  +tostring(barCount[1],"####")+if addCondition+    strategy.entry(id="VWAP_RSI LE", comment="Add "  , direction = strategy.long )  //and rsiDipped   comment="Add "  +tostring(barCount[1],"####")bgcolor(color.new(add_on_divergence and addCondition ? color.green : na, 0))⋯//Take profit Exit-strategy.close(id="VWAP_RSI LE", comment="TP Exit",   when=ta.crossunder(rsiVal,90) )+if ta.crossunder(rsiVal,90)+    strategy.close(id="VWAP_RSI LE", comment="TP Exit" )//stoplossstopLossVal =   strategy.position_avg_price -  (strategy.position_avg_price*stopLoss*0.01) -strategy.close(id="VWAP_RSI LE", comment="SL Exit",   when= close < stopLossVal)+if close < stopLossVal+    strategy.close(id="VWAP_RSI LE", comment="SL Exit")

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

⋯// © mohanee-//@version=5+//@version=6strategy(title="VWAP and RSI strategy [EEMANI] v2", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
Long EMA200int · min 1longEMAval
short EMA50int · min 1shortEMAval
RSI Period3int · min 1rsiVal
RSI Buy Line15int · min 5rsiDipped Buy Line
RSI Sell Line90int · min 50Sell Line
Add on RSI divergencetruebooladdCondition bgcolor
Stop Loss%5int · min 1stopLossVal

What it calculates

  • EMA (ema, ta.ema in v5)close, Long EMA (200)longEMAval · line 24
  • EMA (ema, ta.ema in v5)close, short EMA (50)shortEMAval · line 25
  • RSI (rsi, ta.rsi in v5)close, RSI Period (3)rsiVal · line 26
  • VWAP (vwap, ta.vwap in v5)hlc3vwapVal · line 27

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 datalongEMALong EMAsetting · 200shortEMAshort EMAsetting · 50rsi1RSI Periodsetting · 3hlc3hlc3price datahlc3 · volumehlc3 · volumeprice datastopLossStop Loss%setting · 5openopenprice datarsi_buy_lineRSI Buy Linesetting · 15rsi_sell_lineRSI Sell Linesetting · 90longEMAvalEMA→ longEMAvalshortEMAvalEMA→ shortEMAvalrsiValRSI→ rsiValvwapValVWAP→ vwapValbarCountbarCountvaluestopLossValstopLossValvalueaddConditionaddConditionconditionrsiDippedrsiDippedconditionlongConditionlongConditionconditionentry:VWAP_RSI LEOpen VWAP_RSI LEstrategy.entryclose:VWAP_RSI LEClose VWAP_RSI LEstrategy.closeplot:29RSIplothline:32Buy Linehlinehline:33Sell Linehlinebgcolor:47bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Open VWAP_RSI LE longlongCondition and strategy.position_size<1On41
Open VWAP_RSI LE longaddConditionadd_on_divergence and barCount[1] > 1 and strategy.position_size>=1 and close<=close[barCount[1]] and rsiVal>rsiVal[barCount+1] and close>open and close>vwapValOn46
Close VWAP_RSI LEcrossunder(rsiVal,90)On50
Close VWAP_RSI LEclose < stopLossValOn53

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 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+164.4%+102.5%743%1.70210.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+245.6%+5.5%1883%21.4726.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.6%+9.8%333%1.184.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+6.1%+8.4%1587%4.761.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.3%+16.7%425%0.250.7%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.1%+21.5%1136%0.580.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.1%+148.3%650%1.041.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.4%+17.1%1471%2.561.1%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 market2100%$25,369.70
Sideways market40%−$23,520.60
Falling market1100%$14,586.00

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

How bad could the drawdown be?

1,820,310.0%

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

0%2,093,356%
All 7 trades
SideEntryExitBarsP&L
long10 Feb 2025 96,462.8025 Feb 2025 91,552.9015−$4,909.87
long20 Feb 2025 96,644.4025 Feb 2025 91,552.905−$5,091.49
long5 Mar 2025 87,282.0010 Mar 2025 80,734.505−$6,547.50
long8 Apr 2025 79,163.2028 Apr 2025 93,749.3020$14,586.00
long3 Jun 2025 105,858.0016 Jul 2025 117,758.0043$11,900.10
long7 Jun 2025 104,288.0016 Jul 2025 117,758.0039$13,469.70
long14 Oct 2025 115,166.0017 Oct 2025 108,194.003−$6,971.73

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
VWAP and RSI strategy this page—v4 strategy+164.4%7210.9%
Power Zonessssss by liuenvwap ema rsiv5 strategy+2.5%45.1%
VWAP_X_EMA by justvishu91vwap emav4 strategyNo trades on this market
RSI Cross [xaurr] by livetrendrsi emav4 strategy+24.4%5335.3%
Bitpanda Coinrule Template by joshuajcoop01rsi emav5 strategy−2.8%44.6%
RSI with Slow and Fast MA Crossing Strategy (by Coinrule) by Coinrulersi emav5 strategy−2.8%44.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 26 msWith a workaround 1,000 bars in 40 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 41, 46) 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/// © mohanee//@version=4strategy(title="VWAP and RSI strategy [EEMANI] v2", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)//This strategy combines VWAP and RSI indicators//BUY RULE//1. EMA50 > EMA 200//2. if current close > vwap session  value and  close>open   //3. check if RSI3 is dipped below 10  for any of last 10 candles//EXIT RULE//1. RSI3   crossing down 90 level//STOP LOSS EXIT//1. As configured --- default is set to 5%int barCount = 0// variables  BEGINlongEMA = input(200, title="Long EMA", minval=1)shortEMA = input(50, title="short EMA", minval=1)rsi1 = input(3,title="RSI Period", minval=1)rsi_buy_line = input(15,title="RSI Buy Line", minval=5)rsi_sell_line = input(90,title="RSI Sell Line", minval=50)add_on_divergence=input(true,title="Add on RSI divergence")stopLoss = input(title="Stop Loss%", defval=5, minval=1)//variables  ENDlongEMAval= ema(close, longEMA)shortEMAval= ema(close, shortEMA)rsiVal=rsi(close,rsi1)vwapVal=vwap(hlc3)// Drawingsplot_rsi = plot(rsiVal, title="RSI", color=color.purple, linewidth=1)//plot_fill = plot(0, color=color.green, editable=false)//fill(plot_rsi, plot_fill, title="Oscillator Fill", color=color.blue, transp=75) hline(rsi_buy_line, color=color.green, title="Buy Line", linewidth=2, linestyle=hline.style_dashed)hline(rsi_sell_line, color=color.purple, title="Sell Line", linewidth=2, linestyle=hline.style_dashed)//plot(value_ma, title="MA", color=color_ma, linewidth=2)rsiDipped=falsefor i = 1 to 10    rsiDipped := rsiDipped or rsiVal[i]<rsi_buy_line//rsiDipped =  rsiVal[1]<rsi_buy_line or rsiVal[2]<rsi_buy_line or rsiVal[3]<rsi_buy_line  or rsiVal[4]<rsi_buy_line  or rsiVal[5]<rsi_buy_line  or rsiVal[6]<rsi_buy_line or rsiVal[7]<rsi_buy_line  or rsiVal[8]<rsi_buy_line  or rsiVal[9]<rsi_buy_line  or rsiVal[10]<rsi_buy_line  longCondition=  shortEMAval > longEMAval and  close>open and  close>vwapVal  and open>vwapVal  and rsiDipped//Entrystrategy.entry(id="VWAP_RSI LE", comment="VR LE" , long=true,  when= longCondition  and strategy.position_size<1 )  //and rsiDipped//Add//barCount:=nz(barssince(longCondition),1)barCount :=  strategy.position_size>0 ? (barCount[1]+1) : 0addCondition = add_on_divergence and barCount[1] > 1 and strategy.position_size>=1 and close<=close[barCount[1]] and rsiVal>rsiVal[barCount+1] and   close>open and  close>vwapVal  //and open>vwapValstrategy.entry(id="VWAP_RSI LE", comment="Add "  , long=true,  when= addCondition )  //and rsiDipped   comment="Add "  +tostring(barCount[1],"####")bgcolor(add_on_divergence and addCondition ? color.green : na,transp=0)     //Take profit Exitstrategy.close(id="VWAP_RSI LE", comment="TP Exit",   when=crossunder(rsiVal,90) )//stoplossstopLossVal =   strategy.position_avg_price -  (strategy.position_avg_price*stopLoss*0.01) strategy.close(id="VWAP_RSI LE", comment="SL Exit",   when= close < stopLossVal)