Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

[Strategy] - EMA 10,20 59 with Profit Displayed

A Pine Script v4 strategy built on EMA (close, 10) and Barssince (Buytrend). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss. Each trade is 1000 contracts and pays no commission. 8 settings; defaults include infoBoxSize size.large, Ema1Value 10 and Ema2Value 20.

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 [Strategy] - EMA 10,20 59 with Profit Displayed repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 108 of 108 trades.
Can [Strategy] - EMA 10,20 59 with Profit Displayed be converted to Pine Script v5?
No
The automatic step from v4 to v5 gives a script that does not run in v5 (Pine Script v5 Error at @L50:C235: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version), so no v5 download is offered; the edits are shown below.
Does [Strategy] - EMA 10,20 59 with Profit Displayed use a stop loss?
Yes
strategy.exit sets a stop on line 70, 77.
Does [Strategy] - EMA 10,20 59 with Profit Displayed run in Zeal Terminal?
Yes
It compiles in 50 ms and runs 1,000 bars in 83 ms, in the browser.

BTCUSDT · 1D · default settings

  • ema1
  • ema2
  • ema3
  • 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)
Close = 61577.49Close = 65235.21Close = 60293.3Close = 65376Close = 54018.81Close = 64262.7Close = 96258Close = 94628Close = 108816.33Close = 115349.71Close = 109643.46Close = 120529.35Close = 106431.68Close = 75691.76Close = 71408.9Close = 78338.03buyProfit in pip = -109640,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$-5,779,770$506Equity from $250
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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep. Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 69, 76) so the engine trades the way the script says.
Net profit
−2,311,450.00%
−$5,778,620.00
Buy and hold
+102.5%
same period
Closed trades
793
1 won · 792 lost
Profitable
0.1%
of closed trades
Profit factor
0.76
gross profit ÷ gross loss
Max drawdown
8,424,000.00%
−$21,060,000.00

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

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

  • Note

    4 settings have no label

    In the settings dialog ema1Value (line 10), ema2Value (line 11), ema3Value (line 12), maxLoss (line 13) 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 transp =, which v5 removed line 27

    transp = on line 27, 31, 32, 37, 38. v5 folds the transparency into the colour with color.new(c, transp).

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, tostring → str.tostring, barssince → ta.barssince, crossunder → ta.crossunder, crossover → ta.crossover.

v4 → v5

Differs

The v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L50:C235: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.

  • Line 3: //@version=4 → //@version=5
  • Line 6: input(type = input.bool) → input.bool()
  • Line 7: input(type = input.bool) → input.bool()
  • Line 8: input(type = input.bool) → input.bool()
  • Line 14: ema → ta.ema
  • Line 15: ema → ta.ema
32 more edits
  • Line 16: ema → ta.ema
  • Line 18: tostring → str.tostring
  • Line 24: barssince → ta.barssince
  • Line 25: barssince → ta.barssince
  • Line 27: transp = 70 → color.new(Buytrend ? color.green : color.red, 70)
  • Line 29: crossunder → ta.crossunder
  • Line 30: barssince → ta.barssince
  • Line 31: transp = 30 → color.new(BuySignal ? color.green : na, 30)
  • Line 32: transp = 30 → color.new(BuySignalOut ? color.black : na, 30)
  • Line 35: crossover → ta.crossover
  • Line 36: barssince → ta.barssince
  • Line 37: transp = 30 → color.new(SellSignal ? color.red : na, 30)
  • Line 38: transp = 30 → color.new(SellSignalOut ? color.black : na, 30)
  • Line 50: tostring → str.tostring
  • Line 50: tostring → str.tostring
  • Line 50: tostring → str.tostring
  • Line 52: tostring → str.tostring
  • Line 52: tostring → str.tostring
  • Line 52: tostring → str.tostring
  • Line 55: tostring → str.tostring
  • Line 55: tostring → str.tostring
  • Line 55: tostring → str.tostring
  • Line 58: tostring → str.tostring
  • Line 58: tostring → str.tostring
  • Line 58: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 59: tostring → str.tostring
  • Line 69: strategy.entry(…, true) → strategy.entry(…, strategy.long)
  • Line 76: strategy.entry(…, false) → strategy.entry(…, strategy.short)
