Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Short Swing Bearish MACD Cross (By Coinrule)

A Pine Script v5 strategy built on EMA (close, 450), MACD (close, 11) and Crossunder (macdLine, signalLine). It has 2 order rules, 1 entry among them, and trades short only with the default settings. Exits use a stop loss and a profit target. Each trade commits 30% of equity and pays 0.1% 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 Short Swing Bearish MACD Cross (By Coinrule) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 7 of 7 trades.
How did Short Swing Bearish MACD Cross (By Coinrule) do on BTCUSDT 1D with default settings?
−6.93%
From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Short Swing Bearish MACD Cross (By Coinrule) run in Pine Script v6?
Yes
Same 8 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 Short Swing Bearish MACD Cross (By Coinrule) use a stop loss?
Yes
strategy.exit sets a stop on line 19.
Does Short Swing Bearish MACD Cross (By Coinrule) run in Zeal Terminal?
Yes
It compiles in 18 ms and runs 1,000 bars in 23 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 (0)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,307$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
−6.93%
−$693.05
Buy and hold
+102.5%
same period
Closed trades
8
2 won · 6 lost
Profitable
25.0%
of closed trades
Profit factor
0.41
gross profit ÷ gross loss
Max drawdown
6.93%
−$693.05

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

  • 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

  • EMAclose, 450slowEMA · line 6
  • MACDclose, 11, 26, 9macdLine · line 8
  • MACDclose, 11, 26, 9signalLine · line 8
  • MACDclose, 11, 26, 9histogramLine · line 8
  • CrossundermacdLine, signalLinegoShortCondition1 · line 10

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 datahighhighprice datalowlowprice datatimetimeprice dataslowEMAEMA→ slowEMAmacdLineMACD→ macdLinesignalLineMACD→ signalLinehistogramLineMACD→ histogramLinegoShortCondition1Crossunder→ goShortCondition1strategyDirectionstrategyDirectionvaluestopLossstopLossvaluetakeProfittakeProfitvaluegoShortCondition2goShortCondition2conditiontimePeriodtimePeriodconditionnotInTradenotInTradeconditionentry:ShortOpen Shortstrategy.entryexit:exitexit exitstrategy.exitplot:21plotplot

Order rules

OrderFires whenBy defaultLine
Open Short short(goShortCondition1 and goShortCondition2 and timePeriod and notInTrade)On18
Exit exit stop and limit(goShortCondition1 and goShortCondition2 and timePeriod and notInTrade)On19

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.

7/7trades 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−6.9%+102.5%825%0.416.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.8%+5.5%10%0.000.8%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−4.0%+9.8%1030%0.706.7%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−4.6%+8.4%30%0.004.6%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.6%+16.7%1050%1.374.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−3.1%+21.5%30%0.003.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−1.2%+148.3%540%0.803.7%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−4.4%+17.1%20%0.004.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 market250%$107.94
Sideways market20%−$323.35
Falling market425%−$477.65

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

How bad could the drawdown be?

11.5%

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

0%13%
All 8 trades
SideEntryExitBarsP&L
short18 Dec 2025 86,243.205 Jan 2026 93,980.5018−$275.14
short21 Jan 2026 88,427.7031 Jan 2026 80,864.3010$243.71
short23 Mar 2026 67,859.0013 Apr 2026 74,294.3021−$289.58
short29 Apr 2026 76,342.804 May 2026 80,577.105−$166.85
short13 May 2026 80,504.5028 May 2026 73,456.1015$244.14
short27 Jun 2026 60,097.304 Jul 2026 63,190.407−$156.49
short28 Jul 2026 63,755.9019 Aug 2026 67,096.1022−$156.63
short3 Sep 2026 77,340.003 Sep 2026 80,903.700−$136.20

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
Short Swing Bearish MACD Cross (By Coinrule) this page—v5 strategy−6.9%86.9%
MACD Trend Strategy by Zeal Terminalmacd emav5 strategy−1.0%213.5%
Fast EMA above Slow EMA with MACD (by Coinrule) by Coinruleema macdv5 strategy−4.5%187.7%
EMA and MACD with Trailing Stop Loss (by Coinrule) by Coinruleema macdv5 strategy+3.3%224.6%
RSI of MACD Strategy [Long only] by mohaneemacd emav4 strategyNo trades on this market
Macd Divergence + MTF EMA by Trading_Solutions_macd emav5 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.

  • 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 8 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

⋯// © Coinrule-//@version=5+//@version=6strategy("Shorting Bearish MACD Cross with Price Below EMA 450 (By Coinrule)", overlay=true, initial_capital = 10000, default_qty_value = 30, default_qty_type = strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.1)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 18 msYes 1,000 bars in 23 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/// © Coinrule//@version=5strategy("Shorting Bearish MACD Cross with Price Below EMA 450 (By Coinrule)", overlay=true, initial_capital = 10000, default_qty_value = 30, default_qty_type = strategy.percent_of_equity, commission_type=strategy.commission.percent, commission_value=0.1)// EMAs slowEMA = ta.ema(close, 450)// MACD[macdLine, signalLine, histogramLine] = ta.macd(close, 11, 26, 9)// ConditionsgoShortCondition1 = ta.crossunder(macdLine, signalLine)goShortCondition2 = slowEMA > closetimePeriod = time >= timestamp(syminfo.timezone, 2021, 12, 1, 0, 0)notInTrade = strategy.position_size <= 0strategyDirection = strategy.direction.shortif (goShortCondition1 and goShortCondition2 and timePeriod and notInTrade)    stopLoss = high * 1.04    takeProfit = low * 0.92    strategy.entry("Short", strategy.short)    strategy.exit("exit","Short", stop=stopLoss, limit=takeProfit)    plot(slowEMA, color=color.green)