Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Dillon's Double VWAP Strategy

A Pine Script v5 strategy built on Change (high), RMA (ta.tr, len) and EMA (hl2, 100). It has 40 order rules, 20 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.05% commission. 25 settings; defaults include Anchor Period Session, VWAP Source close and Inner Bands Multiplier 1.0.

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 Dillon's Double VWAP Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Dillon's Double VWAP Strategy 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 BTCUSDT 4h it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Does Dillon's Double VWAP Strategy run in Pine Script v6?
Yes
Same 5 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Dillon's Double VWAP Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 199, 200, 201, 202, 210, 227, 228, 229, 230, 238.
Does Dillon's Double VWAP Strategy run in Zeal Terminal?
Yes
It compiles in 106 ms and runs 1,000 bars in 186 ms, in the browser.

BTCUSDT · 1D · default settings

  • ADX
  • Plot
  • VWAP
  • Upper Inner Band
  • Lower Inner Band
  • Upper Outer Band
  • Lower Outer Band
  • Bars Since Entry
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$100,000$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 direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 187, 188, 190, 191, 192, 194 and more) 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. The live re-run is not offered here: the script requests BINANCE:BTCUSDT 240, which this page cannot load in your browser.

Needs BINANCE:BTCUSDT 240 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.

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

    1 setting does nothing

    “Use EMA Distance Filter” is declared but never read.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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 187, 188, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 204, 205, 206, 207, 209, 210, 211, 215, 216, 218, 219, 220, 222, 223, 224, 225, 227, 228, 229, 230, 232, 233, 234, 235, 237, 238, 239. The upgraded version below moves each call inside an if block.

Settings

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

SettingDefaultType and rangeFeeds
VWAP Settings
Anchor PeriodSessionstring · options ["Session", "Week", "Month", "Quarter", "Year"]isNewPeriod
VWAP Sourceclosesourcesum_src_vol sum_src_src_vol inner_vwap inner_bottom inner_top outer_vwap outer_bottom outer_top
Inner Bands Multiplier1.0float · step .1inner_vwap inner_bottom inner_top
Outer Bands Multiplier2.1float · step .1outer_vwap outer_bottom outer_top
ADX Settings
ADX Smoothing14intadx adx_val
DI Length14intplus minus adx_val
ADX ThresholdThe minumn ADX value to allow opening a postion30intadx_is_below_threshold
Ladder Into PositionsEnable this to use the laddering settings below.trueboolexit Close Long Ladder 1 exit Close Long Ladder 2 exit Close Long Ladder 3 exit Close Long Ladder 4 cancel Long Ladder 1 cancel Long Ladder 2 cancel Long Ladder 3 cancel Long Ladder 4 entry Long exit Close Long cancel Long exit Close short Ladder 1 exit Close short Ladder 2 exit Close short Ladder 3 exit Close short Ladder 4 cancel short Ladder 1 cancel short Ladder 2 cancel short Ladder 3 cancel short Ladder 4 entry short exit Close short cancel short line 136 line 185 line 213
indent_4+"Ladder Rungs"3int · min 2 · max 4 · step 1position_qty entry Long Ladder 1 entry Long Ladder 2 entry Long Ladder 1 entry Long Ladder 2 entry Long Ladder 3 entry Long Ladder 1 entry Long Ladder 2 entry Long Ladder 3 entry Long Ladder 4 entry short Ladder 1 entry short Ladder 2 entry short Ladder 1 entry short Ladder 2 entry short Ladder 3 entry short Ladder 1 entry short Ladder 2 entry short Ladder 3 entry short Ladder 4 line 186 line 189 line 193 line 214 line 217 line 221
indent_4+"Ladder Step (%)".25float · step .1long_ladder_1_limit_price long_ladder_2_limit_price long_ladder_3_limit_price long_ladder_4_limit_price short_ladder_1_limit_price short_ladder_2_limit_price short_ladder_3_limit_price short_ladder_4_limit_price
Entry Settings
Stop Loss (%)5.0float · step 0.1long_stop_loss short_stop_loss
Take Profit (%)10.5float · step 0.1long_profit_target short_profit_target
Long Entry Limit Lookback1int · min 1 · step 1limit_order_long_price
Short Entry Limit Lookback1int · min 1 · step 1limit_order_short_price
Start Trailing After (%)3float · step 0.1long_start_trailing_val short_start_trailing_val
Trail Behind (%)4float · step 0.1long_trail_behind_val short_trail_behind_val long_trailing_stop short_trailing_stop
Close early if price crosses outer VWAP bandEnabling this will cause entries to close if/when the price crosses the VWAP to the other outer band.falseboollong_position_take_profit short_position_take_profit
Limit Entries
Use EMA Filtertrueboollong_conditions_met short_conditions_met EMA Macro Filter
indent_4+"Timeframe"240timeframeema_filter_smoothed
indent_4+"Length"100int · min 1 · step 10ema_filter
indent_4+"Source"hl2sourceema_filter
Use EMA Distance Filtertrueboolunused
indent_4+"EMA Min Distance (%)"Disable opening trades when the price is too close to the above EMA.2.0floatprice_far_enough_away_from_ema
Use Time Session FiltertrueboolwithinTime
indent_4+"Time Session To Ignore Trades"1400-2200sessionwithinTime

