Join today
Strategies / Trend / Combined Supertrend

Combined Supertrend: Daily Trend Filter With Three Lines

Combined Supertrend enters in the trend direction when the daily close is above (or below) three different trend lines at once. It also needs the ATR line and the percentage line to be more than 7 points apart for two bars. Trades close when those two lines come back together or price crosses back through all the lines.

TrendLong & shortSwingUSD/JPYDaily
n/aProfit factor
1,613,780Net profit JPY
52.83%Win rate
53Trades
-1,041,500Max drawdown
30,449Avg trade

Best run of 3. USD/JPY, Daily, spread 1, from run sweeps:2026-09-16-USDJPY-D-opt.tsv:2.

Entry rules, long

  1. Members only
  2. The ATR line and the percentage line are more than 7 points apart on this bar and the previous bar
  3. No position is open

Entry rules, short

  1. Members only
  2. The ATR line and the percentage line are more than 7 points apart on this bar and the previous bar
  3. No position is open

Exit rules

  1. Members only
  2. Close a long when price closes below all three lines and the standard SuperTrend(3,5) on two bars in a row
  3. Close a short when price closes above all four lines, with a previous-bar check that mixes above and below (as tested)
  4. No stop loss or target

Test conditions

PeriodUp to 2026-09-16
InstrumentUSD/JPY, Daily
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-16

Parameters

positionSize
Contracts per trade
1
lookbackPeriod
Window for the ATR trend line
21
atrMultiplier
ATR multiple for the ATR trend line
3
pctStopFactor
Percentage supertrend distance, as a fraction of close
0.005
rsqPeriod
R-squared window for the adaptive supertrend
10
rsqMultiplier
Multiplier of the adaptive supertrend
2
rsqCentre
R-squared value where the adaptive length equals rsqPeriod
0.25
exitStFactor
Multiplier of the standard supertrend used in exits
3
exitStPeriod
Length of the standard supertrend used in exits
5
minGapPoints
Trend lines must be at least this far apart to trade
7
pctDirection
Percentage supertrend starts in up mode
1
prevStopLong
Previous long stop of the percentage supertrend
0
prevStopShort
Previous short stop, seeded very high
1000000000000

Every run

Markets and timeframes tested

MarketTimeframePFTradesWin %NetMax DD
USD/JPYBest runDailyn/a 5352.831,613,780 JPY-1,041,500
EUR/USDDailyn/a 2560.0083,943 USD-82,640
GBP/USDDailyn/a 4443.1812,847 USD-11,278

Charts

Results by run

Net profit against max drawdown

Net profitMax drawdown
0-2.0M-1.0M1.0M2.0MUSD/JPY · DailyEUR/USD · DailyGBP/USD · 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.

// ============================================================
// Combined Supertrend
// ProRealAlgos Strategy Library  |  prorealalgos.com
// Type: Trend
// Direction: Long & short
// Timeframe tested: Daily
// ============================================================

// --- Settings ---
DEFPARAM CumulateOrders = false
DEFPARAM PreloadBars = 10000

// --- Parameters ---
positionSize = 1              // contracts per trade
lookbackPeriod = 21           // window for the ATR trend line
atrMultiplier = 3             // ATR multiple for the ATR trend line
pctStopFactor = 0.005         // percentage supertrend distance, as a fraction of close
rsqPeriod = 10                // r-squared window for the adaptive supertrend
rsqMultiplier = 2             // multiplier of the adaptive supertrend
rsqCentre = 0.25              // r-squared value where the adaptive length equals rsqPeriod
exitStFactor = 3              // multiplier of the standard supertrend used in exits
exitStPeriod = 5              // length of the standard supertrend used in exits
minGapPoints = 7              // trend lines must be at least this far apart to trade

ONCE pctDirection = 1                 // percentage supertrend starts in up mode
ONCE prevStopLong = 0                 // previous long stop of the percentage supertrend
ONCE prevStopShort = 1000000000000    // previous short stop, seeded very high

// --- Indicators ---
// Line one: ATR trend line, the channel extreme minus or plus a weighted ATR band.
weightedAtr = WeightedAverage[lookbackPeriod](AverageTrueRange[1](close))
recentHigh = Highest[lookbackPeriod](high)
recentLow = Lowest[lookbackPeriod](low)
upperLimit = recentHigh[1]-(weightedAtr[1]*atrMultiplier)
lowerLimit = recentLow[1]+(weightedAtr[1]*atrMultiplier)

