Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

MA Cross Strategy

A Pine Script v5 strategy built on SMA (close, 10). It has 3 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays 0.05% commission. 3 settings; defaults include Fast 10 and Slow 30.

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 MA Cross Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
How did MA Cross Strategy do on BTCUSDT 1D with default settings?
−439.77%
From 26 Jan 2024 to 21 Oct 2026, over 40 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does MA Cross 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: 40 before, 41 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 MA Cross Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does MA Cross Strategy run in Zeal Terminal?
Yes
It compiles in 10 ms and runs 1,000 bars in 20 ms, in the browser.

BTCUSDT · 1D · default settings

  • Fast
  • Slow
  • 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$-36,441$20,253Equity from $10,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
−439.77%
−$43,977.50
Buy and hold
+102.5%
same period
Closed trades
40
10 won · 30 lost
Profitable
25.0%
of closed trades
Profit factor
0.74
gross profit ÷ gross loss
Max drawdown
541.19%
−$54,119.30

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short 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.

Settings

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

SettingDefaultType and rangeFeeds
Fast10int · min 1maFast
Slow30int · min 1maSlow
Trade the short sidetrueboolentry Short close Long line 24

What it calculates

  • SMAclose, Fast (10)maFast · line 14
  • SMAclose, Slow (30)maSlow · line 15

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 datafastFastsetting · 10slowSlowsetting · 30maFastSMA→ maFastmaSlowSMA→ maSlowentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:LongClose Longstrategy.closeplot:17Fastplotplot:18Slowplot

Order rules

OrderFires whenBy defaultLine
Open Long longta.crossover(maFast, maSlow)On21
Open Short shortallowShortsOn “Trade the short side”25
Close LongallowShortsOn “Trade the short side”27

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.

11/11trades 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−439.8%+102.5%4025%0.74541.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−97.2%+5.5%3931%0.78104.9%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+14.2%+9.8%3636%1.2419.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+0.2%+8.4%4030%1.016.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+0.8%+16.7%3444%1.251.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.4%+21.5%3540%1.790.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.5%+148.3%3622%0.969.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.5%+17.1%4337%0.871.4%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 market1217%−$31,175.90
Sideways market1828%−$9,554.08
Falling market1030%−$3,206.38

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

How bad could the drawdown be?

22,987.6%

The 95th percentile of the worst drawdown when the same 40 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 105.3% to 22,987.6%; the tick is what actually happened, 501.6%. Order luck alone moves it this much.

