Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

dEMA w- VWAP filter

A Pine Script v4 strategy built on EMA (close, 34). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 1 in cash and pays no commission. 1 setting; defaults include EMA Length 34.

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 dEMA w- VWAP filter repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 10 of 10 trades.
How did dEMA w- VWAP filter do on BTCUSDT 1D with default settings?
+9,246.98%
From 26 Jan 2024 to 21 Oct 2026, over 31 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can dEMA w- VWAP filter be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does dEMA w- VWAP filter use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does dEMA w- VWAP filter run in Zeal Terminal?
Yes
It compiles in 8 ms and runs 1,000 bars in 25 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • 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 (1)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$49,502$1,013Equity from $500
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 true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 9) so the engine trades the way the script says.
Net profit
+9,246.98%
$46,234.90
Buy and hold
+102.5%
same period
Closed trades
31
10 won · 21 lost
Profitable
32.3%
of closed trades
Profit factor
2.07
gross profit ÷ gross loss
Max drawdown
425.20%
−$20,213.30

One run with the author's default settings, $500 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

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, change → ta.change, crossunder → ta.crossunder.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 6: ema → ta.ema
  • Line 7: change → ta.change
  • Line 7: vwap → ta.vwap
  • Line 9: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 10: change → ta.change
5 more edits
  • Line 10: vwap → ta.vwap
  • Line 10: crossunder → ta.crossunder
  • Line 10: vwap → ta.vwap
  • Line 10: change → ta.change
  • Line 13: vwap → ta.vwap
⋯// © shiner_trading-//@version=4+//@version=5strategy("dEMA w/ VWAP filter", overlay=true, default_qty_type=strategy.cash, initial_capital=500)len = input(34, "EMA Length")-ma = ema(close, len)+ma = ta.ema(close, len)-longCondition = change(ma) > 0 and ma < vwap+longCondition = ta.change(ma) > 0 and ma < ta.vwapif (longCondition)-    strategy.entry("Buy", true, 1)+    strategy.entry("Buy", strategy.long, 1)-shortCondition = (change(ma) < 0 and close > vwap) or (crossunder(ma, vwap) and change(ma) > 0)+shortCondition = (ta.change(ma) < 0 and close > ta.vwap) or (ta.crossunder(ma, ta.vwap) and ta.change(ma) > 0)if (shortCondition)    strategy.close("Buy")-plot (vwap, color=color.fuchsia)+plot (ta.vwap, color=color.fuchsia)plot (ma)

Clean v5

VerifiedDownload the v5 script

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

  • Line 5: input() → input.int()
⋯strategy("dEMA w/ VWAP filter", overlay=true, default_qty_type=strategy.cash, initial_capital=500)-len = input(34, "EMA Length")+len = input.int(34, "EMA Length")ma = ta.ema(close, len)⋯

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

⋯// © shiner_trading-//@version=5+//@version=6strategy("dEMA w/ VWAP filter", overlay=true, default_qty_type=strategy.cash, initial_capital=500)⋯

Settings

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

SettingDefaultType and rangeFeeds
EMA Length34intma

What it calculates

  • EMA (ema, ta.ema in v5)close, EMA Length (34)ma · line 6

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 datalenEMA Lengthsetting · 34maEMA→ malongConditionlongConditionconditionshortConditionshortConditionconditionentry:BuyOpen Buystrategy.entryclose:BuyClose Buystrategy.closeplot:13plotplotplot:14plotplot

Order rules

OrderFires whenBy defaultLine
Open Buy long(longCondition)On9
Close Buy(shortCondition)On12

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, and the live replay matched history.

10/10trades 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. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+9,247.0%+102.5%3132%2.07425.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+765.6%+5.5%2442%1.181,496.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+254.4%+9.8%2832%1.40150.3%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+49.8%+8.4%2829%1.3239.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+1.5%+16.7%3234%1.0419.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+5.1%+21.5%2236%1.973.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+66.1%+148.3%3441%1.5631.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+12.2%+17.1%2540%1.4017.1%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market933%$5,170.45
Sideways market1533%$43,051.40
Falling market729%−$1,986.90

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

How bad could the drawdown be?

7,365.4%

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

0%8,470%
All 31 trades
SideEntryExitBarsP&L
long1 Mar 2024 61,131.0015 Apr 2024 65,661.9045$4,530.86
long23 Apr 2024 66,819.3026 Apr 2024 64,498.303−$2,320.99
long16 May 2024 66,206.5013 Jun 2024 68,264.0028$2,057.47
long16 Jul 2024 64,724.106 Aug 2024 54,018.8021−$10,705.20
long24 Aug 2024 64,037.2031 Aug 2024 59,124.007−$4,913.25
long14 Sep 2024 60,498.0018 Sep 2024 60,314.004−$184.00
long19 Sep 2024 61,760.004 Oct 2024 60,752.7015−$1,007.26
long5 Oct 2024 62,086.0011 Oct 2024 60,326.406−$1,759.60
long12 Oct 2024 62,540.0024 Dec 2024 94,881.5073$32,341.50
long25 Dec 2024 98,663.6029 Dec 2024 95,300.004−$3,363.58
long3 Jan 2025 96,984.809 Jan 2025 95,060.606−$1,924.18
long15 Jan 2025 96,560.909 Feb 2025 96,444.8025−$116.10
long26 Mar 2025 87,392.9028 Mar 2025 87,232.002−$160.87
long13 Apr 2025 85,276.907 Jun 2025 104,288.0055$19,011.50
long8 Jun 2025 105,552.0020 Jun 2025 104,659.0012−$893.56
long25 Jun 2025 106,083.004 Aug 2025 114,209.0040$8,125.81
long5 Aug 2025 115,055.006 Aug 2025 114,130.001−$925.28
long8 Aug 2025 117,472.0019 Aug 2025 116,227.0011−$1,244.97
long11 Sep 2025 113,960.0025 Sep 2025 113,307.0014−$652.99
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$1,537.48
long27 Oct 2025 114,559.002 Nov 2025 110,098.006−$4,461.31
long3 Jan 2026 89,995.1022 Jan 2026 89,454.7019−$540.41
long14 Mar 2026 70,930.0021 Mar 2026 70,510.707−$419.28
long26 Mar 2026 71,336.501 Apr 2026 68,284.506−$3,052.04
long8 Apr 2026 71,924.2019 May 2026 77,001.9041$5,077.66
long11 Jul 2026 64,161.7015 Jul 2026 65,044.004$882.27
long16 Jul 2026 64,756.3019 Jul 2026 64,834.203$77.93
long20 Jul 2026 64,722.6027 Jul 2026 65,400.007$677.45
long31 Jul 2026 64,780.002 Aug 2026 62,823.702−$1,956.38
long6 Aug 2026 64,665.2014 Aug 2026 63,490.908−$1,174.38
long19 Aug 2026 64,725.4018 Oct 2026 81,491.0060$16,765.60

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
dEMA w- VWAP filter this page—v4 strategy+9,247.0%31425.2%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 9) 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/// © shiner_trading//@version=4strategy("dEMA w/ VWAP filter", overlay=true, default_qty_type=strategy.cash, initial_capital=500)len = input(34, "EMA Length")ma = ema(close, len)longCondition = change(ma) > 0 and ma < vwapif (longCondition)    strategy.entry("Buy", true, 1)shortCondition = (change(ma) < 0 and close > vwap) or (crossunder(ma, vwap) and change(ma) > 0)if (shortCondition)    strategy.close("Buy")plot (vwap, color=color.fuchsia)plot (ma)