Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Trend Identifier Strategy

A Pine Script v5 strategy built on ALMA (close, 140), EMA or Stoch (3) and EMA (dema-dema[1], 5). 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 100% of equity and pays 0.03% commission. 7 settings; defaults include start year 2020, start month 1 and start day 1.

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 Trend Identifier Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 5 of 5 trades.
How did Trend Identifier Strategy do on BTCUSDT 1D with default settings?
+61.96%
From 26 Jan 2024 to 21 Oct 2026, over 24 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Trend Identifier Strategy 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: 24 before, 33 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
Does Trend Identifier Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Trend Identifier Strategy run in Zeal Terminal?
Yes
It compiles in 33 ms and runs 1,000 bars in 46 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (7)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctPlot$1,652$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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
Net profit
+61.96%
$619.62
Buy and hold
+102.5%
same period
Closed trades
24
8 won · 16 lost
Profitable
33.3%
of closed trades
Profit factor
2.22
gross profit ÷ gross loss
Max drawdown
20.37%
−$283.23

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

    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
start year2020inttimeStart
start month1inttimeStart
start day1inttimeStart
end year2025inttimeEnd
end month1inttimeEnd
end day1inttimeEnd
Choose Time IntervalfalseboolcondTime

What it calculates

  • ALMAclose, 140, 1.1, 6ema · line 22
  • EMA / Stochta.ema(ta.stoch(dema,dema,dema,100),3), 3stodema · line 24
  • EMAdema-dema[1], 5d2ema · line 25
  • EMA / Stochta.ema(ta.stoch(d2ema,d2ema,d2ema,100),3), 3stod2ema · line 26
  • EMAclose, 120*24/tfcind · line 27
  • EMA / Stochta.stoch(ind,ind,ind,120*24/tfc), 3heat · line 28
  • EMAheat, 7*24/tfcindex · line 29
  • EMAdema, 21demaema · 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 datatimetimeprice dataendyearend yearsetting · 2025endmonthend monthsetting · 1enddayend daysetting · 1startyearstart yearsetting · 2020startmonthstart monthsetting · 1startdaystart daysetting · 1emaALMA→ emastodemaEMA / Stoch→ stodemad2emaEMA→ d2emastod2emaEMA / Stoch→ stod2emaindEMA→ indheatEMA / Stoch→ heatindexEMA→ indexdemaemaEMA→ demaemacondTimecondTimevaluedemademavaluecond1acond1aconditioncond1bcond1bconditiontimeEndtimeEndconditiontimeStarttimeStartconditiongreen, yellow, red, blue, tcolorColourgreen · yellow +3entry:buyOpen buystrategy.entryorder:sellorder sellstrategy.orderplot:37plotplot

Order rules

OrderFires whenBy defaultLine
Open buy long(condTime and cond1a and ( ( ((tcolor[1] == red and demaema<0.02) or (tcolor[1] == blue and demaema < 0.02) or (tcolor[1] == yellow and demaema>-0.02) ) and tcolor == green) or (tcolor[1] == red and tcolor == blue and demaema < -0.01) ) and index<85 and ind<0.4)On42
order sell short(condTime and cond1b and ( (((tcolor[1] == yellow and demaema > -0.02) or (tcolor[1] == blue and demaema < 0.02) or (tcolor[1] == green and demaema < 0.02)) and tcolor == red) or (tcolor[1] == green and tcolor == yellow and demaema > 0.015) ) and index>15 and ind>-0.1)On45

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.

5/5trades 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+62.0%+102.5%2433%2.2220.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+102.7%+9.8%1040%2.1348.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−42.4%+16.7%2138%0.6462.1%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+45.3%+148.3%2133%1.9322.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%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 market729%−$85.04
Sideways market1331%$318.80
Falling market450%$386.34

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

How bad could the drawdown be?

28.9%

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

