Join today
Strategies / Trend / X-Bars Regression Slope

X-Bars Regression Slope

When the 28-bar linear regression slope was positive on the previous bar, it places a buy limit at the 12-period SMA of lows. A negative slope sets a short limit at the SMA of highs. Once the slope flips, the position exits with a limit at the opposite average.

TrendLong & shortIntradayEUR/USD10 min
n/aProfit factor
93,957Net profit USD
46.86%Win rate
7,224Trades
-51,230Max drawdown
13.01Avg trade

Best run of 6. EUR/USD, 10 min, spread 1, from run sweeps:2026-09-17-EURUSD-10m-opt.tsv:3.

Entry rules, long

  1. The 28-bar linear regression slope of TotalPrice was positive on the previous bar
  2. Members only

Entry rules, short

  1. The slope was negative on the previous bar
  2. Members only

Exit rules

  1. Members only
  2. Close a short with a limit at the SMA of lows once the slope turns positive
  3. No stop loss

Test conditions

PeriodUp to 2026-09-17
InstrumentEUR/USD, 10 minutes
Spread1 points
Contracts1
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-09-17

Parameters

positionSize
Shares per trade
1
bandPeriod
SMA length of highs and lows
12
slopePeriod
Regression slope length
28

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
EUR/USDBest run10 minn/a 7,22446.8693,957 USD-51,230
EUR/USD2 minn/a 7,05638.39402,648 USD-89,492
EUR/USD3 minn/a 7,07240.75281,741 USD-66,463
EUR/USD5 minn/a 7,13643.53120,196 USD-81,556
Brent CrudeDailyn/a 16350.9230,683 EUR-6,617
US Crude OilDailyn/a 37446.5212,008 EUR-10,126

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-100K-50K250K500KEUR/USD · 2 minEUR/USD · 3 minEUR/USD · 5 minEUR/USD · 10 minBrent Crude · DailyUS Crude Oil · Daily

The code

ProBuilder, rewritten to house standard

Every file in the library uses the same header, the same section order and the same variable names. The numbers above were produced by the original version before the rewrite, and the rewrite has not yet been compiled in ProRealTime.

// ============================================================
// X-Bars Regression Slope
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: 10 minutes
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false

// --- Parameters ---
positionSize = 1          // shares per trade
bandPeriod = 12           // SMA length of the highs and of the lows
slopePeriod = 28          // regression slope length on TotalPrice

// --- Indicators ---
upperBand = Average[bandPeriod](high)
lowerBand = Average[bandPeriod](low)
regressionSlope = LinearRegressionSlope[slopePeriod](TotalPrice)

24 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • There is no stop loss. The best run on EUR/USD 10 minutes drew down USD 51,230 against USD 93,957 net profit.
  • Profit factor was not recorded, since all results come from parameter sweeps.
  • Limit orders are re-placed every bar, so live fills may differ from the backtest, especially on 2 and 3 minute charts.
  • Testing covered only EUR/USD, Brent Crude and US Crude Oil.

Indicators used

SMALinear Regression

How to load it

  1. Copy the code with the copy button above 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.

Questions

About this strategy

Can this run in ProOrder?

Yes, ProOrder supports limit orders re-placed each bar. The rewritten code was not compile-checked, so backtest it first.

Which markets were tested?

EUR/USD on several intraday charts plus Brent Crude and US Crude Oil daily. All 5 listed runs were positive, with EUR/USD 2 minutes making USD 402,648 in a sweep.

What drawdown came with 1 contract?

The EUR/USD 10 minute best run had a max drawdown of USD 51,230 at position size 1.

Why a 10 minute chart?

It gave the best recorded run. The shorter EUR/USD charts made more but with drawdowns up to USD 89,492.

Related

Strategies like this one

Bollinger Squeeze

Uses the same indicator.

14.30 PF · 86 trades

Slow MACD Slope

Best run on the same market, EUR/USD.

6.80 PF · 7,305 trades

Long-Term Moving Average Cross

Also a trend strategy.

12.31 PF · 61 trades

Regression-based trend systems are part of our research. Join the ProRealAlgos waitlist to follow it.

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