Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Full Swing Gold Vwap Macd SMO Strategy

A Pine Script v4 strategy built on EMA (close, 12) and TSI (close, 6). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 10000% of equity and pays 0.005% commission. 12 settings; defaults include Source low, Fast Length 12 and Slow Length 26.

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 Full Swing Gold Vwap Macd SMO Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Full Swing Gold Vwap Macd SMO Strategy do on BTCUSDT 1D with default settings?
−2,062.45%
From 26 Jan 2024 to 21 Oct 2026, over 2 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Full Swing Gold Vwap Macd SMO Strategy 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 Full Swing Gold Vwap Macd SMO Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 39, 40.
Does Full Swing Gold Vwap Macd SMO Strategy run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 48 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • EMA
  • EMA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (12)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOctTSI$-1,962,450$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 37, 38) so the engine trades the way the script says.
Net profit
−2,062.45%
−$2,062,450.00
Buy and hold
+102.5%
same period
Closed trades
2
1 won · 1 lost
Profitable
50.0%
of closed trades
Profit factor
0.30
gross profit ÷ gross loss
Max drawdown
300.97%
−$2,938,940.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

    Every trade uses all the equity

    default_qty_value is 10000% of equity.

  • Note

    1 setting has no label

    In the settings dialog source (line 5) shows an empty name. The labels on this page come from the variable names.

  • 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 37, 38. The upgraded version below moves each call inside an if block.

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, tsi → ta.tsi.
  • 2 strategy calls use the when = argument (line 37, 38). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

Trades differ: 2 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 3: //@version=4 → //@version=5
  • Line 15: input(type = input.integer) → input.int()
  • Line 16: input(type = input.integer) → input.int()
  • Line 17: input(type = input.source) → input.source()
  • Line 18: input(type = input.integer) → input.int()
  • Line 19: ema → ta.ema
6 more edits
  • Line 20: ema → ta.ema
  • Line 22: ema → ta.ema
  • Line 28: tsi → ta.tsi
  • Line 29: ema → ta.ema
  • Line 37: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
  • Line 38: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
⋯// © exlux99-//@version=4+//@version=5strategy("VWAP Gold strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10000, calc_on_every_tick = true, commission_type = strategy.commission.percent, commission_value = 0.005)⋯//macd-fast_length = input(title="Fast Length", type=input.integer, defval=12)+fast_length = input.int(title="Fast Length", defval=12)-slow_length = input(title="Slow Length", type=input.integer, defval=26)+slow_length = input.int(title="Slow Length", defval=26)-src = input(title="Source", type=input.source, defval=close)+src = input.source(title="Source", defval=close)-signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)+signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)-fast_ma = ema(src, fast_length)+fast_ma = ta.ema(src, fast_length)-slow_ma = ema(src, slow_length)+slow_ma = ta.ema(src, slow_length)macd = fast_ma - slow_ma-signal =  ema(macd, signal_length)+signal =  ta.ema(macd, signal_length)hist = macd - signal⋯siglen = input(5, minval=1, title="Signal Line Length SMO")-erg = tsi(close, shortlen, longlen)+erg = ta.tsi(close, shortlen, longlen)-sig = ema(erg, siglen)+sig = ta.ema(erg, siglen)osc = erg - sig⋯slshort=input(0.025, step=0.005, title="Stop loss % for short")-strategy.entry("long",1,when=longCondition)+strategy.entry("long",strategy.long,when=longCondition)-strategy.entry("short",0,when=shortCondition)+strategy.entry("short",strategy.short,when=shortCondition)strategy.exit("short_tp/sl", "long", profit=close * tplong / syminfo.mintick, loss=close * sllong / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')⋯

Clean v5

Verified

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

  • Line 5: input() → input.source()
  • Line 25: input() → input.int()
  • Line 26: input() → input.int()
  • Line 27: input() → input.int()
  • Line 33: input() → input.float()
  • Line 34: input() → input.float()
