Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Swing VWAP Crypto and Stocks Strategy

A Pine Script v5 strategy with no technical-analysis calculation. It has 3 order rules, 1 entry among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 100% of equity and pays 0.03% commission. 2 settings; defaults include LONG Stop Loss % 10.0 and LONG Take Profit % 29.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 Swing VWAP Crypto and Stocks Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Swing VWAP Crypto and Stocks Strategy do on BTCUSDT 1D with default settings?
−28.14%
From 26 Jan 2024 to 21 Oct 2026, over 56 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Swing VWAP Crypto and Stocks Strategy 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: 56 before, 56 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Swing VWAP Crypto and Stocks Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 11.
Does Swing VWAP Crypto and Stocks Strategy run in Zeal Terminal?
Yes
It compiles in 7 ms and runs 1,000 bars in 24 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (2)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$72$203Equity from $100
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference.
Net profit
−28.14%
−$28.14
Buy and hold
+102.5%
same period
Closed trades
56
28 won · 28 lost
Profitable
50.0%
of closed trades
Profit factor
0.81
gross profit ÷ gross loss
Max drawdown
55.49%
−$66.56

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

    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 10, 12. 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
Fixed Risk Management
LONG Stop Loss % 10.0floatlongStop
LONG Take Profit %29.0floatlongTake

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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.

stopPerLONG Stop Loss % setting · 10.0takePerLONG Take Profit %setting · 29.0high · low · closehigh · low · closeprice dataclosecloseprice datalongStoplongStopvaluelongTakelongTakevaluelonglongconditionentry:longOpen longstrategy.entryexit:LONG EXITexit LONG EXITstrategy.exitclose_all:close_all strategy.close_all

Order rules

OrderFires whenBy defaultLine
Open long longlong and dayofweek==dayofweek.mondayOn10
Exit LONG EXIT stop and limitevery barOn11
Close dayofweek==dayofweek.sundayOn12

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.

17/17trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. On 3 of them the position changed while the bar was forming before it settled. Anyone watching live sees those changes; once the bar closes it matches history.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. 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

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−28.1%+102.5%5650%0.8155.5%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1.1%+5.5%2050%1.0326.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−14.7%+9.8%5848%0.9256.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−10.6%+8.4%2245%0.7930.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+20.6%+16.7%5947%1.0760.4%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+4.0%+21.5%2148%1.0630.7%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+38.8%+148.3%5054%1.2540.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+31.0%+17.1%1856%2.2513.5%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 market2050%−$30.97
Sideways market2255%$18.39
Falling market1443%−$15.55

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

How bad could the drawdown be?

60.8%

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