⋯// © mattehalen-//@version=4+//@version=5//study("EMA 10,20 59",overlay=true)strategy("EMA 10,20 59",overlay=true, process_orders_on_close = true, default_qty_type =  strategy.fixed, default_qty_value = 1000, initial_capital=250, currency=currency.USD)-infoBox     = input(true, title="infoBox", type=input.bool)+infoBox     = input.bool(true, title="infoBox")-infoBox2    = input(false, title="infoBox2", type=input.bool)+infoBox2    = input.bool(false, title="infoBox2")-BuySellSignal_Bool = input(false, title="Buy & SellSignal", type=input.bool)+BuySellSignal_Bool = input.bool(false, title="Buy & SellSignal")infoBoxSize = input(title="infoBoxSize", defval=size.large, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])⋯maxLoss = input(3000)-ema1        = ema(close,ema1Value)+ema1        = ta.ema(close,ema1Value)-ema2        = ema(close,ema2Value)+ema2        = ta.ema(close,ema2Value)-ema3        = ema(close,ema3Value)+ema3        = ta.ema(close,ema3Value)objcnt      = 0-buyTitle    = tostring(close[1])+buyTitle    = str.tostring(close[1])myProfit    = float(0)⋯Buytrend = (ema1 and ema2 > ema3) and (ema1[1] and ema2[1] > ema3[1])-BarssinceBuyTrend = barssince(Buytrend)+BarssinceBuyTrend = ta.barssince(Buytrend)-BarssinceSellTrend = barssince(not Buytrend)+BarssinceSellTrend = ta.barssince(not Buytrend)closeAtBuyTrend = close[1]-bgcolor(Buytrend ? color.green : color.red,transp=70)+bgcolor(color.new(Buytrend ? color.green : color.red, 70))BuySignal = Buytrend and not Buytrend[1] and BuySellSignal_Bool-BuySignalOut = Buytrend and (crossunder(ema1,ema2)) and BuySellSignal_Bool+BuySignalOut = Buytrend and (ta.crossunder(ema1,ema2)) and BuySellSignal_Bool-BarssinceBuy = barssince(BuySignal)+BarssinceBuy = ta.barssince(BuySignal)-bgcolor(BuySignal ? color.green : na , transp=30)+bgcolor(color.new(BuySignal ? color.green : na, 30) )-bgcolor(BuySignalOut ? color.black : na , transp=30)+bgcolor(color.new(BuySignalOut ? color.black : na, 30) )plot(BarssinceBuy,title="BarssinceBuy",display=display.none)SellSignal = not Buytrend and Buytrend[1] and BuySellSignal_Bool-SellSignalOut = not Buytrend and (crossover(ema1,ema2)) and BuySellSignal_Bool+SellSignalOut = not Buytrend and (ta.crossover(ema1,ema2)) and BuySellSignal_Bool-BarssinceSell = barssince(SellSignal)+BarssinceSell = ta.barssince(SellSignal)-bgcolor(SellSignal ? color.red : na , transp=30)+bgcolor(color.new(SellSignal ? color.red : na, 30) )-bgcolor(SellSignalOut ? color.black : na , transp=30)+bgcolor(color.new(SellSignalOut ? color.black : na, 30) )plot(BarssinceSell,title="BarssinceSell",display=display.none)⋯if (Buytrend and not Buytrend[1] and infoBox==true)-    l = label.new(bar_index - (BarssinceBuyTrend[1]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuyTrend[1]]) + "\n" + "Profit = "+tostring(close[BarssinceBuyTrend[1]]-close) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.red,size=infoBoxSize)+    l = label.new(bar_index - (BarssinceBuyTrend[1]/2), na,text="Close = " + str.tostring(close) + "\n" + "Start = "+str.tostring(close[BarssinceBuyTrend[1]]) + "\n" + "Profit = "+str.tostring(close[BarssinceBuyTrend[1]]-close) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.red,size=infoBoxSize)if (not Buytrend and Buytrend[1] and infoBox==true)-    l = label.new(bar_index - (BarssinceSellTrend[1]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSellTrend[1]]) + "\n" + "Profit = "+tostring(close-close[BarssinceSellTrend[1]]) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.green,size=infoBoxSize)+    l = label.new(bar_index - (BarssinceSellTrend[1]/2), na,text="Close = " + str.tostring(close) + "\n" + "Start = "+str.tostring(close[BarssinceSellTrend[1]]) + "\n" + "Profit = "+str.tostring(close-close[BarssinceSellTrend[1]]) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.green,size=infoBoxSize)if (BuySignalOut and not BuySignalOut[1] and infoBox2==true)//    l = label.new(bar_index - (BarssinceBuy[0]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuy[0]]) + "\n" + "Profit = "+tostring(close-close[BarssinceBuy[0]]) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.purple,size=infoBoxSize-    l = label.new(bar_index, na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuy[0]]) + "\n" + "Profit = "+tostring(close-close[BarssinceBuy[0]]) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.lime,size=infoBoxSize)+    l = label.new(bar_index, na,text="Close = " + str.tostring(close) + "\n" + "Start = "+str.tostring(close[BarssinceBuy[0]]) + "\n" + "Profit = "+str.tostring(close-close[BarssinceBuy[0]]) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.lime,size=infoBoxSize)if (SellSignalOut and not SellSignalOut[1] and infoBox2==true)//    l = label.new(bar_index - (BarssinceSell[0]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSell[0]]) + "\n" + "Profit = "+tostring(close[BarssinceSell[0]]-close) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.purple,size=infoBoxSize)-    l = label.new(bar_index, na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSell[0]]) + "\n" + "Profit = "+tostring(close[BarssinceSell[0]]-close) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.fuchsia,size=infoBoxSize)+    l = label.new(bar_index, na,text="Close = " + str.tostring(close) + "\n" + "Start = "+str.tostring(close[BarssinceSell[0]]) + "\n" + "Profit = "+str.tostring(close[BarssinceSell[0]]-close) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.fuchsia,size=infoBoxSize)-l2 = label.new(bar_index, na, 'buyProfit in pip = '+tostring(buyProfit)+"\n"+  'cntBuy = '+tostring(cntBuy) +"\n"+  'sellProfit in pip = '+tostring(sellProfit)+"\n"+  'cntSell = '+tostring(cntSell) +"\n"+  'totalProfit in pip = '+tostring(totalProfit)     , +l2 = label.new(bar_index, na, 'buyProfit in pip = '+str.tostring(buyProfit)+"\n"+  'cntBuy = '+str.tostring(cntBuy) +"\n"+  'sellProfit in pip = '+str.tostring(sellProfit)+"\n"+  'cntSell = '+str.tostring(cntSell) +"\n"+  'totalProfit in pip = '+str.tostring(totalProfit)     ,   color=totalProfit>0 ? color.green : color.red, ⋯    strategy.close("short", comment = "Exit short")-    strategy.entry("long", true)+    strategy.entry("long", strategy.long)    strategy.exit("Max Loss", "long", loss = maxLoss)⋯    strategy.close("long", comment = "Exit Long")-    strategy.entry("short", false)+    strategy.entry("short", strategy.short)    strategy.exit("Max Loss", "short", loss = maxLoss)⋯

