Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

4X EMA and volume strategy

A Pine Script v4 strategy built on EMA (close, 13) and SMA or Change (14). It has 4 order rules, 2 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.1% commission. 8 settings; defaults include Ema1l 13, Ema2l 21 and Ema3l 50.

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 4X EMA and volume strategy repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did 4X EMA and volume strategy do on BTCUSDT 1D with default settings?
+1.81%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can 4X EMA and volume strategy 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 4X EMA and volume strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does 4X EMA and volume strategy run in Zeal Terminal?
Yes
It compiles in 14 ms and runs 1,000 bars in 32 ms, in the browser.

BTCUSDT · 1D · default settings

  • EMA
  • EMA
  • EMA
  • EMA
  • SMA
  • 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 (8)
0.00100,000200,000AprJulOct2025AprJulOct2026AprJulOct$1,090$2,025Equity from $1,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 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 25, 29) so the engine trades the way the script says.
Net profit
+1.81%
$18.06
Buy and hold
+102.5%
same period
Closed trades
3
2 won · 1 lost
Profitable
66.7%
of closed trades
Profit factor
1.14
gross profit ÷ gross loss
Max drawdown
25.76%
−$257.60

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

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    7 settings have no label

    In the settings dialog ema1l (line 6), ema2l (line 7), ema3l (line 8), ema4l (line 9), length (line 19), option1 (line 22), option2 (line 23) show 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 25, 26, 29, 30. 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, crossover → ta.crossover, crossunder → ta.crossunder, sma → ta.sma, change → ta.change.
  • 4 strategy calls use the when = argument (line 25, 26, 29, 30). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 10: ema → ta.ema
  • Line 11: ema → ta.ema
  • Line 12: ema → ta.ema
  • Line 13: ema → ta.ema
  • Line 15: crossover → ta.crossover
7 more edits
  • Line 15: crossover → ta.crossover
  • Line 17: crossunder → ta.crossunder
  • Line 17: crossunder → ta.crossunder
  • Line 21: sma → ta.sma
  • Line 21: change → ta.change
  • Line 25: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
  • Line 29: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
⋯// © SoftKill21-//@version=4+//@version=5strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯ema4l=input(180)-ema1=ema(close,ema1l)+ema1=ta.ema(close,ema1l)-ema2=ema(close,ema2l)+ema2=ta.ema(close,ema2l)-ema3=ema(close,ema3l)+ema3=ta.ema(close,ema3l)-ema4=ema(close,ema4l)+ema4=ta.ema(close,ema4l)long1 = close > ema1 and ema1 > ema2 and ema2> ema3 and ema3 > ema4-long2 = crossover(ema1,ema2) and crossover(ema1,ema3)+long2 = ta.crossover(ema1,ema2) and ta.crossover(ema1,ema3)short1 = close < ema1 and ema1 < ema2 and ema2< ema3 and ema3 < ema4-short2= crossunder(ema1,ema2) and crossunder(ema1,ema3)+short2= ta.crossunder(ema1,ema2) and ta.crossunder(ema1,ema3)//eom⋯div = input(10000, title="Divisor", minval=1)-eom = sma(div * change(hl2) * (high - low) / volume, length)+eom = ta.sma(div * ta.change(hl2) * (high - low) / volume, length)option1=input(true)⋯if(option1)-    strategy.entry("long",1,when=long1 and eom>0)+    strategy.entry("long",strategy.long,when=long1 and eom>0)    strategy.close("long",when=short1 and eom<0)⋯if(option2)-    strategy.entry("long",1,when=long2 and eom>0)+    strategy.entry("long",strategy.long,when=long2 and eom>0)    strategy.close("long",when=short2 and eom<0)

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 19: input() → input.int()
  • Line 20: input() → input.int()
6 more edits
  • Line 22: input() → input.bool()
  • Line 23: input() → input.bool()
  • Line 25: when = long1 and eom>0 → if block
  • Line 26: when = short1 and eom<0 → if block
  • Line 29: when = long2 and eom>0 → if block
  • Line 30: when = short2 and eom<0 → if block
⋯//ema x 4-ema1l=input(13)+ema1l=input.int(13)-ema2l=input(21)+ema2l=input.int(21)-ema3l=input(50)+ema3l=input.int(50)-ema4l=input(180)+ema4l=input.int(180)ema1=ta.ema(close,ema1l)⋯//eom-length = input(14, minval=1)+length = input.int(14, minval=1)-div = input(10000, title="Divisor", minval=1)+div = input.int(10000, title="Divisor", minval=1)eom = ta.sma(div * ta.change(hl2) * (high - low) / volume, length)-option1=input(true)+option1=input.bool(true)-option2=input(false)+option2=input.bool(false)if(option1)-    strategy.entry("long",strategy.long,when=long1 and eom>0)+    if long1 and eom>0+        strategy.entry("long",strategy.long)-    strategy.close("long",when=short1 and eom<0)+    if short1 and eom<0+        strategy.close("long") if(option2)-    strategy.entry("long",strategy.long,when=long2 and eom>0)+    if long2 and eom>0+        strategy.entry("long",strategy.long)-    strategy.close("long",when=short2 and eom<0)+    if short2 and eom<0+        strategy.close("long")

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

