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
- 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, 450
slowEMA · line 6 - MACDclose, 11, 26, 9
macdLine · line 8 - MACDclose, 11, 26, 9
signalLine · line 8 - MACDclose, 11, 26, 9
histogramLine · line 8 - CrossundermacdLine, signalLine
goShortCondition1 · 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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Short short | (goShortCondition1 and goShortCondition2 and timePeriod and notInTrade) | On | 18 |
| Exit exit stop and limit | (goShortCondition1 and goShortCondition2 and timePeriod and notInTrade) | On | 19 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −6.9% | +102.5% | 8 | 25% | 0.41 | 6.9% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −0.8% | +5.5% | 1 | 0% | 0.00 | 0.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −4.0% | +9.8% | 10 | 30% | 0.70 | 6.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −4.6% | +8.4% | 3 | 0% | 0.00 | 4.6% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +3.6% | +16.7% | 10 | 50% | 1.37 | 4.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −3.1% | +21.5% | 3 | 0% | 0.00 | 3.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −1.2% | +148.3% | 5 | 40% | 0.80 | 3.7% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −4.4% | +17.1% | 2 | 0% | 0.00 | 4.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 2 | 50% | $107.94 |
| Sideways market | 2 | 0% | −$323.35 |
| Falling market | 4 | 25% | −$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.
All 8 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| short | 18 Dec 2025 86,243.20 | 5 Jan 2026 93,980.50 | 18 | −$275.14 |
| short | 21 Jan 2026 88,427.70 | 31 Jan 2026 80,864.30 | 10 | $243.71 |
| short | 23 Mar 2026 67,859.00 | 13 Apr 2026 74,294.30 | 21 | −$289.58 |
| short | 29 Apr 2026 76,342.80 | 4 May 2026 80,577.10 | 5 | −$166.85 |
| short | 13 May 2026 80,504.50 | 28 May 2026 73,456.10 | 15 | $244.14 |
| short | 27 Jun 2026 60,097.30 | 4 Jul 2026 63,190.40 | 7 | −$156.49 |
| short | 28 Jul 2026 63,755.90 | 19 Aug 2026 67,096.10 | 22 | −$156.63 |
| short | 3 Sep 2026 77,340.00 | 3 Sep 2026 80,903.70 | 0 | −$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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Short Swing Bearish MACD Cross (By Coinrule) this page | — | v5 strategy | −6.9% | 8 | 6.9% |
| MACD Trend Strategy by Zeal Terminal | macd ema | v5 strategy | −1.0% | 21 | 3.5% |
| Fast EMA above Slow EMA with MACD (by Coinrule) by Coinrule | ema macd | v5 strategy | −4.5% | 18 | 7.7% |
| EMA and MACD with Trailing Stop Loss (by Coinrule) by Coinrule | ema macd | v5 strategy | +3.3% | 22 | 4.6% |
| RSI of MACD Strategy [Long only] by mohanee | macd ema | v4 strategy | No trades on this market | ||
| Macd Divergence + MTF EMA by Trading_Solutions_ | macd ema | v5 strategy | No 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
VerifiedNothing 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.
⋯// © 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 18 ms | Yes 1,000 bars in 23 ms | Not measured |
| PineTS | Not tested | Not tested | Not 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)