Clean v5

Not verified

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L50:C235: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.), so this step could not be checked.

  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
⋯infoBoxSize = input(title="infoBoxSize", defval=size.large, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])-ema1Value   = input(10)+ema1Value   = input.int(10)-ema2Value   = input(20)+ema2Value   = input.int(20)-ema3Value   = input(59)+ema3Value   = input.int(59)-maxLoss = input(3000)+maxLoss = input.int(3000)ema1        = ta.ema(close,ema1Value)⋯

Does it run in Pine Script v6?

Not tested

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L50:C235: 'label.style_labelup' is not available in Pine Script v5. It was added in a later version.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © mattehalen-//@version=5+//@version=6//study("EMA 10,20 59",overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
infoBoxtrueboolline 49 line 51
infoBox2falseboolline 53 line 56
Buy & SellSignalfalseboolBuySignal BuySignalOut SellSignal SellSignalOut
infoBoxSizesize.largevalue · options [size.auto, size.tiny, size.small, size.normal, size.large, size.huge]l
Ema1Value (no label in the script)10intema1
Ema2Value (no label in the script)20intema2
Ema3Value (no label in the script)59intema3
Max Loss (no label in the script)3000intexit Max Loss

What it calculates

  • EMA (ema, ta.ema in v5)close, Ema1Value (10)ema1 · line 14
  • EMA (ema, ta.ema in v5)close, Ema2Value (20)ema2 · line 15
  • EMA (ema, ta.ema in v5)close, Ema3Value (59)ema3 · line 16
  • Barssince (barssince, ta.barssince in v5)BuytrendBarssinceBuyTrend · line 24
  • Barssince (barssince, ta.barssince in v5)BuySignalBarssinceBuy · line 30
  • Barssince (barssince, ta.barssince in v5)SellSignalBarssinceSell · line 36

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 dataema1ValueEma1Valuesetting · 10ema2ValueEma2Valuesetting · 20ema3ValueEma3Valuesetting · 59infoBoxSizeinfoBoxSizesetting · size.largeema1EMA→ ema1ema2EMA→ ema2ema3EMA→ ema3BarssinceBuyTrendBarssince→ BarssinceBuyTrendBarssinceBuyBarssince→ BarssinceBuyBarssinceSellBarssince→ BarssinceSellbuyTitle, closeAtBuyTrendbuyTitle · closeAtBuyTr…2 valuesbuyProfitbuyProfitvaluecntBuycntBuyvaluesellProfitsellProfitvaluecntSellcntSellvaluetotalProfittotalProfitvalueBuytrend, BarssinceSellTrendBuytrend · BarssinceSel…2 conditionsBuySignal, SellSignalBarssinceSellTrend · Bu…3 conditionsBuySignalOut, SellSignalOutBuySignalOut · SellSign…2 conditionsl, l2Colourl · l2close:shortClose shortstrategy.closeentry:longOpen longstrategy.entryexit:Max Lossexit Max Lossstrategy.exitclose:longClose longstrategy.closeentry:shortOpen shortstrategy.entryplot:20ema1plotplot:21ema2plotplot:22ema3plotbgcolor:27bgcolorbgcolorbgcolor:31bgcolorbgcolorbgcolor:32bgcolorbgcolorplot:33BarssinceBuyplotbgcolor:37bgcolorbgcolorbgcolor:38bgcolorbgcolorplot:39BarssinceSellplot

