Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

EMA_TREND_CATCHER

A Pine Script v5 strategy built on EMA (close, 55) and Crossunder or EMA (close,100, close,200). It has 8 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 is one contract and pays 0.05% commission. 9 settings; defaults include profit_short 27, stop_short 2 and stop_long 3.

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 EMA_TREND_CATCHER repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 1 of 1 trades.
How did EMA_TREND_CATCHER do on BTCUSDT 1D with default settings?
+3,545.00%
From 26 Jan 2024 to 21 Oct 2026, over 5 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does EMA_TREND_CATCHER run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L44:C19: 'fill' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download.
Does EMA_TREND_CATCHER use a stop loss?
Yes
strategy.exit sets a stop on line 53, 58.
Does EMA_TREND_CATCHER run in Zeal Terminal?
Yes
It compiles in 25 ms and runs 1,000 bars in 57 ms, in the browser.

BTCUSDT · 1D · default settings

  • ema 12
  • ema 25
  • ema 30
  • ema 40
  • ema 55
  • ema 100
  • ema 200
  • EMA(50)
  • EMA(100)
  • 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 (9)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$36,454$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. Lines are what the script plots.
Net profit
+3,545.00%
$35,450.00
Buy and hold
+102.5%
same period
Closed trades
5
2 won · 3 lost
Profitable
40.0%
of closed trades
Profit factor
7.37
gross profit ÷ gross loss
Max drawdown
253.82%
−$4,339.72

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

    4 settings do nothing

    “media_1”, “media_2”, “resta_medias2”, “RSI_periodos” are declared but never read.

  • Note

    No slippage

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

Settings

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

SettingDefaultType and rangeFeeds
profit_short27intexit cerrar short
stop_short2intexit cerrar short
stop_long3intexit cerrar long
profit_long35intexit cerrar long
media_155intunused
media_2100intunused
resta_medias0intcol
resta_medias20intunused
RSI_periodos42intunused

What it calculates

  • EMAclose, 55EMA50 · line 37
  • EMAclose, 100EMA100 · line 38
  • Crossunder / EMAta.ema(close,100), ta.ema(close,200)Go_Short · line 46
  • Crossunder / EMAta.ema(close,25), ta.ema(close,6)cancelar_short · line 49
  • Crossunder / EMAta.ema(close,12), ta.ema(close,30)cancelar · line 55

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 dataresta_mediasresta_mediassetting · 0EMA50EMA→ EMA50EMA100EMA→ EMA100Go_ShortCrossunder / EMA→ Go_Shortcancelar_shortCrossunder / EMA→ cancelar_shortcancelarCrossunder / EMA→ cancelarestado_mediasestado_mediasvalueGo_LongGo_LongconditioncolColourcolclose:enter longClose enter longstrategy.closeentry:enter shortOpen enter shortstrategy.entryexit:cerrar shortexit cerrar shortstrategy.exitclose:enter shortClose enter shortstrategy.closeentry:enter longOpen enter longstrategy.entryexit:cerrar longexit cerrar longstrategy.exitplot:28ema 12plotplot:29ema 25plotplot:30ema 30plotplot:31ema 40plotplot:32ema 55plotplot:33ema 100plotplot:34ema 200plotplot:40EMA(50)plotplot:41EMA(100)plotfill:44Fillfillbgcolor:62bgcolorbgcolor

Order rules

OrderFires whenBy defaultLine
Close enter longevery barOn48
Open enter short shortGo_ShortOn51
Exit cerrar short stop and limitevery barOn53
Close enter shortevery barOn54
Open enter long longGo_LongOn57
Exit cerrar long stop and limitevery barOn58
Close enter shortevery barOn59
Close enter longevery barOn60

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.

1/1trades 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+3,545.0%+102.5%540%7.37253.8%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+1,286.5%+5.5%450%13.56186.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+13.6%+9.8%520%1.4919.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−6.3%+8.4%20%0.0010.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2.5%+16.7%60%0.002.5%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.9%+21.5%50%0.000.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−10.5%+148.3%60%0.0010.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−3.3%+17.1%20%0.003.3%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%$38,588.50
Falling market20%−$3,138.57

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

How bad could the drawdown be?

17,673.2%

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

0%20,324%
All 5 trades
SideEntryExitBarsP&L
short5 Sep 2024 57,970.9013 Sep 2024 59,133.608−$1,221.20
long15 Oct 2024 66,084.005 Dec 2024 100,590.0051$34,422.20
long5 May 2025 94,277.6023 Jun 2025 100,964.0049$6,588.64
short29 Nov 2025 90,890.703 Dec 2025 92,716.304−$1,917.36
long29 Aug 2026 77,845.9015 Sep 2026 75,500.2017−$2,422.35

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
EMA_TREND_CATCHER this page—v5 strategy+3,545.0%5253.8%
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%

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.

  • 9 settings use the untyped input() (line 6, 7, 8, 9, 10, 11, 12, 13, 14). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