What it calculates

  • Changehighup · line 101
  • Changelowdown · line 102
  • RMAta.tr, lentrue_range · line 105
  • RMAmath.abs(plus - minus) / (sum == 0 ? 1 : sum), ADX Smoothing (14)adx · line 112
  • EMAindent_4+"Source" (hl2), indent_4+"Length" (100)ema_filter · line 116
  • Lowesthl2, Long Entry Limit Lookback (1)limit_order_long_price · line 143
  • Highesthl2, Short Entry Limit Lookback (1)limit_order_short_price · line 144
  • Highesthigh, bars_since_entrylong_run_up · line 156
  • Lowestlow, bars_since_entryshort_run_up · line 157
  • Crossoverhigh, upper_outer_band_valueprice_crossed_up_VWAP_upper_outer_band · line 165
  • Crossunderlow, lower_outer_band_valueprice_crossed_down_VWAP_lower_outer_band · line 166
  • Crossclose, short_trailing_stopprice_closed_below_short_trailing_stop · line 175
  • Crossclose, long_trailing_stopprice_closed_above_long_entry_trailing_stop · line 177

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.

The script has 132 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long Ladder 1 longlong_conditions_metOn187
Open Long Ladder 2 longlong_conditions_metOn188
Open Long Ladder 1 longlong_conditions_metOn190
Open Long Ladder 2 longlong_conditions_metOn191
Open Long Ladder 3 longlong_conditions_metOn192
Open Long Ladder 1 longlong_conditions_metOn194
Open Long Ladder 2 longlong_conditions_metOn195
Open Long Ladder 3 longlong_conditions_metOn196
Open Long Ladder 4 longlong_conditions_metOn197
Exit Close Long Ladder 1 stop and limitlong_position_take_profitOn “Ladder Into Positions”199
Exit Close Long Ladder 2 stop and limitlong_position_take_profitOn “Ladder Into Positions”200
Exit Close Long Ladder 3 stop and limitlong_position_take_profitOn “Ladder Into Positions”201
Exit Close Long Ladder 4 stop and limitlong_position_take_profitOn “Ladder Into Positions”202
cancel Long Ladder 1cancel_long_conditionOn “Ladder Into Positions”204
cancel Long Ladder 2cancel_long_conditionOn “Ladder Into Positions”205
cancel Long Ladder 3cancel_long_conditionOn “Ladder Into Positions”206
cancel Long Ladder 4cancel_long_conditionOn “Ladder Into Positions”207
Open Long longlong_conditions_metOn “Ladder Into Positions”209
Exit Close Long stop and limitlong_position_take_profitOn “Ladder Into Positions”210
cancel Longcancel_long_conditionOn “Ladder Into Positions”211
Open short Ladder 1 shortshort_conditions_metOn215
Open short Ladder 2 shortshort_conditions_metOn216
Open short Ladder 1 shortshort_conditions_metOn218
Open short Ladder 2 shortshort_conditions_metOn219
Open short Ladder 3 shortshort_conditions_metOn220
Open short Ladder 1 shortshort_conditions_metOn222
Open short Ladder 2 shortshort_conditions_metOn223
Open short Ladder 3 shortshort_conditions_metOn224
Open short Ladder 4 shortshort_conditions_metOn225
Exit Close short Ladder 1 stop and limitshort_position_take_profitOn “Ladder Into Positions”227
Exit Close short Ladder 2 stop and limitshort_position_take_profitOn “Ladder Into Positions”228
Exit Close short Ladder 3 stop and limitshort_position_take_profitOn “Ladder Into Positions”229
Exit Close short Ladder 4 stop and limitshort_position_take_profitOn “Ladder Into Positions”230
cancel short Ladder 1cancel_short_conditionOn “Ladder Into Positions”232
cancel short Ladder 2cancel_short_conditionOn “Ladder Into Positions”233
cancel short Ladder 3cancel_short_conditionOn “Ladder Into Positions”234
cancel short Ladder 4cancel_short_conditionOn “Ladder Into Positions”235
Open short shortshort_conditions_metOn “Ladder Into Positions”237
Exit Close short stop and limitshort_position_take_profitOn “Ladder Into Positions”238
cancel shortcancel_short_conditionOn “Ladder Into Positions”239

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

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 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationreads realtime-only state. Live values can differ from history.
  • 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