Order rules

OrderFires whenBy defaultLine
Close short(Buytrend)On68
Open long long(Buytrend)On69
Exit Max Loss stop(Buytrend)On70
Close long(not Buytrend)On75
Open short short(not Buytrend)On76
Exit Max Loss stop(not Buytrend)On77

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.

108/108trades 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.

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,311,450.0%+102.5%7930%0.768,424,000.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+7,178,780.0%+5.5%3482%2.75459,228.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−258,028.0%+9.8%1775%0.871,048,420.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+242,656.0%+8.4%3523%1.8430,796.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−127,644.0%+16.7%3520%0.42199,196.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+10,272.0%+21.5%1040%2.133,908.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−22,624.0%+148.3%3426%0.93181,256.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−69,292.0%+17.1%2425%0.52112,272.0%8 May 2026 – 21 Oct 2026

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

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Ema1Value 5, Ema2Value 34) made −7,640,630.0% before 26 Dec 2025 and +4,346,400.0% after it, worse than the defaults' +5,908,550.0% after. Tuning on the past did not carry forward. 0% of the 64 combinations made money in-sample and 100% out-of-sample.

Before 26 Dec 2025 · in-sample
Ema2Value ↓ · Ema1Value →567910121417
10−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
12−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
14−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
17−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
20−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
24−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
28−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%−8,220,000%
34−7,640,630%−7,640,630%−7,640,630%−7,640,630%−7,640,630%−7,640,630%−7,640,630%−7,640,630%
From 26 Dec 2025 · out-of-sample
Ema2Value ↓ · Ema1Value →567910121417
10+3,060,200%+3,060,200%+3,060,200%+3,060,200%+3,060,200%+3,060,200%+3,060,200%+3,060,200%
12+2,316,200%+2,316,200%+2,316,200%+2,316,200%+2,316,200%+2,316,200%+2,316,200%+2,316,200%
14+2,190,480%+2,190,480%+2,190,480%+2,190,480%+2,190,480%+2,190,480%+2,190,480%+2,190,480%
17+5,344,460%+5,344,460%+5,344,460%+5,344,460%+5,344,460%+5,344,460%+5,344,460%+5,344,460%
20+5,908,550%+5,908,550%+5,908,550%+5,908,550%+5,908,550%+5,908,550%+5,908,550%+5,908,550%
24+4,936,870%+4,936,870%+4,936,870%+4,936,870%+4,936,870%+4,936,870%+4,936,870%+4,936,870%
28+4,025,960%+4,025,960%+4,025,960%+4,025,960%+4,025,960%+4,025,960%+4,025,960%+4,025,960%
34+4,346,400%+4,346,400%+4,346,400%+4,346,400%+4,346,400%+4,346,400%+4,346,400%+4,346,400%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market3300%−$9,900,000.00
Sideways market3640%−$10,920,000.00
Falling market991%$15,041,400.00

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

How bad could the drawdown be?

1,040,570.0%

The 95th percentile of the worst drawdown when the same 793 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 8,942.0% to 1,040,570.0%; the tick is what actually happened, 12,000.0%. Order luck alone moves it this much.