4 more edits
  • Line 35: input() → input.float()
  • Line 36: input() → input.float()
  • Line 37: when = longCondition → if block
  • Line 38: when = shortCondition → if block
⋯strategy("VWAP Gold strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10000, calc_on_every_tick = true, commission_type = strategy.commission.percent, commission_value = 0.005)-source = input(low)+source = input.source(low)//vwap monthly⋯//SMO-longlen = input(22, minval=1, title="Long Length SMO")+longlen = input.int(22, minval=1, title="Long Length SMO")-shortlen = input(6, minval=1, title="Short Length SMO")+shortlen = input.int(6, minval=1, title="Short Length SMO")-siglen = input(5, minval=1, title="Signal Line Length SMO")+siglen = input.int(5, minval=1, title="Signal Line Length SMO")erg = ta.tsi(close, shortlen, longlen)⋯longCondition =  close > vwapMonthly and hist> hist[1] and osc > 0-tplong=input(0.085, step=0.005, title="Take profit % for long")+tplong=input.float(0.085, step=0.005, title="Take profit % for long")-sllong=input(0.03, step=0.005, title="Stop loss % for long")+sllong=input.float(0.03, step=0.005, title="Stop loss % for long")-tpshort=input(0.05, step=0.005, title="Take profit % for short")+tpshort=input.float(0.05, step=0.005, title="Take profit % for short")-slshort=input(0.025, step=0.005, title="Stop loss % for short")+slshort=input.float(0.025, step=0.005, title="Stop loss % for short")-strategy.entry("long",strategy.long,when=longCondition)+if longCondition+    strategy.entry("long",strategy.long)-strategy.entry("short",strategy.short,when=shortCondition)+if shortCondition+    strategy.entry("short",strategy.short)strategy.exit("short_tp/sl", "long", profit=close * tplong / syminfo.mintick, loss=close * sllong / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')⋯

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

⋯// © exlux99-//@version=5+//@version=6strategy("VWAP Gold strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10000, calc_on_every_tick = true, commission_type = strategy.commission.percent, commission_value = 0.005)⋯

Settings

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

SettingDefaultType and rangeFeeds
Source (no label in the script)lowsourcesumsourceM
Fast Length12int (written input.integer)fast_ma
Slow Length26int (written input.integer)slow_ma
Sourceclosesourcefast_ma slow_ma
Signal Smoothing9int (written input.integer) · min 1 · max 50signal
Long Length SMO22int · min 1erg
Short Length SMO6int · min 1erg
Signal Line Length SMO5int · min 1sig
Take profit % for long0.085float · step 0.005exit short_tp/sl
Stop loss % for long0.03float · step 0.005exit short_tp/sl
Take profit % for short0.05float · step 0.005exit short_tp/sl
Stop loss % for short0.025float · step 0.005exit short_tp/sl

What it calculates

  • EMA (ema, ta.ema in v5)Source (close), Fast Length (12)fast_ma · line 19
  • EMA (ema, ta.ema in v5)Source (close), Slow Length (26)slow_ma · line 20
  • EMA (ema, ta.ema in v5)macd, Signal Smoothing (9)signal · line 22
  • TSI (tsi, ta.tsi in v5)close, Short Length SMO (6), Long Length SMO (22)erg · line 28
  • EMA (ema, ta.ema in v5)erg, Signal Line Length SMO (5)sig · line 29

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 datafast_lengthFast Lengthsetting · 12slow_lengthSlow Lengthsetting · 26signal_lengthSignal Smoothingsetting · 9shortlenShort Length SMOsetting · 6longlenLong Length SMOsetting · 22siglenSignal Line Length SMOsetting · 5volumevolumeprice datalowlowprice datafast_maEMA→ fast_maslow_maEMA→ slow_masignalEMA→ signalergTSI→ ergsigEMA→ sigsumsourceMsumsourceMvaluesumVolMsumVolMvaluevwapMonthlyvwapMonthlyvaluemacdmacdvaluehisthistvalueoscoscvalueshortConditionshortConditionconditionlongConditionlongConditionconditionbeginningMbeginningMconditionentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryexit:short_tp/slexit short_tp/slstrategy.exit

Order rules

OrderFires whenBy defaultLine
Open long longlongConditionclose > vwapMonthly and hist> hist[1] and osc > 0On37
Open short shortshortConditionclose < vwapMonthly and hist < hist[1] and osc < 0On38
Exit short_tp/sl stop and limitevery barOn39
Exit short_tp/sl stop and limitevery barOn40

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 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−2,062.4%+102.5%250%0.30301.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−298.5%+5.5%10%0.00298.5%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−2,082.8%+9.8%250%0.30301.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−295.6%+8.4%10%0.00295.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2,028.1%+16.7%250%0.30303.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−298.3%+21.5%10%0.00298.3%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−2,057.1%+148.3%250%0.30301.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−294.5%+17.1%10%0.00294.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 market250%−$2,062,450.00
Sideways market0—$0.00
Falling market0—$0.00

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

How bad could the drawdown be?

2,062.4%

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

0%2,372%
All 2 trades
SideEntryExitBarsP&L
long1 Mar 2024 61,131.004 Mar 2024 66,495.703$876,485.00
long5 Mar 2024 68,245.705 Mar 2024 66,198.300−$2,938,940.00

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
Full Swing Gold Vwap Macd SMO Strategy this page—v4 strategy−2,062.4%2301.0%
SMIO strat by Nico_TMtsi emav4 strategy+49.1%4528.1%
True Strength Index by Zeal Terminaltsi emav5 indicatorindicator
Risk Reduction Ultimate Template by burgercrisistsi emav4 strategyNo trades on this market

Where it runs

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

Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 37, 38) 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/// © exlux99//@version=4strategy("VWAP Gold strategy", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 10000, calc_on_every_tick = true, commission_type = strategy.commission.percent, commission_value = 0.005)source = input(low)//vwap monthlytimeframeM = time("M")beginningM = na(timeframeM[1]) or timeframeM > timeframeM[1]sumsourceM = source * volumesumVolM = volumesumsourceM := beginningM ? sumsourceM : sumsourceM + sumsourceM[1]sumVolM := beginningM ? sumVolM : sumVolM + sumVolM[1]vwapMonthly= sumsourceM / sumVolM//macdfast_length = input(title="Fast Length", type=input.integer, defval=12)slow_length = input(title="Slow Length", type=input.integer, defval=26)src = input(title="Source", type=input.source, defval=close)signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)fast_ma = ema(src, fast_length)slow_ma = ema(src, slow_length)macd = fast_ma - slow_masignal =  ema(macd, signal_length)hist = macd - signal//SMOlonglen = input(22, minval=1, title="Long Length SMO")shortlen = input(6, minval=1, title="Short Length SMO")siglen = input(5, minval=1, title="Signal Line Length SMO")erg = tsi(close, shortlen, longlen)sig = ema(erg, siglen)osc = erg - sigshortCondition =  close < vwapMonthly and hist < hist[1] and osc < 0longCondition =  close > vwapMonthly and hist> hist[1] and osc > 0tplong=input(0.085, step=0.005, title="Take profit % for long")sllong=input(0.03, step=0.005, title="Stop loss % for long")tpshort=input(0.05, step=0.005, title="Take profit % for short")slshort=input(0.025, step=0.005, title="Stop loss % for short")strategy.entry("long",1,when=longCondition)strategy.entry("short",0,when=shortCondition)strategy.exit("short_tp/sl", "long", profit=close * tplong / syminfo.mintick, loss=close * sllong / syminfo.mintick, comment='LONG EXIT',  alert_message = 'closeshort')strategy.exit("short_tp/sl", "short", profit=close * tpshort / syminfo.mintick, loss=close * slshort / syminfo.mintick, comment='SHORT EXIT',  alert_message = 'closeshort')