Not run on other markets: the script requests BINANCE:BTCUSDT 240, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.

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
Dillon's Double VWAP Strategy this page—v5 strategy0.0%00.0%
5 Minute EMA Cross Strategy by jordanfrayema lowest highest crossv5 strategy+3.4%97.5%
PB Trend Scalper by PatrickGwynBuckleyema rma highest lowestv5 strategy−16.9%1068.3%
Jigga - Survival Level by jigneshjcrma highest lowest emav5 strategyNo trades on this market
Bagheri IG Ether by Bagheri_IGema highest lowest rmav4 strategy+0.0%30.0%
Bagheri IG Ether v2 by Bagheri_IGema highest lowest rmav4 strategy−0.0%20.0%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 40 strategy calls use the when = argument (line 187, 188, 190, 191, 192, 194, 195, 196, 197, 199, 200, 201, 202, 204, 205, 206, 207, 209, 210, 211, 215, 216, 218, 219, 220, 222, 223, 224, 225, 227, 228, 229, 230, 232, 233, 234, 235, 237, 238, 239). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 187: when = long_conditions_met → if block
  • Line 188: when = long_conditions_met → if block
  • Line 190: when = long_conditions_met → if block
  • Line 191: when = long_conditions_met → if block
  • Line 192: when = long_conditions_met → if block
  • Line 194: when = long_conditions_met → if block
34 more edits
  • Line 195: when = long_conditions_met → if block
  • Line 196: when = long_conditions_met → if block
  • Line 197: when = long_conditions_met → if block
  • Line 199: when = long_position_take_profit → if block
  • Line 200: when = long_position_take_profit → if block
  • Line 201: when = long_position_take_profit → if block
  • Line 202: when = long_position_take_profit → if block
  • Line 204: when = cancel_long_condition → if block
  • Line 205: when = cancel_long_condition → if block
  • Line 206: when = cancel_long_condition → if block
  • Line 207: when = cancel_long_condition → if block
  • Line 209: when = long_conditions_met → if block
  • Line 210: when = long_position_take_profit → if block
  • Line 211: when = cancel_long_condition → if block
  • Line 215: when = short_conditions_met → if block
  • Line 216: when = short_conditions_met → if block
  • Line 218: when = short_conditions_met → if block
  • Line 219: when = short_conditions_met → if block
  • Line 220: when = short_conditions_met → if block
  • Line 222: when = short_conditions_met → if block
  • Line 223: when = short_conditions_met → if block
  • Line 224: when = short_conditions_met → if block
  • Line 225: when = short_conditions_met → if block
  • Line 227: when = short_position_take_profit → if block
  • Line 228: when = short_position_take_profit → if block
  • Line 229: when = short_position_take_profit → if block
  • Line 230: when = short_position_take_profit → if block
  • Line 232: when = cancel_short_condition → if block
  • Line 233: when = cancel_short_condition → if block
  • Line 234: when = cancel_short_condition → if block
  • Line 235: when = cancel_short_condition → if block
  • Line 237: when = short_conditions_met → if block
  • Line 238: when = short_position_take_profit → if block
  • Line 239: when = cancel_short_condition → if block