0%33%
All 24 trades
SideEntryExitBarsP&L
long16 Jul 2024 64,724.103 Aug 2024 61,498.3018−$50.42
long24 Aug 2024 64,037.2028 Aug 2024 59,415.004−$69.09
long14 Sep 2024 60,498.0017 Sep 2024 58,214.003−$33.76
long18 Sep 2024 60,314.003 Oct 2024 60,649.3015$4.20
long7 Oct 2024 62,819.9010 Oct 2024 60,636.003−$30.08
long12 Oct 2024 62,540.0023 Dec 2024 95,186.3072$427.86
long25 Dec 2024 98,663.6027 Dec 2024 95,791.602−$37.09
long4 Jan 2025 98,174.208 Jan 2025 96,954.604−$15.77
long16 Jan 2025 100,497.003 Feb 2025 97,700.6018−$33.99
long4 Feb 2025 101,329.005 Feb 2025 97,763.101−$41.57
long13 Apr 2025 85,276.906 Jun 2025 101,509.0054$212.50
long8 Jun 2025 105,552.0018 Jun 2025 104,551.0010−$13.44
long24 Jun 2025 105,334.002 Jul 2025 105,681.008$3.56
long3 Jul 2025 108,850.002 Aug 2025 113,298.0030$53.25
long7 Aug 2025 114,992.0019 Aug 2025 116,227.0012$13.95
long23 Aug 2025 116,936.0025 Aug 2025 113,494.002−$41.74
long11 Sep 2025 113,960.0023 Sep 2025 112,651.0012−$16.29
long30 Sep 2025 114,312.0011 Oct 2025 112,774.0011−$18.71
long27 Oct 2025 114,559.0030 Oct 2025 110,021.003−$52.80
long3 Jan 2026 89,995.1021 Jan 2026 88,427.7018−$22.71
long5 Mar 2026 72,666.8019 May 2026 77,001.9075$73.08
long11 Jul 2026 64,161.701 Aug 2026 62,887.9021−$26.81
long5 Aug 2026 64,106.6011 Aug 2026 63,970.006−$3.50
long18 Aug 2026 64,532.1015 Oct 2026 81,682.0058$339.47

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
Trend Identifier Strategy this page—v5 strategy+62.0%2420.4%
Full Crypto Swing Strategy ALMA Cross with MACD by exlux99alma emav4 strategyNo trades on this market
Arnaud Legoux Moving Average Cross (ALMA) by Sarahann999alma emav5 strategy+0.2%90.9%
Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) by CheatCode1ema stochv5 strategy−3.0%7245.4%
Stochastic Moving Average by LucasVivienstoch emav5 strategy+2.8%74.4%
OTT-Stoch-TP-SL by BigCoinHunterema stochv5 strategyNo trades on this market

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.

  • 1 setting uses the untyped input() (line 15). 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 24 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 15: input() → input.bool()
⋯timeStart = time >= timestamp(syminfo.timezone,startyear,startmonth,startday,0,0)-choosetime = input(false,"Choose Time Interval")+choosetime = input.bool(false,"Choose Time Interval")condTime = (choosetime ? (timeStart and timeEnd) : true)⋯

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: 24 before, 33 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.

⋯// -//@version=5+//@version=6strategy(title="Trend Identifier Strategy", shorttitle="Trend Identifier Strategy", format=format.price, precision=4, overlay = false, initial_capital = 1000, pyramiding = 10, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, commission_value = 0.03)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 33 msWith a workaround 1,000 bars in 46 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// © spacekadet17// //@version=5strategy(title="Trend Identifier Strategy", shorttitle="Trend Identifier Strategy", format=format.price, precision=4, overlay = false, initial_capital = 1000, pyramiding = 10, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, commission_type = strategy.commission.percent, commission_value = 0.03)//start-end timestartyear = input.int(2020,"start year")startmonth = input.int(1,"start month")startday = input.int(1,"start day")endyear = input.int(2025,"end year")endmonth = input.int(1,"end month")endday = input.int(1,"end day")timeEnd = time <= timestamp(syminfo.timezone,endyear,endmonth,endday,0,0)timeStart = time >= timestamp(syminfo.timezone,startyear,startmonth,startday,0,0)choosetime = input(false,"Choose Time Interval")condTime = (choosetime ? (timeStart and timeEnd) : true)// time frame?tfc = 1if timeframe.isdaily    tfc := 24// indicators: price normalized alma, and its 1st and 2nd derivativesema = ta.alma(close,140,1.1,6)dema = (ema-ema[1])/emastodema = ta.ema(ta.ema(ta.stoch(dema,dema,dema,100),3),3)d2ema = ta.ema(dema-dema[1],5)stod2ema = ta.ema(ta.ema(ta.stoch(d2ema,d2ema,d2ema,100),3),3)ind = (close-ta.ema(close,120*24/tfc))/closeheat = ta.ema(ta.stoch(ind,ind,ind,120*24/tfc),3)index = ta.ema(heat,7*24/tfc)//plot graphgreen = color.rgb(20,255,100)yellow = color.yellowred = color.redblue = color.rgb(20,120,255)tcolor = (dema>0) and (d2ema>0)? green : (dema>0) and (d2ema<0) ? yellow : (dema < 0) and (d2ema<0) ? red : (dema < 0) and (d2ema>0) ? blue : color.blackdemaema = ta.ema(dema,21)plot(demaema, color = tcolor)//strategy buy-sell conditionscond1a = strategy.position_size <= 0cond1b = strategy.position_size > 0if (condTime and cond1a and ( ( ((tcolor[1] == red and demaema<0.02) or (tcolor[1] == blue and demaema < 0.02) or (tcolor[1] == yellow and demaema>-0.02) ) and tcolor == green) or (tcolor[1] == red and tcolor == blue and demaema < -0.01) ) and index<85 and ind<0.4)    strategy.entry("buy",strategy.long, (strategy.equity-strategy.position_size*close)/1/close)    if (condTime and cond1b and ( (((tcolor[1] == yellow and demaema > -0.02) or (tcolor[1] == blue and demaema < 0.02) or (tcolor[1] == green and demaema < 0.02)) and tcolor == red) or (tcolor[1] == green and tcolor == yellow and demaema > 0.015) ) and index>15 and ind>-0.1)    strategy.order("sell",strategy.short, strategy.position_size)