Same 5 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 10: input() → input.int()
  • Line 11: input() → input.int()
3 more edits
  • Line 12: input() → input.int()
  • Line 13: input() → input.int()
  • Line 14: input() → input.int()
⋯//#####variables##############-profit_short=input(title='profit_short', defval=27)+profit_short=input.int(title='profit_short', defval=27)-stop_short=input(title='stop_short', defval=2)+stop_short=input.int(title='stop_short', defval=2)-stop_long=input(title='stop_long', defval=3)+stop_long=input.int(title='stop_long', defval=3)-profit_long=input(title='profit_long', defval=35)+profit_long=input.int(title='profit_long', defval=35)-media_1=input(title='media_1', defval=55)+media_1=input.int(title='media_1', defval=55)-media_2=input(title='media_2', defval=100)+media_2=input.int(title='media_2', defval=100)-resta_medias=input(title='resta_medias', defval=0)+resta_medias=input.int(title='resta_medias', defval=0)-resta_medias2=input(title='resta_medias2', defval=0)+resta_medias2=input.int(title='resta_medias2', defval=0)-RSI_periodos=input(title='RSI_periodos', defval=42)+RSI_periodos=input.int(title='RSI_periodos', defval=42)//###############VARIABLES###################⋯

Does it run in Pine Script v6?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L44:C19: 'fill' has no 'transp' parameter in Pine Script v6. Use color.new(color, transparency) instead. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © pernath-//@version=5+//@version=6strategy("TREND_CATCHER", overlay=true, commission_value=0.05, commission_type=strategy.commission.percent, initial_capital=1000)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 25 msYes 1,000 bars in 57 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/// © pernath//@version=5strategy("TREND_CATCHER", overlay=true, commission_value=0.05, commission_type=strategy.commission.percent, initial_capital=1000)//#####variables##############profit_short=input(title='profit_short', defval=27)stop_short=input(title='stop_short', defval=2)stop_long=input(title='stop_long', defval=3)profit_long=input(title='profit_long', defval=35)media_1=input(title='media_1', defval=55)media_2=input(title='media_2', defval=100)resta_medias=input(title='resta_medias', defval=0)resta_medias2=input(title='resta_medias2', defval=0)RSI_periodos=input(title='RSI_periodos', defval=42)//###############VARIABLES###################//#####Alert#####id_bot = ""email_token = ""long_open =""long_close =""short_open =""short_close =""//#  {{strategy.order.alert_message}}//#############################//#############################//###############EMA##############///plot(ta.ema(close, 1), title='ema 5', color=color.white)plot(ta.ema(close, 12), title='ema 12', color=color.white)plot(ta.ema(close, 25), title='ema 25', color=color.white)plot(ta.ema(close, 30), title='ema 30', color=color.white, linewidth=1)plot(ta.ema(close, 40), title='ema 40', color=color.white, linewidth=1)plot(ta.ema(close, 55), title='ema 55', color=color.orange, linewidth=1)plot(ta.ema(close, 100), title='ema 100', color=color.red, linewidth=1)plot(ta.ema(close, 200), title='ema 200', color=color.white, linewidth=3)//#############################///######VISUAL#############EMA50 = ta.ema(close, 55)EMA100 = ta.ema(close, 100)estado_medias=EMA50-EMA100a = plot(EMA50, title="EMA(50)", color=color.orange, linewidth=1 ) b = plot(EMA100, title="EMA(100)", color=color.red, linewidth=1 )var color col = nacol := estado_medias>resta_medias ? color.green : color.redfill(a,b,color=col,transp=40)//######VISUAL#############Go_Short=(ta.crossunder(ta.ema(close,100),ta.ema(close,200)))Go_Long=((ta.crossover(ta.ema(close,55),ta.ema(close,100))and(ta.ema(close,12)>ta.ema(close,200))))strategy.close("enter long", (Go_Short),alert_message=long_open)cancelar_short=((ta.crossunder(ta.ema(close,25),ta.ema(close,6))))if Go_Short    strategy.entry("enter short", strategy.short,1, alert_message=short_open)   strategy.exit("cerrar short", "enter short", 1, profit=close*profit_short/100/syminfo.mintick, loss=close*stop_short/100/syminfo.mintick, alert_message=short_close)strategy.close("enter short", (Go_Long),alert_message=short_close)cancelar=((ta.crossunder(ta.ema(close,12),ta.ema(close,30))))if Go_Long    strategy.entry("enter long", strategy.long,1,alert_message=long_open)strategy.exit("cerrar long", "enter long", 1, profit=close*profit_long/100/syminfo.mintick, loss=close*stop_long/100/syminfo.mintick, alert_message=long_close)strategy.close("enter short", (cancelar_short),alert_message=short_close)strategy.close("enter long", (cancelar),alert_message=long_close)//posiciones abiertasbgcolor((strategy.position_size > 0 or strategy.position_size < 0) ? color.blue : na, transp=70)