⋯// © SoftKill21-//@version=5+//@version=6strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )⋯

Settings

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

SettingDefaultType and rangeFeeds
Ema1l (no label in the script)13intema1
Ema2l (no label in the script)21intema2
Ema3l (no label in the script)50intema3
Ema4l (no label in the script)180intema4
Length (no label in the script)14int · min 1eom
Divisor10000int · min 1eom
Option1 (no label in the script)trueboolentry long close long line 24
Option2 (no label in the script)falseboolentry long close long line 28

What it calculates

  • EMA (ema, ta.ema in v5)close, Ema1l (13)ema1 · line 10
  • EMA (ema, ta.ema in v5)close, Ema2l (21)ema2 · line 11
  • EMA (ema, ta.ema in v5)close, Ema3l (50)ema3 · line 12
  • EMA (ema, ta.ema in v5)close, Ema4l (180)ema4 · line 13
  • SMA / Change (sma, ta.sma in v5)div * change(hl2) * (high - low) / volume, Length (14)eom · line 21

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 dataema1lEma1lsetting · 13ema2lEma2lsetting · 21ema3lEma3lsetting · 50ema4lEma4lsetting · 180volumevolumeprice datalowlowprice datahighhighprice datahl2hl2price datadivDivisorsetting · 10000lengthLengthsetting · 14ema1EMA→ ema1ema2EMA→ ema2ema3EMA→ ema3ema4EMA→ ema4eomSMA / Change→ eomlong1, short1long1 · short12 conditionslong2, short2long2 · short22 conditionsentry:longOpen longstrategy.entryclose:longClose longstrategy.close

Order rules

OrderFires whenBy defaultLine
Open long longlong1 and eom>0On25
Close longshort1 and eom<0On26
Open long longlong2 and eom>0On29
Close longshort2 and eom<0On30

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.

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].
  • 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+1.8%+102.5%367%1.1425.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+12.2%+5.5%333%3.246.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−18.2%+9.8%250%0.2337.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+36.2%+8.4%1100%—2.5%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−53.7%+16.7%30%0.0057.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+28.8%+21.5%250%4.4011.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+12.3%+148.3%250%4.6312.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+24.2%+17.1%1100%—2.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 market0—$0.00
Sideways market367%$19.08
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?

12.9%

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

0%15%
All 3 trades
SideEntryExitBarsP&L
long24 Jul 2024 65,936.0016 Aug 2024 57,541.1023−$129.06
long15 Oct 2024 66,084.009 Apr 2025 76,322.40176$132.93
long25 Apr 2025 93,980.5016 Nov 2025 95,596.20205$15.22

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
4X EMA and volume strategy this page—v4 strategy+1.8%325.8%
MACD Long Strat by TheGrindTodayema smav4 strategy+24.0%7920.1%
Stock trending strategy by exlux99ema smav4 strategy+35.3%2114.7%
4-Hour Stochastic EMA Trend by slymnturkogluema smav4 strategyNo trades on this market
Simple Momentum Strategy Based on SMA, EMA and Volume by slip_streamsma emav4 strategy+7.4%1827.4%
BTC WaveTrend R-R=1-1.5 by TrendCrypto2022ema smav5 strategy+0.2%282.7%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as 1 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 25, 29) 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/// © SoftKill21//@version=4strategy("4x ema + volume", overlay=true,initial_capital = 1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent , commission_value=0.1 )//ema x 4ema1l=input(13)ema2l=input(21)ema3l=input(50)ema4l=input(180)ema1=ema(close,ema1l)ema2=ema(close,ema2l)ema3=ema(close,ema3l)ema4=ema(close,ema4l)long1 = close > ema1 and ema1 > ema2 and ema2> ema3 and ema3 > ema4long2 = crossover(ema1,ema2) and crossover(ema1,ema3)short1 = close < ema1 and ema1 < ema2 and ema2< ema3 and ema3 < ema4short2= crossunder(ema1,ema2) and crossunder(ema1,ema3)//eomlength = input(14, minval=1)div = input(10000, title="Divisor", minval=1)eom = sma(div * change(hl2) * (high - low) / volume, length)option1=input(true)option2=input(false)if(option1)    strategy.entry("long",1,when=long1 and eom>0)    strategy.close("long",when=short1 and eom<0) if(option2)    strategy.entry("long",1,when=long2 and eom>0)    strategy.close("long",when=short2 and eom<0)