Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

EMA12-26 with date backtest range (BTCpair)

A Pine Script v5 strategy built on EMA (close, 12) and Crossover (fastEMA, slowEMA). It has 4 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 0.02 in cash and pays no commission. 3 settings.

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 EMA12-26 with date backtest range (BTCpair) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 6 of 6 trades.
How did EMA12-26 with date backtest range (BTCpair) do on BTCUSDT 1D with default settings?
+0.50%
From 26 Jan 2024 to 21 Oct 2026, over 16 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does EMA12-26 with date backtest range (BTCpair) run in Pine Script v6?
Yes
Same 16 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does EMA12-26 with date backtest range (BTCpair) use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does EMA12-26 with date backtest range (BTCpair) run in Zeal Terminal?
Yes
It compiles in 11 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 (3)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$1$2Equity from $1
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
+0.50%
$0.01
Buy and hold
+102.5%
same period
Closed trades
16
4 won · 12 lost
Profitable
25.0%
of closed trades
Profit factor
1.43
gross profit ÷ gross loss
Max drawdown
0.58%
−$0.01

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

Settings

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

SettingDefaultType and rangeFeeds
Backtest Time Period
Filter Date Range of BacktestfalseboolinTradeWindow
Start DateThis start date is in the time zone of the exchange " + "where the chart's instrument trades. It doesn't use the time " + "zone of the chart or of your computer.timestamp("1 Jan 2021")timeinTradeWindow
End DateThis end date is in the time zone of the exchange " + "where the chart's instrument trades. It doesn't use the time " + "zone of the chart or of your computer.timestamp("1 Jan 2022")timeinTradeWindow

What it calculates

  • EMAclose, 12fastEMA · line 23
  • EMAclose, 26slowEMA · line 23
  • CrossoverfastEMA, slowEMAlongCondition · line 27

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 databacktestStartDateStart Datesetting · timestamp("1 Jan 20…backtestEndDateEnd Datesetting · timestamp("1 Jan 20…fastEMAEMA→ fastEMAslowEMAEMA→ slowEMAlongConditionCrossover→ longConditioninTradeWindowinTradeWindowconditionentry:buyOpen buystrategy.entryclose:buyClose buystrategy.closecancel_all:cancel_all strategy.cancel_allclose_all:close_all strategy.close_allplot:24plotplotplot:25plotplot

Order rules

OrderFires whenBy defaultLine
Open buy long(longCondition) and inTradeWindowOn29
Close buyta.crossunder(ta.ema(close, 12), ta.ema(close, 26)) and inTradeWindowOn31
cancel_all not inTradeWindow and inTradeWindow[1]On35
Close not inTradeWindow and inTradeWindow[1]On36

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.

6/6trades 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+0.5%+102.5%1625%1.430.6%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.1%+5.5%2129%1.140.2%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+1.2%+9.8%1429%1.700.8%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.5%+8.4%1631%1.940.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.3%+16.7%1533%1.151.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.8%+21.5%1533%2.850.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+1.2%+148.3%1638%2.140.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%1828%1.350.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 market425%−$0.00
Sideways market617%$0.00
Falling market633%$0.00

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

How bad could the drawdown be?

1.0%

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

0%1%
All 16 trades
SideEntryExitBarsP&L
long18 May 2024 67,024.0017 Jun 2024 66,676.9030−$0.00
long19 Jul 2024 63,987.905 Aug 2024 58,161.0017−$0.00
long25 Aug 2024 64,157.0029 Aug 2024 59,034.904−$0.00
long19 Sep 2024 61,760.0030 Dec 2024 93,738.20102$0.01
long6 Jan 2025 98,363.6010 Jan 2025 92,552.504−$0.00
long17 Jan 2025 99,987.306 Feb 2025 96,612.4020−$0.00
long20 Apr 2025 85,077.0022 Jun 2025 102,120.0063$0.00
long26 Jun 2025 107,341.0021 Aug 2025 114,271.0056$0.00
long14 Sep 2025 115,918.0026 Sep 2025 108,994.0012−$0.00
long2 Oct 2025 118,595.0016 Oct 2025 110,763.0014−$0.00
long6 Jan 2026 93,859.7025 Jan 2026 89,225.3019−$0.00
long16 Mar 2026 72,815.3023 Mar 2026 67,859.007−$0.00
long24 Mar 2026 70,906.4027 Mar 2026 68,820.303−$0.00
long10 Apr 2026 71,788.0023 May 2026 75,539.5043$0.00
long16 Jul 2026 64,756.302 Aug 2026 62,823.7017−$0.00
long7 Aug 2026 64,323.6013 Aug 2026 63,480.006−$0.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
EMA12-26 with date backtest range (BTCpair) this page—v5 strategy+0.5%160.6%
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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Same 16 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © HomoDeus666-//@version=5+//@version=6strategy("CDC actionzone with date backtest range (BTCpair)", overlay=true,initial_capital = 1,commission_type = strategy.commission.percent,default_qty_value = 0.02,currency = currency.BTC,default_qty_type = strategy.cash)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 11 msYes 1,000 bars in 25 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/// © HomoDeus666//@version=5strategy("CDC actionzone with date backtest range (BTCpair)", overlay=true,initial_capital = 1,commission_type = strategy.commission.percent,default_qty_value = 0.02,currency = currency.BTC,default_qty_type = strategy.cash)//input date and timeuseDateFilter = input.bool(false, title="Filter Date Range of Backtest",     group="Backtest Time Period")backtestStartDate = input.time(timestamp("1 Jan 2021"),      title="Start Date", group="Backtest Time Period",     tooltip="This start date is in the time zone of the exchange " +      "where the chart's instrument trades. It doesn't use the time " +      "zone of the chart or of your computer.")backtestEndDate = input.time(timestamp("1 Jan 2022"),     title="End Date", group="Backtest Time Period",     tooltip="This end date is in the time zone of the exchange " +      "where the chart's instrument trades. It doesn't use the time " +      "zone of the chart or of your computer.")     //check date and time optioninTradeWindow = not useDateFilter or (time >= backtestStartDate and     time < backtestEndDate)/// plot and indicatorfastEMA = ta.ema(close,12), slowEMA=ta.ema(close,26)plot(fastEMA,color=color.green,linewidth = 2)plot(slowEMA,color=color.red,linewidth=2)//entry when conditionlongCondition = ta.crossover(fastEMA,slowEMA)if (longCondition) and inTradeWindow    strategy.entry("buy", strategy.long)if ta.crossunder(ta.ema(close, 12), ta.ema(close, 26)) and inTradeWindow    strategy.close("buy")    // trades and cancel all unfilled pending ordersif not inTradeWindow and inTradeWindow[1]    strategy.cancel_all()    strategy.close_all(comment="Date Range Exit")