Join waitlist
Strategies / Trend / SMA 20 Price Flip System

SMA 20 Price Flip System

The system buys 1 contract when the close is above its 20-period SMA and sells short when it is below. It closes the position when price crosses back through the average, then takes the opposite side on the following bar.

TrendLong & shortSwingUSD/JPYDaily
1.39Profit factor
3,385,830Net profit USD
27.98%Win rate
1,240Trades
-428,370Max drawdown
2,731Avg trade

Best run of 3. USD/JPY, Daily, spread 1, from run pf:2026-10-05-USDJPY-D.tsv:4.

Entry rules, long

  1. When flat, buy 1 contract at market if the close is above the 20-period SMA.

Entry rules, short

  1. When flat, sell short 1 contract at market if the close is at or below the 20-period SMA.

Exit rules

  1. A short closes at market when the close rises above the 20-period SMA.
  2. The opposite position is opened on the following bar once the trade is flat.

Test conditions

PeriodUp to 2026-10-05
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-05

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest runDaily1.39 1,24027.983,385,830 USD-428,370
SilverDailyn/a 1,13228.1832,312 USD-28,236
Nikkei 225Dailyn/a 1,04330.1131,511 USD-17,978

Charts

Results by run

Net profitMax drawdown

The code

ProBuilder code, as tested

// ==============================================================
// SMA 20 Price Flip System
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: Daily
// ==============================================================

DEFPARAM CumulateOrders = false

sma = Average[20](close)

17 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

SMA
Read this firstKnown weaknesses2 points
  • The code sets no stop loss, so a losing trade stays open until an exit signal arrives.
  • Results include the spread only. Commissions and overnight financing are not included.

Questions

About this strategy

Can I run SMA 20 Price Flip System 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 3 market and timeframe combinations. The best run was USD/JPY, Daily, with a profit factor of 1.39 over 1,240 trades.

How large was the drawdown?

The best run had a maximum drawdown of 428,370 USD at the tested position size, against a net result of 3,385,830 USD.

Does it trade long, short or both?

It trades both long and short.

Related

Strategies like this one

Trend Surfer

Uses the same indicator.

1.04 PF · 10,813 trades

EMA 8 21 RSI Filtered Bracket

Best run on the same market, USD/JPY.

1.09 PF · 6,194 trades

Dual MA Long Trend

Also a trend strategy.

1.39 PF · 241 trades

Get the full rules, the complete code and the ProRealAlgos portfolio as a member.

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