Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

EMA12-26 buy spot only

A Pine Script v5 strategy built on Crossover or EMA (close, 12, close, 26). 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 is one contract and pays no commission. It has no 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 buy spot only 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 buy spot only do on BTCUSDT 1D with default settings?
+1.00%
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 buy spot only 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: 16 before, 12 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 EMA12-26 buy spot only use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does EMA12-26 buy spot only run in Zeal Terminal?
Yes
It compiles in 7 ms and runs 1,000 bars in 15 ms, in the browser.

BTCUSDT · 1D · default settings

  • Crossover
  • 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 (0)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,025,380$2,025,273Equity from $1,000,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.
Net profit
+1.00%
$10,012.70
Buy and hold
+102.5%
same period
Closed trades
16
4 won · 12 lost
Profitable
25.0%
of closed trades
Profit factor
1.20
gross profit ÷ gross loss
Max drawdown
2.68%
−$27,714.40

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

    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.

The script declares no settings.

What it calculates

  • Crossover / EMAta.ema(close, 12), ta.ema(close, 26)longCondition · line 5

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 datalongConditionCrossover / EMA→ longConditionentry:buyOpen buystrategy.entryclose:buyClose buystrategy.close

Order rules

OrderFires whenBy defaultLine
Open buy long(longCondition)On7
Close buyta.crossunder(ta.ema(close, 12), ta.ema(close, 26))On9

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+1.0%+102.5%1625%1.202.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+0.0%+5.5%2129%1.010.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+0.0%+9.8%1429%1.170.1%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.0%+8.4%1631%1.590.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%1533%0.840.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%1533%2.600.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.0%+148.3%1638%2.060.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.0%+17.1%1828%1.340.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 market425%−$2,602.48
Sideways market617%$1,317.41
Falling market633%$11,297.80

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

How bad could the drawdown be?

4.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, 1.8% to 4.0%; the tick is what actually happened, 2.6%. Order luck alone moves it this much.

0%5%
All 16 trades
SideEntryExitBarsP&L
long18 May 2024 67,024.0017 Jun 2024 66,676.9030−$347.14
long19 Jul 2024 63,987.905 Aug 2024 58,161.0017−$5,826.92
long25 Aug 2024 64,157.0029 Aug 2024 59,034.904−$5,122.12
long19 Sep 2024 61,760.0030 Dec 2024 93,738.20102$31,978.20
long6 Jan 2025 98,363.6010 Jan 2025 92,552.504−$5,811.12
long17 Jan 2025 99,987.306 Feb 2025 96,612.4020−$3,374.86
long20 Apr 2025 85,077.0022 Jun 2025 102,120.0063$17,043.00
long26 Jun 2025 107,341.0021 Aug 2025 114,271.0056$6,930.64
long14 Sep 2025 115,918.0026 Sep 2025 108,994.0012−$6,923.80
long2 Oct 2025 118,595.0016 Oct 2025 110,763.0014−$7,831.71
long6 Jan 2026 93,859.7025 Jan 2026 89,225.3019−$4,634.37
long16 Mar 2026 72,815.3023 Mar 2026 67,859.007−$4,956.25
long24 Mar 2026 70,906.4027 Mar 2026 68,820.303−$2,086.14
long10 Apr 2026 71,788.0023 May 2026 75,539.5043$3,751.52
long16 Jul 2026 64,756.302 Aug 2026 62,823.7017−$1,932.63
long7 Aug 2026 64,323.6013 Aug 2026 63,480.006−$843.62

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 buy spot only this page—v5 strategy+1.0%162.7%
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?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 16 before, 12 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.

⋯// © sasinp-//@version=5+//@version=6strategy("EMA12/26 buy spot only", overlay=true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 7 msYes 1,000 bars in 15 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/// © sasinp//@version=5strategy("EMA12/26 buy spot only", overlay=true)longCondition = ta.crossover(ta.ema(close, 12), ta.ema(close, 26))if (longCondition)    strategy.entry("buy", strategy.long)if ta.crossunder(ta.ema(close, 12), ta.ema(close, 26))    strategy.close("buy")