IF (close > upperLimit AND close > lowerLimit) THEN
  atrTrendLine = upperLimit
ELSIF (close < lowerLimit AND close < upperLimit) THEN
  atrTrendLine = lowerLimit
ELSE
  atrTrendLine = atrTrendLine[1]
ENDIF

// Line two: simplified percentage supertrend around the median price.
pctDistance = close * pctStopFactor
pctStopLong = MedianPrice - pctDistance
pctStopShort = MedianPrice + pctDistance

IF pctDirection = 1 AND pctStopLong < prevStopLong THEN
  pctStopLong = prevStopLong
ENDIF
IF pctDirection = -1 AND pctStopShort > prevStopShort THEN
  pctStopShort = prevStopShort
ENDIF
IF pctDirection = 1 AND close < pctStopLong THEN
  pctDirection = -1
ENDIF
IF pctDirection = -1 AND close > pctStopShort THEN
  pctDirection = 1
ENDIF

prevStopLong = pctStopLong
prevStopShort = pctStopShort

IF pctDirection = 1 THEN
  pctTrendLine = pctStopLong
ELSE
  pctTrendLine = pctStopShort
ENDIF

// Line three: supertrend whose length adapts to the r-squared of recent closes.
sourcePrice = CustomClose
sumX = 0
sumXX = 0
sumXY = 0
sumYY = 0
sumY = 0

IF BarIndex > rsqPeriod THEN
  FOR k = 0 TO rsqPeriod-1 DO
    barPrice = sourcePrice[k]
    sumX = sumX+(k+1)
    sumXX = sumXX+((k+1)*(k+1))
    sumXY = sumXY+((k+1)*barPrice)
    sumYY = sumYY+(barPrice*barPrice)
    sumY = sumY+barPrice
  NEXT

  covarianceXY = sumXY - sumX*sumY/rsqPeriod
  varianceX = sumXX - sumX*sumX/rsqPeriod
  varianceY = sumYY - sumY*sumY/rsqPeriod

  rSquared = ((covarianceXY*covarianceXY)/(varianceX*varianceY))
  adaptiveSt = Supertrend[rsqMultiplier,round(rsqPeriod+rsqPeriod*(rSquared-rsqCentre))]
ENDIF

exitSt = Supertrend[exitStFactor,exitStPeriod]
gapMargin = minGapPoints*PointSize

28 more lines: the entry and exit rules.

Read this first

Known weaknesses

  • Only 3 markets were tested, all daily forex, and the best run on USD/JPY has 53 trades.
  • Drawdowns are large relative to profit: 1,041,500 JPY of drawdown against 1,613,780 JPY of profit on USD/JPY, and 82,640 USD against 83,943 USD on EUR/USD.
  • There is no stop loss or target. The short exit keeps an asymmetric previous-bar check from the tested version.
  • Profit factor was not recorded because only sweep data exists.

Indicators used

SuperTrendATRLinear 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

Is it ready for ProOrder?

The code runs automatically in ProOrder. It has no stop loss, so add account-level protection if you trade it.

How did it do on each pair?

USD/JPY Daily made 1,613,780 JPY over 53 trades, EUR/USD Daily 83,943 USD over 25 trades, and GBP/USD Daily 12,846.80 USD over 44 trades, all at 1 contract.

What drawdown should I expect?

At 1 contract the USD/JPY run fell 1,041,500 JPY from peak and GBP/USD fell 11,278.40 USD. Size down if those numbers are too large for your account.

Why daily bars?

The 7 point gap between the lines and the 21-bar ATR line are tuned for slow moves. On daily charts the system trades only a few times a year.

Related

Strategies like this one

ATR Band

Uses the same indicator.

10.31 PF · 53 trades

Supertrend Counter Trend

Best run on the same market, USD/JPY.

3.47 PF · 1,444 trades

Long-Term Moving Average Cross

Also a trend strategy.

12.31 PF · 61 trades

See how trend systems are combined into portfolios. Join the ProRealAlgos waitlist.

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