Pine Script v4 · Strategy
[VJ] Viper VWAP Intraday
A Pine Script v4 strategy built on Change (src) and ATR or Highest or Lowest (1). It has 3 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. 7 settings; defaults include Market session 0915-1455, Long Take Profit (%) 1 and Short Take Profit (%) 1.
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 [VJ] Viper VWAP Intraday repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did [VJ] Viper VWAP Intraday do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a session window, which can leave these candles out. On BNBUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
- Can [VJ] Viper VWAP Intraday be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 changes the results, so no v5 download is offered; the edits are shown below.
- Does [VJ] Viper VWAP Intraday use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does [VJ] Viper VWAP Intraday run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 41 ms, in the browser.
BTCUSDT · 1D · default settings
- Change
- Change
- ATR
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
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 70, 75, 80. The upgraded version below moves each call inside an if block.
-
Note
Uses long =, which v5 renamed line 70
long = on line 70, 75. 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 sum → math.sum, change → ta.change, log10 → math.log10, atr → ta.atr, highest → ta.highest, lowest → ta.lowest.
- 3 strategy calls use the when = argument (line 70, 75, 80). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
DiffersTrades differ: 1 before, 2 after on BNBUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 11: input(type = input.session) → input.session()
- Line 15: input(type = input.float) → input.float()
- Line 17: input(type = input.float) → input.float()
- Line 21: input(type = input.float) → input.float()
- Line 23: input(type = input.float) → input.float()
18 more edits
- Line 38: input(type = input.integer) → input.int()
- Line 40: sum → math.sum
- Line 40: change → ta.change
- Line 41: sum → math.sum
- Line 41: change → ta.change
- Line 45: log10 → math.log10
- Line 45: sum → math.sum
- Line 45: atr → ta.atr
- Line 45: highest → ta.highest
- Line 45: lowest → ta.lowest
- Line 45: log10 → math.log10
- Line 48: input(type = input.float) → input.float()
- Line 65: vwap → ta.vwap
- Line 65: vwap → ta.vwap
- Line 66: vwap → ta.vwap
- Line 66: vwap → ta.vwap
- Line 70: long = strategy.long → direction = strategy.long
- Line 75: long = strategy.short → direction = strategy.short
⋯// © vikris-//@version=4+//@version=5strategy("[VJ] Viper VWAP Intraday", overlay=true, calc_on_every_tick = false)⋯// square-off time set by your broker-var i_marketSession = input(title="Market session", type=input.session, +var i_marketSession = input.session(title="Market session", defval="0915-1455", confirm=true)⋯// Make inputs that set the take profit % (optional)-longProfitPerc = input(title="Long Take Profit (%)",- type=input.float, minval=0.0, step=0.1, defval=1) * 0.01+longProfitPerc = input.float(title="Long Take Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01-shortProfitPerc = input(title="Short Take Profit (%)",- type=input.float, minval=0.0, step=0.1, defval=1) * 0.01+shortProfitPerc = input.float(title="Short Take Profit (%)", minval=0.0, step=0.1, defval=1) * 0.01 // Set stop loss level with input options (optional)-longLossPerc = input(title="Long Stop Loss (%)",- type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01+longLossPerc = input.float(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=0.5) * 0.01-shortLossPerc = input(title="Short Stop Loss (%)",- type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01 +shortLossPerc = input.float(title="Short Stop Loss (%)", minval=0.0, step=0.1, defval=0.5) * 0.01 ⋯// ********** Strategy - Start **********-cilength = input(title="Length", type=input.integer, defval=14, minval=1, maxval=2000)+cilength = input.int(title="Length", defval=14, minval=1, maxval=2000)src = hlc3-upper = sum(volume * (change(src) <= 0 ? 0 : src), cilength)+upper = math.sum(volume * (ta.change(src) <= 0 ? 0 : src), cilength)-lower = sum(volume * (change(src) >= 0 ? 0 : src), cilength)+lower = math.sum(volume * (ta.change(src) >= 0 ? 0 : src), cilength)_rsi(upper, lower) =>⋯mf = _rsi(upper, lower)-ci = 100 * log10(sum(atr(1), cilength) / (highest(cilength) - lowest(cilength))) / log10(cilength)+ci = 100 * math.log10(math.sum(ta.atr(1), cilength) / (ta.highest(cilength) - ta.lowest(cilength))) / math.log10(cilength)// bcod = mf < 25 and ci <50 // scod = mf >75 and ci <50 -citrendfactor = input(title="Trend Factor", type=input.float, defval=38.2, minval=1.0, maxval=100.0)+citrendfactor = input.float(title="Trend Factor", defval=38.2, minval=1.0, maxval=100.0)bcod = mf < 25 ⋯//Final Long/Short Condition-longCondition = redCandle and vol and vwap > vwap[1] and ci <citrendfactor+longCondition = redCandle and vol and ta.vwap > ta.vwap[1] and ci <citrendfactor-shortCondition =greenCandle and vol and vwap < vwap[1] and ci <citrendfactor+shortCondition =greenCandle and vol and ta.vwap < ta.vwap[1] and ci <citrendfactor ⋯// When longCondition and intradaySession both are true-strategy.entry(id = "Long", long = strategy.long, +strategy.entry(id = "Long", direction = strategy.long, when = longCondition and intradaySession)⋯// When shortCondition and intradaySession both are true-strategy.entry(id = "Short", long = strategy.short, +strategy.entry(id = "Short", direction = strategy.short, when = shortCondition and intradaySession)⋯Clean v5
VerifiedSame 2 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine.
- Line 66: when = longCondition and intradaySession → if block
- Line 71: when = shortCondition and intradaySession → if block
- Line 76: when = squareOff → if block
⋯// When longCondition and intradaySession both are true-strategy.entry(id = "Long", direction = strategy.long, - when = longCondition and intradaySession)+if longCondition and intradaySession+ strategy.entry(id = "Long", direction = strategy.long) ⋯// When shortCondition and intradaySession both are true-strategy.entry(id = "Short", direction = strategy.short, - when = shortCondition and intradaySession)+if shortCondition and intradaySession+ strategy.entry(id = "Short", direction = strategy.short) ⋯squareOff = (not intradaySession) and (strategy.position_size != 0)-strategy.close_all(when = squareOff, comment = "Square-off")+if squareOff+ strategy.close_all(comment = "Square-off")// ********** Strategy - End **********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: 2 before, 9 after on BTCUSDT 4h, 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.
⋯// © vikris-//@version=5+//@version=6strategy("[VJ] Viper VWAP Intraday", overlay=true, calc_on_every_tick = false)⋯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 |
|---|---|---|---|
| Market session | 0915-1455 | session | intradaySession |
| Long Take Profit (%) | 1 | float · min 0.0 · step 0.1 | longExitPrice |
| Short Take Profit (%) | 1 | float · min 0.0 · step 0.1 | shortExitPrice |
| Long Stop Loss (%) | 0.5 | float · min 0.0 · step 0.1 | longStopPrice |
| Short Stop Loss (%) | 0.5 | float · min 0.0 · step 0.1 | shortStopPrice |
| Length | 14 | int (written input.integer) · min 1 · max 2000 | upper lower ci |
| Trend Factor | 38.2 | float · min 1.0 · max 100.0 | longCondition shortCondition |
What it calculates
- Change (
change,ta.changein v5)srcupper · line 40 - Change (
change,ta.changein v5)srclower · line 41 - ATR / Highest / Lowest (
atr,ta.atrin v5)1ci · line 45
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 and intradaySession | On | 70 |
| Open Short short | shortCondition and intradaySession | On | 75 |
| Close | squareOff(not intradaySession) and (strategy.position_size != 0) | On | 80 |
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.
- 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 1 | 0% | 0.00 | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
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 |
|---|---|---|---|---|---|
| [VJ] Viper VWAP Intraday this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Aggresive Scalper-Swing Crypto Strategy by exlux99 | lowest highest atr | v4 strategy | −7.4% | 3 | 16.0% |
| Donchian Channels Strategy by KrisWaters by kriswaters | highest lowest atr | v4 strategy | +55.8% | 21 | 23.3% |
| Chandelier Exit - Strategy by melihtuna | atr highest lowest | v4 strategy | −34.8% | 11 | 43.2% |
| ETF trader by FX_minds | atr lowest highest | v4 strategy | +78.3% | 17 | 32.7% |
| Chandelier Exit by Zeal Terminal | atr highest lowest | v5 indicator | indicator | ||
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | With a workaround 1,000 bars in 41 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as long = strategy.long, long = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 70, 75) so the engine trades the way the script says. 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. 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/// © vikris//@version=4strategy("[VJ] Viper VWAP Intraday", overlay=true, calc_on_every_tick = false)// ********** Strategy inputs - Start **********// Used for intraday handling// Session value should be from market start to the time you want to square-off // your intraday strategy// Important: The end time should be at least 2 minutes before the intraday// square-off time set by your brokervar i_marketSession = input(title="Market session", type=input.session, defval="0915-1455", confirm=true) // Make inputs that set the take profit % (optional)longProfitPerc = input(title="Long Take Profit (%)", type=input.float, minval=0.0, step=0.1, defval=1) * 0.01shortProfitPerc = input(title="Short Take Profit (%)", type=input.float, minval=0.0, step=0.1, defval=1) * 0.01 // Set stop loss level with input options (optional)longLossPerc = input(title="Long Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01shortLossPerc = input(title="Short Stop Loss (%)", type=input.float, minval=0.0, step=0.1, defval=0.5) * 0.01 // ********** Strategy inputs - End **********// ********** Supporting functions - Start **********// A function to check whether the bar or period is in intraday sessionbarInSession(sess) => time(timeframe.period, sess) != 0// Figure out take profit pricelongExitPrice = strategy.position_avg_price * (1 + longProfitPerc)shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)// Determine stop loss pricelongStopPrice = strategy.position_avg_price * (1 - longLossPerc)shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)// ********** Supporting functions - End **********// ********** Strategy - Start **********cilength = input(title="Length", type=input.integer, defval=14, minval=1, maxval=2000)src = hlc3upper = sum(volume * (change(src) <= 0 ? 0 : src), cilength)lower = sum(volume * (change(src) >= 0 ? 0 : src), cilength)_rsi(upper, lower) => 100.0 - (100.0 / (1.0 + upper / lower))mf = _rsi(upper, lower)ci = 100 * log10(sum(atr(1), cilength) / (highest(cilength) - lowest(cilength))) / log10(cilength)// bcod = mf < 25 and ci <50 // scod = mf >75 and ci <50 citrendfactor = input(title="Trend Factor", type=input.float, defval=38.2, minval=1.0, maxval=100.0)bcod = mf < 25 scod = mf >75//Vol Confirmationvol = volume > volume[1]//Engulfing candle confirm// bullishEC = close > open[1] and close[1] < open[1]// bearishEC = close < open[1] and close[1] > open[1]//Candles colorsgreenCandle = (close > open)redCandle = (close < open)// See if intraday session is activebool intradaySession = barInSession(i_marketSession)// Trade only if intraday session is active //Final Long/Short ConditionlongCondition = redCandle and vol and vwap > vwap[1] and ci <citrendfactorshortCondition =greenCandle and vol and vwap < vwap[1] and ci <citrendfactor // Long position// When longCondition and intradaySession both are truestrategy.entry(id = "Long", long = strategy.long, when = longCondition and intradaySession) // Short position// When shortCondition and intradaySession both are truestrategy.entry(id = "Short", long = strategy.short, when = shortCondition and intradaySession) // Square-off position (when session is over and position is open)squareOff = (not intradaySession) and (strategy.position_size != 0)strategy.close_all(when = squareOff, comment = "Square-off")// ********** Strategy - End **********