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.
Best run of 3. USD/JPY, Daily, spread 1, from run sweeps:2026-09-16-USDJPY-D-opt.tsv:2.
| Period | Up to 2026-09-16 |
| Instrument | USD/JPY, Daily |
| Spread | 1 points |
| Contracts | 1 |
| Starting capital | 1,000,000 |
| Costs | Spread only. Commissions and overnight financing are not included. |
| Bars | Up to 200,000 bars, fewer where the instrument has less history |
| Last tested | 2026-09-16 |
| 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
| Market | Timeframe | PF | Trades | Win % | Net | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYBest run | Daily | n/a | 53 | 52.83 | 1,613,780 JPY | -1,041,500 |
| EUR/USD | Daily | n/a | 25 | 60.00 | 83,943 USD | -82,640 |
| GBP/USD | Daily | n/a | 44 | 43.18 | 12,847 USD | -11,278 |
Charts
The code
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
Questions
The code runs automatically in ProOrder. It has no stop loss, so add account-level protection if you trade it.
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.
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.
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
The ProRealAlgos community gets the full rules, the complete code and the automated portfolio.