0%26,436%
All 40 trades
SideEntryExitBarsP&L
short17 Apr 2024 63,793.4019 May 2024 66,915.2032−$3,187.17
long19 May 2024 66,915.2016 Jun 2024 66,228.2028−$753.54
short16 Jun 2024 66,228.2020 Jul 2024 66,660.0034−$498.22
long20 Jul 2024 66,660.007 Aug 2024 56,022.0018−$10,699.40
short7 Aug 2024 56,022.0027 Aug 2024 62,834.0020−$6,871.45
long27 Aug 2024 62,834.005 Sep 2024 57,970.909−$4,923.52
short5 Sep 2024 57,970.9020 Sep 2024 62,948.0015−$5,037.58
long20 Sep 2024 62,948.0010 Oct 2024 60,636.0020−$2,373.80
short10 Oct 2024 60,636.0016 Oct 2024 67,074.106−$6,502.01
long16 Oct 2024 67,074.1027 Dec 2024 95,791.6072$28,636.00
short27 Dec 2024 95,791.6018 Jan 2025 104,077.0022−$8,385.82
long18 Jan 2025 104,077.008 Feb 2025 96,506.8021−$7,670.98
short8 Feb 2025 96,506.8028 Mar 2025 87,232.0048$9,182.90
long28 Mar 2025 87,232.004 Apr 2025 83,213.107−$4,104.16
short4 Apr 2025 83,213.1019 Apr 2025 84,474.7015−$1,345.47
long19 Apr 2025 84,474.707 Jun 2025 104,288.0049$19,719.30
short7 Jun 2025 104,288.0016 Jun 2025 105,594.009−$1,410.55
long16 Jun 2025 105,594.0020 Jun 2025 104,659.004−$1,040.58
short20 Jun 2025 104,659.001 Jul 2025 107,147.0011−$2,593.84
long1 Jul 2025 107,147.005 Aug 2025 115,055.0035$7,797.40
short5 Aug 2025 115,055.0014 Aug 2025 123,306.009−$8,370.61
long14 Aug 2025 123,306.0023 Aug 2025 116,936.009−$6,490.58
short23 Aug 2025 116,936.0015 Sep 2025 115,268.0023$1,551.87
long15 Sep 2025 115,268.0029 Sep 2025 112,164.0014−$3,217.79
short29 Sep 2025 112,164.004 Oct 2025 122,232.005−$10,185.50
long4 Oct 2025 122,232.0017 Oct 2025 108,194.0013−$14,153.20
short17 Oct 2025 108,194.0012 Dec 2025 92,513.4056$15,580.50
long12 Dec 2025 92,513.4019 Dec 2025 85,516.407−$7,086.00
short19 Dec 2025 85,516.406 Jan 2026 93,859.7018−$8,433.01
long6 Jan 2026 93,859.7026 Jan 2026 86,670.4020−$7,279.64
short26 Jan 2026 86,670.407 Mar 2026 68,114.0040$18,478.90
long7 Mar 2026 68,114.0029 Mar 2026 66,377.0022−$1,804.25
short29 Mar 2026 66,377.0012 Apr 2026 73,043.2014−$6,735.85
long12 Apr 2026 73,043.2022 May 2026 77,615.5040$4,497.01
short22 May 2026 77,615.5011 Jul 2026 64,161.7050$13,382.90
long11 Jul 2026 64,161.703 Aug 2026 63,570.0023−$655.60
short3 Aug 2026 63,570.0021 Aug 2026 73,027.0018−$9,525.33
long21 Aug 2026 73,027.0018 Sep 2026 76,417.0028$3,315.25
short18 Sep 2026 76,417.0022 Sep 2026 86,620.004−$10,284.50
long22 Sep 2026 86,620.0016 Oct 2026 82,245.9024−$4,458.53

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
MA Cross Strategy this page—v5 strategy−439.8%40541.2%
Follow the Crypto Shorts by xtradernetsmav4 strategyNo trades on this market
buy down and sell high trend 200 sma and ma cross by willi130503smav4 strategyNo trades on this market
Mayer Multiple Strategy by xtradernetsmav4 strategyNo trades on this market
Moving Average Cross Strategy early Closing by Geduldtradersmav4 strategy+73.8%20151.5%
MFI Simple Strategy by OztheWozsmav5 strategy−0.2%283.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: 40 before, 41 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.

⋯// © Zeal Terminal-//@version=5+//@version=6strategy("MA Cross Strategy", overlay = true, initial_capital = 10000,⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 10 msYes 1,000 bars in 20 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

Written by Zeal Terminal and published under the Mozilla Public License 2.0.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Zeal Terminal//@version=5strategy("MA Cross Strategy", overlay = true, initial_capital = 10000,     commission_type = strategy.commission.percent, commission_value = 0.05,     slippage = 1) // Not investment advice. fast = input.int(10, "Fast", minval = 1)slow = input.int(30, "Slow", minval = 1)allowShorts = input.bool(true, "Trade the short side") maFast = ta.sma(close, fast)maSlow = ta.sma(close, slow) plot(maFast, "Fast", color = color.aqua)plot(maSlow, "Slow", color = color.orange) if ta.crossover(maFast, maSlow)    strategy.entry("Long", strategy.long) if ta.crossunder(maFast, maSlow)    if allowShorts        strategy.entry("Short", strategy.short)    else        strategy.close("Long")