⋯    if ladderRungs == 2-        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price)-        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price)    else if ladderRungs == 3-        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price)-        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price)-        strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price)    else if ladderRungs == 4-        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price)-        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price)-        strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price)-        strategy.entry(id="Long Ladder 4", direction=strategy.long, qty=position_qty, limit=long_ladder_4_limit_price, when=long_conditions_met)+        if long_conditions_met+            strategy.entry(id="Long Ladder 4", direction=strategy.long, qty=position_qty, limit=long_ladder_4_limit_price)    -    strategy.exit(id="Close Long Ladder 1", from_entry="Long Ladder 1", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)+    if long_position_take_profit+        strategy.exit(id="Close Long Ladder 1", from_entry="Long Ladder 1", stop=long_trailing_stop, limit=long_profit_target)-    strategy.exit(id="Close Long Ladder 2", from_entry="Long Ladder 2", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)+    if long_position_take_profit+        strategy.exit(id="Close Long Ladder 2", from_entry="Long Ladder 2", stop=long_trailing_stop, limit=long_profit_target)-    strategy.exit(id="Close Long Ladder 3", from_entry="Long Ladder 3", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)+    if long_position_take_profit+        strategy.exit(id="Close Long Ladder 3", from_entry="Long Ladder 3", stop=long_trailing_stop, limit=long_profit_target)-    strategy.exit(id="Close Long Ladder 4", from_entry="Long Ladder 4", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)+    if long_position_take_profit+        strategy.exit(id="Close Long Ladder 4", from_entry="Long Ladder 4", stop=long_trailing_stop, limit=long_profit_target)    -    strategy.cancel(id="Long Ladder 1", when=cancel_long_condition)+    if cancel_long_condition+        strategy.cancel(id="Long Ladder 1")-    strategy.cancel(id="Long Ladder 2", when=cancel_long_condition)+    if cancel_long_condition+        strategy.cancel(id="Long Ladder 2")-    strategy.cancel(id="Long Ladder 3", when=cancel_long_condition)+    if cancel_long_condition+        strategy.cancel(id="Long Ladder 3")-    strategy.cancel(id="Long Ladder 4", when=cancel_long_condition)+    if cancel_long_condition+        strategy.cancel(id="Long Ladder 4")else-    strategy.entry(id="Long", direction=strategy.long, qty=position_qty, when=long_conditions_met)+    if long_conditions_met+        strategy.entry(id="Long", direction=strategy.long, qty=position_qty)-    strategy.exit(id="Close Long", from_entry="Long", stop=long_stop_loss, limit=long_profit_target, when=long_position_take_profit)+    if long_position_take_profit+        strategy.exit(id="Close Long", from_entry="Long", stop=long_stop_loss, limit=long_profit_target)-    strategy.cancel(id="Long", when=cancel_long_condition)+    if cancel_long_condition+        strategy.cancel(id="Long")// short Entry⋯    if ladderRungs == 2-        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price)-        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price)    else if ladderRungs == 3-        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price)-        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price)-        strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price)    else if ladderRungs == 4-        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price)-        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price)-        strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price)-        strategy.entry(id="short Ladder 4", direction=strategy.short, qty=position_qty, limit=short_ladder_4_limit_price, when=short_conditions_met)+        if short_conditions_met+            strategy.entry(id="short Ladder 4", direction=strategy.short, qty=position_qty, limit=short_ladder_4_limit_price)    -    strategy.exit(id="Close short Ladder 1", from_entry="short Ladder 1", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)+    if short_position_take_profit+        strategy.exit(id="Close short Ladder 1", from_entry="short Ladder 1", stop=short_trailing_stop, limit=short_profit_target)-    strategy.exit(id="Close short Ladder 2", from_entry="short Ladder 2", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)+    if short_position_take_profit+        strategy.exit(id="Close short Ladder 2", from_entry="short Ladder 2", stop=short_trailing_stop, limit=short_profit_target)-    strategy.exit(id="Close short Ladder 3", from_entry="short Ladder 3", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)+    if short_position_take_profit+        strategy.exit(id="Close short Ladder 3", from_entry="short Ladder 3", stop=short_trailing_stop, limit=short_profit_target)-    strategy.exit(id="Close short Ladder 4", from_entry="short Ladder 4", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)+    if short_position_take_profit+        strategy.exit(id="Close short Ladder 4", from_entry="short Ladder 4", stop=short_trailing_stop, limit=short_profit_target)    -    strategy.cancel(id="short Ladder 1", when=cancel_short_condition)+    if cancel_short_condition+        strategy.cancel(id="short Ladder 1")-    strategy.cancel(id="short Ladder 2", when=cancel_short_condition)+    if cancel_short_condition+        strategy.cancel(id="short Ladder 2")-    strategy.cancel(id="short Ladder 3", when=cancel_short_condition)+    if cancel_short_condition+        strategy.cancel(id="short Ladder 3")-    strategy.cancel(id="short Ladder 4", when=cancel_short_condition)+    if cancel_short_condition+        strategy.cancel(id="short Ladder 4")else-    strategy.entry(id="short", direction=strategy.short, qty=position_qty, when=short_conditions_met)+    if short_conditions_met+        strategy.entry(id="short", direction=strategy.short, qty=position_qty)-    strategy.exit(id="Close short", from_entry="short", stop=short_stop_loss, limit=short_profit_target, when=short_position_take_profit)+    if short_position_take_profit+        strategy.exit(id="Close short", from_entry="short", stop=short_stop_loss, limit=short_profit_target)-    strategy.cancel(id="short", when=cancel_short_condition)+    if cancel_short_condition+        strategy.cancel(id="short")// Plot entry lines & values⋯

Does it run in Pine Script v6?

Yes

