Join waitlist
Strategies / Trend / EMA 12 21 Trend Crossover

EMA 12 21 Trend Crossover

Buys when the 12-period EMA crosses above the 21-period EMA and sells short when it crosses below. Each cross reverses any open position, so the system stays in the market after its first signal.

TrendLong & shortSwingUSD/JPYDaily
1.59Profit factor
3,435,460Net profit USD
33.40%Win rate
503Trades
-433,100Max drawdown
6,830Avg trade

Best run of 11. USD/JPY, Daily, spread 1, from run pf:2026-10-12-USDJPY-D.tsv:39.

Entry rules, long

  1. Signals are only considered after bar 21.

Entry rules, short

  1. Signals are only considered after bar 21.

Exit rules

  1. A long closes while the 12-period EMA is below the 21-period EMA, and a short closes while it is at or above.
  2. No stop loss or profit target is set.

Test conditions

PeriodUp to 2026-10-12
InstrumentUSD/JPY, Daily
Spread1 points
Starting capital1,000,000
CostsSpread only. Commissions and overnight financing are not included.
BarsUp to 200,000 bars, fewer where the instrument has less history
Last tested2026-10-12

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest runDaily1.59 50333.403,435,460 USD-433,100
GoldDaily1.55 51731.723,460 EUR-809
USD/JPY1 hourn/a 5,20930.041,051,280 USD-298,730
USD/JPY30 minn/a 7,47729.06468,660 USD-258,680
EUR/USDDailyn/a 45735.23178,398 USD-48,505
Nikkei 225Dailyn/a 43231.0229,614 USD-21,264
Nasdaq 100Dailyn/a 42429.9515,714 EUR-5,664
Brent CrudeDailyn/a 19730.4615,137 EUR-13,430
US Crude Oil4 hoursn/a 90131.1911,913 EUR-6,177
Gold4 hoursn/a 1,13831.723,310 EUR-943
Gold1 hourn/a 4,54228.602,339 EUR-1,249

Charts

Results by run

Top 10 of 11 runs. The full list is in the table above.

Above 1.0 made money, below 1.0 lost money.

The code

ProBuilder code, as tested

// ==============================================================
// EMA 12 21 Trend Crossover
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: Daily
// ==============================================================

DEFPARAM CumulateOrders = false

emafast = ExponentialAverage[12](close)
emaslow = ExponentialAverage[21](close)

16 more lines: the entry and exit rules.

Setup

How to load it

  1. Copy the code with the copy button on the code block.
  2. In ProRealTime, open a chart of the instrument and timeframe you want to test, then open ProOrder > New trading system and choose "Create with programming".
  3. Paste the code, give the system a name and save it.
  4. Click "Backtest", set your own spread and position size, and run it before you consider trading it live.

Indicators used

EMA
Read this firstKnown weaknesses2 points
  • Results include the spread only. Commissions and overnight financing are not included.
  • The code is published as it was backtested and has not been compiled again since.

Questions

About this strategy

Can I run EMA 12 21 Trend Crossover in ProOrder?

Yes. The code is ProBuilder and runs as an automated ProOrder system. Backtest it on your own account with your own spread and position size before trading it live.

Which markets was it tested on?

It was tested on 11 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 1.59 over 503 trades.

How large was the drawdown?

The best run had a maximum drawdown of 433,100 USD at the tested position size, against a net result of 3,435,460 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Reversal Pattern With Chaikin Volatility

Uses the same indicator.

2.26 PF · 6,872 trades

Trend Surfer

Best run on the same market, USD/JPY.

1.04 PF · 10,813 trades

Ichimoku Cloud Confluence

Also a trend strategy.

1.59 PF · 302 trades

Put your name on the ProRealAlgos waitlist to trade a tested portfolio instead of single strategies.

The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.

Past backtest results do not guarantee future results. This is not financial advice. Curated and maintained by ProRealAlgos. ProRealTime™ is a trademark of ProRealTime SAS. prorealalgos.comStatsDocs