0%1,196,656%
The first 150 of 793 trades
SideEntryExitBarsP&L
short26 Jan 2024 41,823.5027 Jan 2024 41,853.501−$30,000.00
short27 Jan 2024 42,120.6028 Jan 2024 42,150.601−$30,000.00
short28 Jan 2024 42,031.1029 Jan 2024 42,061.101−$30,000.00
short29 Jan 2024 43,302.7030 Jan 2024 43,332.701−$30,000.00
short30 Jan 2024 42,941.1031 Jan 2024 42,971.101−$30,000.00
short31 Jan 2024 42,580.001 Feb 2024 42,610.001−$30,000.00
short1 Feb 2024 43,082.902 Feb 2024 43,112.901−$30,000.00
short2 Feb 2024 43,200.003 Feb 2024 43,230.001−$30,000.00
short3 Feb 2024 43,011.104 Feb 2024 43,041.101−$30,000.00
short4 Feb 2024 42,582.905 Feb 2024 42,612.901−$30,000.00
short5 Feb 2024 42,708.706 Feb 2024 42,738.701−$30,000.00
short6 Feb 2024 43,098.907 Feb 2024 43,128.901−$30,000.00
short7 Feb 2024 44,349.608 Feb 2024 44,379.601−$30,000.00
short8 Feb 2024 45,288.709 Feb 2024 45,318.701−$30,000.00
short9 Feb 2024 47,132.8010 Feb 2024 47,162.801−$30,000.00
short10 Feb 2024 47,751.1011 Feb 2024 47,781.101−$30,000.00
short11 Feb 2024 48,300.0012 Feb 2024 48,330.001−$30,000.00
short12 Feb 2024 49,917.3013 Feb 2024 49,947.301−$30,000.00
short13 Feb 2024 49,699.6014 Feb 2024 49,729.601−$30,000.00
short14 Feb 2024 51,795.2015 Feb 2024 51,825.201−$30,000.00
short15 Feb 2024 51,880.0016 Feb 2024 51,910.001−$30,000.00
short16 Feb 2024 52,124.1017 Feb 2024 52,154.101−$30,000.00
short17 Feb 2024 51,642.6018 Feb 2024 51,672.601−$30,000.00
short18 Feb 2024 52,137.7019 Feb 2024 52,167.701−$30,000.00
short19 Feb 2024 51,774.7020 Feb 2024 51,804.701−$30,000.00
short20 Feb 2024 52,258.8021 Feb 2024 52,288.801−$30,000.00
short21 Feb 2024 51,849.4022 Feb 2024 51,879.401−$30,000.00
short22 Feb 2024 51,288.4023 Feb 2024 51,318.401−$30,000.00
short23 Feb 2024 50,744.2024 Feb 2024 50,774.201−$30,000.00
short24 Feb 2024 51,568.2025 Feb 2024 51,598.201−$30,000.00
short25 Feb 2024 51,728.8026 Feb 2024 51,758.801−$30,000.00
short26 Feb 2024 54,476.5027 Feb 2024 54,506.501−$30,000.00
short27 Feb 2024 57,037.3028 Feb 2024 57,067.301−$30,000.00
short28 Feb 2024 62,432.1029 Feb 2024 62,462.101−$30,000.00
short29 Feb 2024 61,131.001 Mar 2024 61,161.001−$30,000.00
short1 Mar 2024 62,387.902 Mar 2024 62,417.901−$30,000.00
short2 Mar 2024 61,987.303 Mar 2024 62,017.301−$30,000.00
short3 Mar 2024 63,114.004 Mar 2024 63,144.001−$30,000.00
short4 Mar 2024 68,245.705 Mar 2024 68,275.701−$30,000.00
short5 Mar 2024 63,724.006 Mar 2024 63,754.001−$30,000.00
short6 Mar 2024 66,074.007 Mar 2024 66,104.001−$30,000.00
short7 Mar 2024 66,823.208 Mar 2024 66,853.201−$30,000.00
short8 Mar 2024 68,124.209 Mar 2024 68,154.201−$30,000.00
short9 Mar 2024 68,313.3010 Mar 2024 68,343.301−$30,000.00
short10 Mar 2024 68,955.9011 Mar 2024 68,985.901−$30,000.00
short11 Mar 2024 72,078.1012 Mar 2024 72,108.101−$30,000.00
short12 Mar 2024 71,452.0013 Mar 2024 71,482.001−$30,000.00
short13 Mar 2024 73,072.4014 Mar 2024 73,102.401−$30,000.00
short14 Mar 2024 71,388.9015 Mar 2024 71,418.901−$30,000.00
short15 Mar 2024 69,499.9016 Mar 2024 69,529.901−$30,000.00
short16 Mar 2024 65,300.6017 Mar 2024 65,330.601−$30,000.00
short17 Mar 2024 68,393.5018 Mar 2024 68,423.501−$30,000.00
short18 Mar 2024 67,610.0019 Mar 2024 67,640.001−$30,000.00
short19 Mar 2024 61,937.4020 Mar 2024 61,967.401−$30,000.00
short20 Mar 2024 67,840.5021 Mar 2024 67,870.501−$30,000.00
short21 Mar 2024 65,501.3022 Mar 2024 65,531.301−$30,000.00
short22 Mar 2024 63,796.6023 Mar 2024 63,826.601−$30,000.00
short23 Mar 2024 63,990.0024 Mar 2024 64,020.001−$30,000.00
short24 Mar 2024 67,210.0025 Mar 2024 67,240.001−$30,000.00
long25 Mar 2024 69,880.0026 Mar 2024 69,850.001−$30,000.00
long26 Mar 2024 69,988.0027 Mar 2024 69,958.001−$30,000.00
long27 Mar 2024 69,470.0028 Mar 2024 69,440.001−$30,000.00
long28 Mar 2024 70,780.6029 Mar 2024 70,750.601−$30,000.00
long29 Mar 2024 69,850.5030 Mar 2024 69,820.501−$30,000.00
long30 Mar 2024 69,582.201 Apr 2024 69,552.202−$30,000.00
long1 Apr 2024 69,649.802 Apr 2024 69,619.801−$30,000.00
long2 Apr 2024 65,464.003 Apr 2024 65,434.001−$30,000.00
long3 Apr 2024 65,963.304 Apr 2024 65,933.301−$30,000.00
long4 Apr 2024 68,487.805 Apr 2024 68,457.801−$30,000.00
long5 Apr 2024 67,820.606 Apr 2024 67,790.601−$30,000.00
long6 Apr 2024 68,896.007 Apr 2024 68,866.001−$30,000.00
long7 Apr 2024 69,360.408 Apr 2024 69,330.401−$30,000.00
long8 Apr 2024 71,620.009 Apr 2024 71,590.001−$30,000.00
long9 Apr 2024 69,146.0010 Apr 2024 69,116.001−$30,000.00
long10 Apr 2024 70,631.1011 Apr 2024 70,601.101−$30,000.00
long11 Apr 2024 70,006.2012 Apr 2024 69,976.201−$30,000.00
long12 Apr 2024 67,116.5013 Apr 2024 67,086.501−$30,000.00
long13 Apr 2024 63,924.5014 Apr 2024 63,894.501−$30,000.00
long14 Apr 2024 65,661.8015 Apr 2024 65,631.801−$30,000.00
long15 Apr 2024 63,420.0016 Apr 2024 63,390.001−$30,000.00
long16 Apr 2024 63,793.4017 Apr 2024 63,763.401−$30,000.00
long17 Apr 2024 61,277.4018 Apr 2024 61,247.401−$30,000.00
long18 Apr 2024 63,470.1019 Apr 2024 63,440.101−$30,000.00
long19 Apr 2024 63,818.0020 Apr 2024 63,788.001−$30,000.00
long20 Apr 2024 64,940.6021 Apr 2024 64,910.601−$30,000.00
long21 Apr 2024 64,941.2022 Apr 2024 64,911.201−$30,000.00
long22 Apr 2024 66,819.3023 Apr 2024 66,789.301−$30,000.00
long23 Apr 2024 66,414.0024 Apr 2024 66,384.001−$30,000.00
long24 Apr 2024 64,289.6025 Apr 2024 64,259.601−$30,000.00
long25 Apr 2024 64,498.3026 Apr 2024 64,468.301−$30,000.00
long26 Apr 2024 63,770.0027 Apr 2024 63,740.001−$30,000.00
long27 Apr 2024 63,462.0028 Apr 2024 63,432.001−$30,000.00
long28 Apr 2024 63,118.6029 Apr 2024 63,088.601−$30,000.00
long29 Apr 2024 63,866.0030 Apr 2024 63,836.001−$30,000.00
long30 Apr 2024 60,672.001 May 2024 60,642.001−$30,000.00
long1 May 2024 58,365.002 May 2024 58,335.001−$30,000.00
long2 May 2024 59,060.603 May 2024 59,030.601−$30,000.00
long3 May 2024 62,882.004 May 2024 62,852.001−$30,000.00
long4 May 2024 63,892.005 May 2024 63,862.001−$30,000.00
long5 May 2024 64,012.006 May 2024 63,982.001−$30,000.00
long6 May 2024 63,165.207 May 2024 63,135.201−$30,000.00
long7 May 2024 62,312.108 May 2024 62,282.101−$30,000.00
long8 May 2024 61,193.009 May 2024 61,163.001−$30,000.00
long9 May 2024 63,074.0010 May 2024 63,044.001−$30,000.00
long10 May 2024 60,800.0011 May 2024 60,770.001−$30,000.00
long11 May 2024 60,826.0012 May 2024 60,796.001−$30,000.00
long12 May 2024 61,484.0013 May 2024 61,454.001−$30,000.00
long13 May 2024 62,940.1014 May 2024 62,910.101−$30,000.00
short14 May 2024 61,577.5015 May 2024 61,607.501−$30,000.00
short15 May 2024 66,206.5016 May 2024 66,236.501−$30,000.00
long16 May 2024 65,235.2017 May 2024 65,205.201−$30,000.00
long17 May 2024 67,024.0018 May 2024 66,994.001−$30,000.00
long18 May 2024 66,915.2019 May 2024 66,885.201−$30,000.00
long19 May 2024 66,274.0020 May 2024 66,244.001−$30,000.00
long20 May 2024 71,446.6021 May 2024 71,416.601−$30,000.00
long21 May 2024 70,148.3022 May 2024 70,118.301−$30,000.00
long22 May 2024 69,166.6023 May 2024 69,136.601−$30,000.00
long23 May 2024 67,969.6024 May 2024 67,939.601−$30,000.00
long24 May 2024 68,550.0025 May 2024 68,520.001−$30,000.00
long25 May 2024 69,290.6026 May 2024 69,260.601−$30,000.00
long26 May 2024 68,507.7027 May 2024 68,477.701−$30,000.00
long27 May 2024 69,436.4028 May 2024 69,406.401−$30,000.00
long28 May 2024 68,398.4029 May 2024 68,368.401−$30,000.00
long29 May 2024 67,652.4030 May 2024 67,622.401−$30,000.00
long30 May 2024 68,352.2031 May 2024 68,322.201−$30,000.00
long31 May 2024 67,540.001 Jun 2024 67,510.001−$30,000.00
long1 Jun 2024 67,766.902 Jun 2024 67,736.901−$30,000.00
long2 Jun 2024 67,765.603 Jun 2024 67,735.601−$30,000.00
long3 Jun 2024 68,809.904 Jun 2024 68,779.901−$30,000.00
long4 Jun 2024 70,537.805 Jun 2024 70,507.801−$30,000.00
long5 Jun 2024 71,108.006 Jun 2024 71,078.001−$30,000.00
long6 Jun 2024 70,799.107 Jun 2024 70,769.101−$30,000.00
long7 Jun 2024 69,355.608 Jun 2024 69,325.601−$30,000.00
long8 Jun 2024 69,310.509 Jun 2024 69,280.501−$30,000.00
long9 Jun 2024 69,648.1010 Jun 2024 69,618.101−$30,000.00
long10 Jun 2024 69,540.0011 Jun 2024 69,510.001−$30,000.00
long11 Jun 2024 67,314.2012 Jun 2024 67,284.201−$30,000.00
long12 Jun 2024 68,264.0013 Jun 2024 68,234.001−$30,000.00
long13 Jun 2024 66,773.0014 Jun 2024 66,743.001−$30,000.00
long14 Jun 2024 66,044.0015 Jun 2024 66,014.001−$30,000.00
long15 Jun 2024 66,228.3016 Jun 2024 66,198.301−$30,000.00
long16 Jun 2024 66,676.9017 Jun 2024 66,646.901−$30,000.00
long17 Jun 2024 66,504.3018 Jun 2024 66,474.301−$30,000.00
long18 Jun 2024 65,175.3019 Jun 2024 65,145.301−$30,000.00
long19 Jun 2024 64,974.4020 Jun 2024 64,944.401−$30,000.00
long20 Jun 2024 64,870.0021 Jun 2024 64,840.001−$30,000.00
long21 Jun 2024 64,143.6022 Jun 2024 64,113.601−$30,000.00
long22 Jun 2024 64,262.0023 Jun 2024 64,232.001−$30,000.00
long23 Jun 2024 63,210.0024 Jun 2024 63,180.001−$30,000.00
short24 Jun 2024 60,293.3025 Jun 2024 60,323.301−$30,000.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
[Strategy] - EMA 10,20 59 with Profit Displayed this page—v4 strategy−2,311,450.0%7938,424,000.0%
Mathias & Christer EMA by mattehalenema barssincev4 strategyNo trades on this market
Dazzling Bolts by OrcChieftainema barssincev4 strategy+8.5%1413.0%
Triple Supertrend with EMA and ADX strategy by kunjandetrojaema barssincev5 strategy−1.0%585.3%
Momentum Strategy (BTC-USDT; 30m) - STOCH RSI (with source code) by Drun30ema barssincev4 strategy+13.3%1213.6%
Twin Range Filter Algo by OrcChieftainema barssincev4 strategy+48.4%186.8%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 69, 76) 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/// © mattehalen//@version=4//study("EMA 10,20 59",overlay=true)strategy("EMA 10,20 59",overlay=true, process_orders_on_close = true, default_qty_type =  strategy.fixed, default_qty_value = 1000, initial_capital=250, currency=currency.USD)infoBox     = input(true, title="infoBox", type=input.bool)infoBox2    = input(false, title="infoBox2", type=input.bool)BuySellSignal_Bool = input(false, title="Buy & SellSignal", type=input.bool)infoBoxSize = input(title="infoBoxSize", defval=size.large, options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge])ema1Value   = input(10)ema2Value   = input(20)ema3Value   = input(59)maxLoss = input(3000)ema1        = ema(close,ema1Value)ema2        = ema(close,ema2Value)ema3        = ema(close,ema3Value)objcnt      = 0buyTitle    = tostring(close[1])myProfit    = float(0)plot(ema1,title="ema1",color=color.red,linewidth=2)plot(ema2,title="ema2",color=color.green,linewidth=2)plot(ema3,title="ema3",color=color.black,linewidth=2)Buytrend = (ema1 and ema2 > ema3) and (ema1[1] and ema2[1] > ema3[1])BarssinceBuyTrend = barssince(Buytrend)BarssinceSellTrend = barssince(not Buytrend)closeAtBuyTrend = close[1]bgcolor(Buytrend ? color.green : color.red,transp=70)BuySignal = Buytrend and not Buytrend[1] and BuySellSignal_BoolBuySignalOut = Buytrend and (crossunder(ema1,ema2)) and BuySellSignal_BoolBarssinceBuy = barssince(BuySignal)bgcolor(BuySignal ? color.green : na , transp=30)bgcolor(BuySignalOut ? color.black : na , transp=30)plot(BarssinceBuy,title="BarssinceBuy",display=display.none)SellSignal = not Buytrend and Buytrend[1] and BuySellSignal_BoolSellSignalOut = not Buytrend and (crossover(ema1,ema2)) and BuySellSignal_BoolBarssinceSell = barssince(SellSignal)bgcolor(SellSignal ? color.red : na , transp=30)bgcolor(SellSignalOut ? color.black : na , transp=30)plot(BarssinceSell,title="BarssinceSell",display=display.none)buyProfit   = float(0)cntBuy      =0sellProfit  = float(0)cntSell     =0buyProfit   := Buytrend and not Buytrend[1]? nz(buyProfit[1]) + (close[BarssinceBuyTrend[1]]-close) : nz(buyProfit[1])cntBuy      := Buytrend and not Buytrend[1]? nz(cntBuy[1]) + 1: nz(cntBuy[1])sellProfit  := not Buytrend and Buytrend[1]? nz(sellProfit[1]) + (close-close[BarssinceSellTrend[1]]) : nz(sellProfit[1])cntSell     := not Buytrend and Buytrend[1]? nz(cntSell[1]) + 1 : nz(cntSell[1])totalProfit = buyProfit + sellProfitif (Buytrend and not Buytrend[1] and infoBox==true)    l = label.new(bar_index - (BarssinceBuyTrend[1]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuyTrend[1]]) + "\n" + "Profit = "+tostring(close[BarssinceBuyTrend[1]]-close) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.red,size=infoBoxSize)if (not Buytrend and Buytrend[1] and infoBox==true)    l = label.new(bar_index - (BarssinceSellTrend[1]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSellTrend[1]]) + "\n" + "Profit = "+tostring(close-close[BarssinceSellTrend[1]]) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.green,size=infoBoxSize)if (BuySignalOut and not BuySignalOut[1] and infoBox2==true)//    l = label.new(bar_index - (BarssinceBuy[0]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuy[0]]) + "\n" + "Profit = "+tostring(close-close[BarssinceBuy[0]]) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.purple,size=infoBoxSize    l = label.new(bar_index, na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceBuy[0]]) + "\n" + "Profit = "+tostring(close-close[BarssinceBuy[0]]) ,style=label.style_labelup, yloc=yloc.belowbar,color=color.lime,size=infoBoxSize)if (SellSignalOut and not SellSignalOut[1] and infoBox2==true)//    l = label.new(bar_index - (BarssinceSell[0]/2), na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSell[0]]) + "\n" + "Profit = "+tostring(close[BarssinceSell[0]]-close) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.purple,size=infoBoxSize)    l = label.new(bar_index, na,text="Close = " + tostring(close) + "\n" + "Start = "+tostring(close[BarssinceSell[0]]) + "\n" + "Profit = "+tostring(close[BarssinceSell[0]]-close) ,style=label.style_labeldown, yloc=yloc.abovebar,color=color.fuchsia,size=infoBoxSize)l2 = label.new(bar_index, na, 'buyProfit in pip = '+tostring(buyProfit)+"\n"+  'cntBuy = '+tostring(cntBuy) +"\n"+  'sellProfit in pip = '+tostring(sellProfit)+"\n"+  'cntSell = '+tostring(cntSell) +"\n"+  'totalProfit in pip = '+tostring(totalProfit)     ,   color=totalProfit>0 ? color.green : color.red,   textcolor=color.white,  style=label.style_labeldown, yloc=yloc.abovebar,  size=size.large)label.delete(l2[1])//--------------------------------------------------//--------------------------------------------------if (Buytrend)    strategy.close("short", comment = "Exit short")    strategy.entry("long", true)    strategy.exit("Max Loss", "long", loss = maxLoss)//if BuySignalOut   // strategy.close("long", comment = "Exit Long")if (not Buytrend)    // Enter trade and issue exit order on max loss.    strategy.close("long", comment = "Exit Long")    strategy.entry("short", false)    strategy.exit("Max Loss", "short", loss = maxLoss)//if SellSignalOut    // Force trade exit.    //strategy.close("short", comment = "Exit short")    //--------------------------------------------------//--------------------------------------------------//--------------------------------------------------