Same 5 trades and the same P&L on BTCUSDT 4h, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © jordanfray-//@version=5+//@version=6strategy(title="Double VWAP Strategy", overlay=true, max_bars_back=5000, default_qty_type=strategy.percent_of_equity, default_qty_value=100,initial_capital=100000, commission_type=strategy.commission.percent, commission_value=0.05, backtest_fill_limits_assumption=2)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 106 msWith a workaround 1,000 bars in 186 msNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 187, 188, 190, 191, 192, 194 and more) 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.

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/// © jordanfray//@version=5strategy(title="Double VWAP Strategy", overlay=true, max_bars_back=5000, default_qty_type=strategy.percent_of_equity, default_qty_value=100,initial_capital=100000, commission_type=strategy.commission.percent, commission_value=0.05, backtest_fill_limits_assumption=2)// Indenting Classsindent_1 = " "indent_2 = "  "indent_3 = "   "indent_4 = "    "// Group Titlesgroup_one_title = "VWAP Settings"group_two_title = "ADX Settings"group_three_title = "Entry Settings"group_four_title = "Limit Entries"// Input Tipsadx_thresholdToolTip = "The minumn ADX value to allow opening a postion"adxCancelToolTip= "You can optionally set a different lower value for ADX that will allow entries even if below the trigger threshold."close_early_toopTip = "Enabling this will cause entries to close if/when the price crosses the VWAP to the other outer band."ladderInToolTip = "Enable this to use the laddering settings below."emaDistanceToolTip = "Disable opening trades when the price is too close to the above EMA."// Colorsocean_blue = color.new(#0C6090,0)sky_blue = color.new(#00A5FF,0)green = color.new(#2DBD85,0)red = color.new(#E02A4A,0)light_blue = color.new(#00A5FF,90)light_green = color.new(#2DBD85,90)light_red = color.new(#E02A4A,90)light_yellow = color.new(#FFF900,90)white = color.new(#ffffff,0)transparent = color.new(#000000,100)// Strategy Settingsanchor =                      input.string(defval="Session", title="Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year"], group=group_one_title)src =                         input.source(defval=close, title="VWAP Source", group=group_one_title)multiplier_inner =            input.float(defval=1.0, step=.1, title="Inner Bands Multiplier", group=group_one_title)multiplier_outer =            input.float(defval=2.1, step=.1, title="Outer Bands Multiplier", group=group_one_title)adx_len =                     input.int(defval=14, title="ADX Smoothing", group=group_two_title)di_len =                      input.int(defval=14, title="DI Length", group=group_two_title)adx_threshold =               input.int(defval=30, title="ADX Threshold", group=group_two_title, tooltip=adx_thresholdToolTip)enableLaddering =             input.bool(defval=true, title="Ladder Into Positions", tooltip=ladderInToolTip, group=group_two_title)ladderRungs =                 input.int(defval=3, minval=2, maxval=4, step=1, title=indent_4+"Ladder Rungs", group=group_two_title)ladderStep =                  input.float(defval=.25, title=indent_4+"Ladder Step (%)", step=.1, group=group_two_title)/100stop_loss_val =               input.float(defval=5.0, title="Stop Loss (%)", step=0.1, group=group_three_title)/100take_profit_val =             input.float(defval=10.5, title="Take Profit (%)", step=0.1, group=group_three_title)/100long_entry_limit_lookback =   input.int(defval=1, title="Long Entry Limit Lookback", minval=1, step=1, group=group_three_title)short_entry_limit_lookback =  input.int(defval=1, title="Short Entry Limit Lookback", minval=1, step=1, group=group_three_title)start_trailing_after =        input.float(defval=3, title="Start Trailing After (%)", step=0.1, group=group_three_title)/100trail_behind =                input.float(defval=4, title="Trail Behind (%)", step=0.1, group=group_three_title)/100close_early =                 input.bool(defval=false, title="Close early if price crosses outer VWAP band", tooltip=close_early_toopTip)enableEmaFilter =             input.bool(defval=true, title="Use EMA Filter", group=group_four_title)emaFilterTimeframe =          input.timeframe(defval="240", title=indent_4+"Timeframe", group=group_four_title)emaFilterLength =             input.int(defval=100, minval=1, step=10, title=indent_4+"Length", group=group_four_title)emaFilterSource =             input.source(defval=hl2, title=indent_4+"Source", group=group_four_title)enableEmaDistanceFilter =     input.bool(defval=true, title="Use EMA Distance Filter", group=group_four_title)emaDistanceThreshold =        input.float(defval=2.0, title=indent_4+"EMA Min Distance (%)", group=group_four_title, tooltip=emaDistanceToolTip)useTimeFilter =               input.bool(defval=true, title="Use Time Session Filter", group=group_four_title)timeSession =                 input.session(defval="1400-2200", title=indent_4+"Time Session To Ignore Trades", group=group_four_title)// Calculate and plot VWAP bandsfloat vwap_val = nafloat upper_inner_band_value = nafloat lower_inner_band_value = nafloat upper_outer_band_value = nafloat lower_outer_band_value = navar cumVol = 0.cumVol += nz(volume)if barstate.islast and cumVol == 0    runtime.error("No volume is provided by the data vendor.")    computeVWAP(src, isNewPeriod, stDevMultiplier) =>    var float sum_src_vol = na    var float sum_vol = na    var float sum_src_src_vol = na    sum_src_vol := isNewPeriod ? src * volume : src * volume + sum_src_vol[1]    sum_vol := isNewPeriod ? volume : volume + sum_vol[1]    sum_src_src_vol := isNewPeriod ? volume * math.pow(src, 2) : volume * math.pow(src, 2) + sum_src_src_vol[1]    _vwap = sum_src_vol / sum_vol    variance = sum_src_src_vol / sum_vol - math.pow(_vwap, 2)    variance := variance < 0 ? 0 : variance    standard_deviation = math.sqrt(variance)    lower_band_value = _vwap - standard_deviation * stDevMultiplier    upper_band_value = _vwap + standard_deviation * stDevMultiplier    [_vwap, lower_band_value, upper_band_value]timeChange(period) =>    ta.change(time(period))isNewPeriod = switch anchor    "Session" => timeChange("D")    "Week" => timeChange("W")    "Month" => timeChange("M")    "Quarter" => timeChange("3M")    "Year" => timeChange("12M")    => false[inner_vwap, inner_bottom, inner_top] = computeVWAP(src, isNewPeriod, multiplier_inner)[outer_vwap, outer_bottom, outer_top] = computeVWAP(src, isNewPeriod, multiplier_outer)vwap_val := inner_vwapupper_inner_band_value := inner_toplower_inner_band_value := inner_bottomupper_outer_band_value := outer_toplower_outer_band_value := outer_bottom// Calculate and plot ADXdirmov(len) =>    up = ta.change(high)    down = -ta.change(low)    plus_dm = na(up) ? na : (up > down and up > 0 ? up : 0)    minus_dm = na(down) ? na : (down > up and down > 0 ? down : 0)    true_range = ta.rma(ta.tr, len)    plus = fixnan(100 * ta.rma(plus_dm, len) / true_range)    minus = fixnan(100 * ta.rma(minus_dm, len) / true_range)    [plus, minus]adx(di_len, adx_len) =>    [plus, minus] = dirmov(di_len)    sum = plus + minus    adx = 100 * ta.rma(math.abs(plus - minus) / (sum == 0 ? 1 : sum), adx_len)adx_val = adx(di_len, adx_len)plot(adx_val, title="ADX")// Calculate and Plot Macro EMAema_filter = ta.ema(emaFilterSource, emaFilterLength)ema_filter_smoothed = request.security(syminfo.tickerid, emaFilterTimeframe, ema_filter[barstate.isrealtime ? 1 : 0])distance_from_EMA = ((close - ema_filter_smoothed)/close)*100if distance_from_EMA < 0    distance_from_EMA := distance_from_EMA * -1plot(enableEmaFilter ? ema_filter_smoothed: na, title="EMA Macro Filter", style=plot.style_stepline, linewidth=2, color=sky_blue, editable=true)// Calculate if bars are in restricted time periodisInSession(sess) =>     na(time(timeframe.period, sess,"GMT-6")) == falsewithinTime = (useTimeFilter and not isInSession(timeSession)) or not useTimeFilter// Calulate Ladder Entrieslong_ladder_1_limit_price = close - (close * 1 * ladderStep)long_ladder_2_limit_price = close - (close * 2 * ladderStep)long_ladder_3_limit_price = close - (close * 3 * ladderStep)long_ladder_4_limit_price = close - (close * 4 * ladderStep)short_ladder_1_limit_price = close + (close * 1 * ladderStep)short_ladder_2_limit_price = close + (close * 2 * ladderStep)short_ladder_3_limit_price = close + (close * 3 * ladderStep)short_ladder_4_limit_price = close + (close * 4 * ladderStep)var position_qty = strategy.equity/closeif enableLaddering    position_qty := (strategy.equity/close) / ladderRungselse    position_qty := strategy.equity/close    plot(position_qty, color=white)// Calculate entry and exit valueslimit_order_long_price = ta.lowest(hl2, long_entry_limit_lookback)limit_order_short_price = ta.highest(hl2, short_entry_limit_lookback)long_start_trailing_val = strategy.position_avg_price + (strategy.position_avg_price * start_trailing_after)short_start_trailing_val = strategy.position_avg_price - (strategy.position_avg_price * start_trailing_after)long_trail_behind_val = close - (strategy.position_avg_price * (trail_behind/100))short_trail_behind_val = close + (strategy.position_avg_price * (trail_behind/100))currently_in_a_long_postion = strategy.position_size > 0currently_in_a_short_postion = strategy.position_size < 0long_profit_target = strategy.position_avg_price * (1 + take_profit_val)short_profit_target = strategy.position_avg_price * (1 - take_profit_val)long_stop_loss = strategy.position_avg_price * (1.0 - stop_loss_val)short_stop_loss = strategy.position_avg_price * (1 + stop_loss_val)bars_since_entry = currently_in_a_long_postion or currently_in_a_short_postion ? bar_index - strategy.opentrades.entry_bar_index(strategy.opentrades - 1) + 1 : 5long_run_up = ta.highest(high, bars_since_entry)short_run_up = ta.lowest(low, bars_since_entry)long_trailing_stop = currently_in_a_long_postion and bars_since_entry > 0 and long_run_up > long_start_trailing_val ? long_run_up - (long_run_up * trail_behind) : long_stop_lossshort_trailing_stop = currently_in_a_short_postion and bars_since_entry > 0 and short_run_up < short_start_trailing_val ? short_run_up + (short_run_up * trail_behind) : short_stop_loss// Entry Criteriaprice_far_enough_away_from_ema = distance_from_EMA > emaDistanceThresholdadx_is_below_threshold = adx_val < adx_thresholdprice_closed_below_VWAP_upper_outer_band = close < upper_outer_band_valueprice_closed_above_VWAP_lower_outer_band = close > lower_outer_band_valueprice_crossed_up_VWAP_upper_outer_band =  ta.crossover(high,upper_outer_band_value)price_crossed_down_VWAP_lower_outer_band = ta.crossunder(low, lower_outer_band_value)price_above_ema_filter = close > ema_filter_smoothedprice_below_ema_filter = close < ema_filter_smoothed//Trade Restirctionsno_trades_allowed = not withinTime or not adx_is_below_threshold or not price_far_enough_away_from_ema// Enter trades when...long_conditions_met = enableEmaFilter ? price_above_ema_filter and not currently_in_a_short_postion and withinTime and adx_is_below_threshold and price_crossed_down_VWAP_lower_outer_band and price_closed_above_VWAP_lower_outer_band : not currently_in_a_long_postion and withinTime and adx_is_below_threshold and price_crossed_down_VWAP_lower_outer_band and price_closed_above_VWAP_lower_outer_bandshort_conditions_met = enableEmaFilter ? price_below_ema_filter and not currently_in_a_long_postion and withinTime and adx_is_below_threshold and price_crossed_up_VWAP_upper_outer_band and price_closed_below_VWAP_upper_outer_band : not currently_in_a_short_postion and withinTime and adx_is_below_threshold and price_crossed_up_VWAP_upper_outer_band and price_closed_below_VWAP_upper_outer_band// Take Profit When...price_closed_below_short_trailing_stop = ta.cross(close, short_trailing_stop)price_hit_short_entry_profit_target = low > short_profit_targetprice_closed_above_long_entry_trailing_stop = ta.cross(close, long_trailing_stop)price_hit_long_entry_profit_target = high > long_profit_targetlong_position_take_profit = close_early ? price_crossed_up_VWAP_upper_outer_band or price_closed_above_long_entry_trailing_stop or price_hit_long_entry_profit_target : price_closed_above_long_entry_trailing_stop or price_hit_long_entry_profit_targetshort_position_take_profit = close_early ? price_crossed_down_VWAP_lower_outer_band or price_closed_below_short_trailing_stop or price_hit_short_entry_profit_target : price_closed_below_short_trailing_stop or price_hit_short_entry_profit_target// Cancel limir order if...cancel_long_condition = no_trades_allowedcancel_short_condition = no_trades_allowed// Long Entryif enableLaddering    if ladderRungs == 2        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)    else if ladderRungs == 3        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price, when=long_conditions_met)    else if ladderRungs == 4        strategy.entry(id="Long Ladder 1", direction=strategy.long, qty=position_qty, limit=long_ladder_1_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 2", direction=strategy.long, qty=position_qty, limit=long_ladder_2_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 3", direction=strategy.long, qty=position_qty, limit=long_ladder_3_limit_price, when=long_conditions_met)        strategy.entry(id="Long Ladder 4", direction=strategy.long, qty=position_qty, limit=long_ladder_4_limit_price, when=long_conditions_met)        strategy.exit(id="Close Long Ladder 1", from_entry="Long Ladder 1", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)    strategy.exit(id="Close Long Ladder 2", from_entry="Long Ladder 2", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)    strategy.exit(id="Close Long Ladder 3", from_entry="Long Ladder 3", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)    strategy.exit(id="Close Long Ladder 4", from_entry="Long Ladder 4", stop=long_trailing_stop, limit=long_profit_target, when=long_position_take_profit)        strategy.cancel(id="Long Ladder 1", when=cancel_long_condition)    strategy.cancel(id="Long Ladder 2", when=cancel_long_condition)    strategy.cancel(id="Long Ladder 3", when=cancel_long_condition)    strategy.cancel(id="Long Ladder 4", when=cancel_long_condition)else    strategy.entry(id="Long", direction=strategy.long, qty=position_qty, when=long_conditions_met)    strategy.exit(id="Close Long", from_entry="Long", stop=long_stop_loss, limit=long_profit_target, when=long_position_take_profit)    strategy.cancel(id="Long", when=cancel_long_condition)// short Entryif enableLaddering    if ladderRungs == 2        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)    else if ladderRungs == 3        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price, when=short_conditions_met)    else if ladderRungs == 4        strategy.entry(id="short Ladder 1", direction=strategy.short, qty=position_qty, limit=short_ladder_1_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 2", direction=strategy.short, qty=position_qty, limit=short_ladder_2_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 3", direction=strategy.short, qty=position_qty, limit=short_ladder_3_limit_price, when=short_conditions_met)        strategy.entry(id="short Ladder 4", direction=strategy.short, qty=position_qty, limit=short_ladder_4_limit_price, when=short_conditions_met)        strategy.exit(id="Close short Ladder 1", from_entry="short Ladder 1", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)    strategy.exit(id="Close short Ladder 2", from_entry="short Ladder 2", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)    strategy.exit(id="Close short Ladder 3", from_entry="short Ladder 3", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)    strategy.exit(id="Close short Ladder 4", from_entry="short Ladder 4", stop=short_trailing_stop, limit=short_profit_target, when=short_position_take_profit)        strategy.cancel(id="short Ladder 1", when=cancel_short_condition)    strategy.cancel(id="short Ladder 2", when=cancel_short_condition)    strategy.cancel(id="short Ladder 3", when=cancel_short_condition)    strategy.cancel(id="short Ladder 4", when=cancel_short_condition)else    strategy.entry(id="short", direction=strategy.short, qty=position_qty, when=short_conditions_met)    strategy.exit(id="Close short", from_entry="short", stop=short_stop_loss, limit=short_profit_target, when=short_position_take_profit)    strategy.cancel(id="short", when=cancel_short_condition)// Plot entry lines & valuescenter_VWAP_line = plot(vwap_val, title="VWAP", linewidth=1, color=green)upper_inner_band = plot(upper_inner_band_value, title="Upper Inner Band", linewidth=1, color=sky_blue)lower_inner_band = plot(lower_inner_band_value, title="Lower Inner Band", linewidth=1, color=sky_blue)upper_outer_band = plot(upper_outer_band_value, title="Upper Outer Band", linewidth=2, color=ocean_blue)lower_outer_band = plot(lower_outer_band_value, title="Lower Outer Band", linewidth=2, color=ocean_blue)fill(upper_outer_band, lower_outer_band, title="VWAP Bands Fill", color=light_blue)plotshape(long_conditions_met ? close  : na, title="Long Entry Symbol", color=green, style=shape.triangleup, location=location.abovebar)plotshape(short_conditions_met ? close  : na, title="Short Entry Symbol", color=red, style=shape.triangledown, location=location.belowbar)long_trailing_stop_line = plot(long_trailing_stop, style=plot.style_stepline, editable=false, color=currently_in_a_long_postion ? long_trailing_stop > strategy.position_avg_price ? green : red : transparent)short_trailing_stop_line = plot(short_trailing_stop, style=plot.style_stepline, editable=false, color=currently_in_a_short_postion ? short_trailing_stop < strategy.position_avg_price ? green : red : transparent)bars_since_entry_int = plot(bars_since_entry, editable=false, title="Bars Since Entry", color=green)entry = plot(strategy.position_avg_price, editable=false, title="Entry", style=plot.style_stepline, color=currently_in_a_long_postion or currently_in_a_short_postion ? color.blue : transparent, linewidth=1)fill(entry,long_trailing_stop_line, editable=false, color=currently_in_a_long_postion ? long_trailing_stop > strategy.position_avg_price ? light_green : light_red : transparent)fill(entry,short_trailing_stop_line, editable=false, color=currently_in_a_short_postion ? short_trailing_stop < strategy.position_avg_price ? light_green : light_red : transparent)bgcolor(title="No Trades Allowed", color=no_trades_allowed ? light_red : light_green)//long_run_up_line = plot(long_run_up, style=plot.style_stepline, editable=false, color=currently_in_a_long_postion ? green : transparent)//short_run_up_line = plot(short_run_up, style=plot.style_stepline, editable=false, color=currently_in_a_short_postion ? green : transparent)