Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Short Selling EMA Cross (By Coinrule)

A Pine Script v5 strategy built on EMA (close, 20) and Crossunder (fastEMA, slowEMA). 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 Selling EMA Cross (By Coinrule) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did Short Selling EMA Cross (By Coinrule) do on BTCUSDT 1D with default settings?
+5.27%
From 26 Jan 2024 to 21 Oct 2026, over 6 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Short Selling EMA Cross (By Coinrule) run in Pine Script v6?
Yes
Same 6 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 Selling EMA Cross (By Coinrule) use a stop loss?
Yes
strategy.exit sets a stop on line 17.
Does Short Selling EMA Cross (By Coinrule) run in Zeal Terminal?
Yes
It compiles in 9 ms and runs 1,000 bars in 32 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 (0)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$10,527$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
+5.27%
$526.84
Buy and hold
+102.5%
same period
Closed trades
6
5 won · 1 lost
Profitable
83.3%
of closed trades
Profit factor
1.68
gross profit ÷ gross loss
Max drawdown
10.00%
−$1,022.31

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, 20fastEMA · line 6
  • EMAclose, 50slowEMA · line 7
  • CrossunderfastEMA, slowEMAgoShortCondition1 · line 9

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 datafastEMAEMA→ fastEMAslowEMAEMA→ slowEMAgoShortCondition1Crossunder→ goShortCondition1strategyDirectionstrategyDirectionvaluestopLossstopLossvaluetakeProfittakeProfitvaluetimePeriodtimePeriodconditionnotInTradenotInTradeconditionentry:shortOpen shortstrategy.entryexit:exitexit exitstrategy.exitplot:19plotplotplot:20plotplot

Order rules

OrderFires whenBy defaultLine
Open short short(goShortCondition1 and timePeriod and notInTrade)On16
Exit exit stop and limit(goShortCondition1 and timePeriod and notInTrade)On17

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.

2/2trades 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+5.3%+102.5%683%1.6810.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−5.3%+5.5%10%0.008.6%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+12.1%+9.8%786%2.6510.4%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−9.8%+8.4%30%0.0014.4%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.6%+16.7%1070%1.2111.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−11.6%+21.5%425%0.1513.9%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+9.3%+148.3%683%2.475.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−2.2%+17.1%367%0.7010.9%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 market1100%$221.00
Sideways market475%$54.62
Falling market1100%$251.22

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

How bad could the drawdown be?

7.6%

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

0%9%
All 6 trades
SideEntryExitBarsP&L
short4 May 2024 62,882.004 Jul 2024 58,124.1061$221.00
short6 Aug 2024 54,018.8015 Oct 2024 67,634.5070−$779.00
short18 Feb 2025 95,780.0025 Feb 2025 87,588.607$236.59
short30 Aug 2025 108,377.0014 Nov 2025 95,246.0076$346.01
short21 Jan 2026 88,427.7031 Jan 2026 80,864.3010$251.22
short1 Jun 2026 73,674.402 Jun 2026 67,528.001$251.02

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 Selling EMA Cross (By Coinrule) this page—v5 strategy+5.3%610.0%
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 6 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("Short Selling EMA Cross (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 9 msYes 1,000 bars in 32 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("Short Selling EMA Cross (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 fastEMA = ta.ema(close, 20)slowEMA = ta.ema(close, 50)// ConditionsgoShortCondition1 = ta.crossunder(fastEMA, slowEMA)timePeriod = time >= timestamp(syminfo.timezone, 2021, 12, 1, 0, 0)notInTrade = strategy.position_size <= 0strategyDirection = strategy.direction.shortif (goShortCondition1 and timePeriod and notInTrade)    stopLoss = high * 1.16    takeProfit = low * 0.92    strategy.entry("short", strategy.short)    strategy.exit("exit","short", stop=stopLoss, limit=takeProfit)    plot(fastEMA, color=color.blue)plot(slowEMA, color=color.yellow)