0%70%
All 56 trades
SideEntryExitBarsP&L
long30 Jan 2024 43,302.705 Feb 2024 42,582.906−$1.72
long13 Feb 2024 49,917.3019 Feb 2024 52,137.706$4.31
long27 Feb 2024 54,476.504 Mar 2024 63,114.006$16.19
long5 Mar 2024 68,245.7011 Mar 2024 68,955.906$1.16
long12 Mar 2024 72,078.1016 Mar 2024 64,870.304−$12.06
long26 Mar 2024 69,880.001 Apr 2024 71,280.006$2.10
long9 Apr 2024 71,620.0013 Apr 2024 64,458.004−$11.06
long23 Apr 2024 66,819.3029 Apr 2024 63,118.606−$5.53
long30 Apr 2024 63,866.001 May 2024 57,479.401−$9.39
long14 May 2024 62,940.1020 May 2024 66,274.006$4.40
long21 May 2024 71,446.6027 May 2024 68,507.706−$3.69
long9 Jul 2024 56,714.6015 Jul 2024 60,797.906$6.04
long16 Jul 2024 64,724.1022 Jul 2024 68,165.406$4.77
long13 Aug 2024 59,346.6019 Aug 2024 58,427.306−$1.54
long20 Aug 2024 59,438.5026 Aug 2024 64,220.006$7.50
long3 Sep 2024 59,132.106 Sep 2024 53,218.903−$10.20
long10 Sep 2024 57,042.0016 Sep 2024 59,132.006$3.29
long15 Oct 2024 66,084.0021 Oct 2024 69,032.006$4.16
long29 Oct 2024 69,962.204 Nov 2024 68,776.006−$1.73
long12 Nov 2024 88,648.0018 Nov 2024 89,856.006$1.26
long17 Dec 2024 106,059.0020 Dec 2024 95,452.803−$9.88
long7 Jan 2025 102,236.009 Jan 2025 92,012.002−$8.89
long4 Feb 2025 101,329.0010 Feb 2025 96,462.806−$3.86
long11 Feb 2025 97,430.8017 Feb 2025 96,118.106−$1.06
long18 Mar 2025 84,010.0024 Mar 2025 86,082.506$1.79
long25 Mar 2025 87,498.2031 Mar 2025 82,390.006−$4.50
long22 Apr 2025 87,516.2028 Apr 2025 93,749.306$5.07
long29 Apr 2025 95,011.205 May 2025 94,277.606−$0.64
long6 May 2025 94,733.7012 May 2025 104,118.006$7.51
long10 Jun 2025 110,263.0016 Jun 2025 105,594.006−$3.60
long24 Jun 2025 105,334.0030 Jun 2025 108,357.006$2.25
long5 Aug 2025 115,055.0011 Aug 2025 119,294.006$2.99
long2 Sep 2025 109,237.008 Sep 2025 111,137.006$1.43
long9 Sep 2025 112,065.0015 Sep 2025 115,268.006$2.43
long30 Sep 2025 114,312.006 Oct 2025 123,482.006$7.11
long7 Oct 2025 124,659.0010 Oct 2025 112,193.003−$9.69
long21 Oct 2025 110,532.0027 Oct 2025 114,559.006$3.11
long11 Nov 2025 106,011.0014 Nov 2025 95,410.003−$9.03
long25 Nov 2025 88,300.001 Dec 2025 90,360.006$1.84
long6 Jan 2026 93,859.7012 Jan 2026 91,013.706−$2.55
long27 Jan 2026 88,347.1031 Jan 2026 79,512.404−$8.05
long3 Feb 2026 78,738.605 Feb 2026 70,864.702−$7.24
long3 Mar 2026 68,830.109 Mar 2026 65,971.206−$2.73
long10 Mar 2026 68,432.2016 Mar 2026 72,815.306$3.94
long17 Mar 2026 74,884.7022 Mar 2026 67,396.205−$6.63
long24 Mar 2026 70,906.4030 Mar 2026 66,010.906−$4.13
long14 Apr 2026 74,418.0020 Apr 2026 73,801.806−$0.49
long21 Apr 2026 75,841.0027 Apr 2026 78,657.606$2.00
long5 May 2026 79,861.0011 May 2026 82,210.106$1.63
long16 Jun 2026 66,328.7022 Jun 2026 63,312.006−$2.69
long30 Jun 2026 60,260.206 Jul 2026 63,650.006$3.10
long18 Aug 2026 64,532.1024 Aug 2026 77,734.006$11.98
long25 Aug 2026 78,992.8031 Aug 2026 77,682.006−$1.22
long1 Sep 2026 78,581.307 Sep 2026 80,341.806$1.52
long15 Sep 2026 78,189.2021 Sep 2026 81,178.006$2.67
long22 Sep 2026 86,620.0028 Sep 2026 84,472.006−$1.87

Similar scripts

No other indicator or strategy here shares enough of its calculations.

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.

  • 2 strategy calls use the when = argument (line 10, 12). 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 56 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 10: when = long and dayofweek==dayofweek.monday → if block
  • Line 12: when = dayofweek==dayofweek.sunday → if block
⋯longTake = strategy.position_avg_price * (1 + takePer)-strategy.entry("long",strategy.long,when=long and dayofweek==dayofweek.monday)+if long and dayofweek==dayofweek.monday+    strategy.entry("long",strategy.long)strategy.exit('LONG EXIT', "long", limit=longTake, stop=longStop)-strategy.close_all(when=dayofweek==dayofweek.sunday)+if dayofweek==dayofweek.sunday+    strategy.close_all()

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

⋯// © exlux99-//@version=5+//@version=6strategy('VWAP strategy ', overlay=true, initial_capital=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true, commission_type=strategy.commission.percent, commission_value=0.03)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 7 msYes 1,000 bars in 24 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

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/// © exlux99//@version=5strategy('VWAP strategy ', overlay=true, initial_capital=100, default_qty_type=strategy.percent_of_equity, default_qty_value=100, calc_on_every_tick=true, commission_type=strategy.commission.percent, commission_value=0.03)long = close> ta.vwap and close[1] < ta.vwapstopPer = input.float(10.0, title='LONG Stop Loss % ', group='Fixed Risk Management') / 100takePer = input.float(29.0, title='LONG Take Profit %', group='Fixed Risk Management') / 100longStop = strategy.position_avg_price * (1 - stopPer)longTake = strategy.position_avg_price * (1 + takePer)strategy.entry("long",strategy.long,when=long and dayofweek==dayofweek.monday)strategy.exit('LONG EXIT', "long", limit=longTake, stop=longStop)strategy.close_all(when=dayofweek==dayofweek.sunday)