Combined Supertrend entra en la dirección de la tendencia cuando el cierre diario está por encima (o por debajo) de tres líneas de tendencia diferentes a la vez. También necesita que la línea del ATR y la línea porcentual estén separadas más de 7 puntos durante dos barras. Las operaciones se cierran cuando esas dos líneas vuelven a juntarse o el precio vuelve a atravesar todas las líneas.
Mejor ejecución de 3. USD/JPY, Diario, spread 1, de la ejecución sweeps:2026-09-16-USDJPY-D-opt.tsv:2.
| Periodo | Hasta 2026-09-16 |
| Instrumento | USD/JPY, Diario |
| Spread | 1 puntos |
| Contratos | 1 |
| Capital inicial | 1,000,000 |
| Costes | Solo spread. No se incluyen comisiones ni financiación overnight. |
| Barras | Hasta 200,000 barras, menos cuando el instrumento tiene menos historial |
| Última prueba | 2026-09-16 |
| positionSize Contratos por operación | 1 |
| lookbackPeriod Ventana para la línea de tendencia del ATR | 21 |
| atrMultiplier Múltiplo del ATR para la línea de tendencia del ATR | 3 |
| pctStopFactor Distancia del supertrend porcentual, como fracción del cierre | 0.005 |
| rsqPeriod Ventana de R cuadrado para el supertrend adaptativo | 10 |
| rsqMultiplier Multiplicador del supertrend adaptativo | 2 |
| rsqCentre Valor de R cuadrado en el que la longitud adaptativa equivale a rsqPeriod | 0.25 |
| exitStFactor Multiplicador del supertrend estándar usado en las salidas | 3 |
| exitStPeriod Longitud del supertrend estándar usado en las salidas | 5 |
| minGapPoints Las líneas de tendencia deben estar separadas al menos esta distancia para operar | 7 |
| pctDirection El supertrend porcentual empieza en modo alcista | 1 |
| prevStopLong Stop long anterior del supertrend porcentual | 0 |
| prevStopShort Stop short anterior, inicializado muy alto | 1000000000000 |
Todas las ejecuciones
| Mercado | Marco temporal | PF | Operaciones | % de acierto | Neto | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYMejor ejecución | Diario | n/a | 53 | 52.83 | 1,613,780 JPY | -1,041,500 |
| EUR/USD | Diario | n/a | 25 | 60.00 | 83,943 USD | -82,640 |
| GBP/USD | Diario | n/a | 44 | 43.18 | 12,847 USD | -11,278 |
Gráficos
El código
// ============================================================ // 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 líneas más: las reglas de entrada y salida.
Configuración
Preguntas
El código se ejecuta automáticamente en ProOrder. No tiene stop loss, así que añade protección a nivel de cuenta si la operas.
USD/JPY Diario obtuvo 1,613,780 JPY en 53 operaciones, EUR/USD Diario 83,943 USD en 25 operaciones, y GBP/USD Diario 12,846.80 USD en 44 operaciones, todos con 1 contrato.
Con 1 contrato la ejecución de USD/JPY cayó 1,041,500 JPY desde el máximo y GBP/USD cayó 11,278.40 USD. Reduce el tamaño si esas cifras son demasiado grandes para tu cuenta.
La separación de 7 puntos entre las líneas y la línea del ATR de 21 barras están ajustadas para movimientos lentos. En gráficos diarios el sistema opera solo unas pocas veces al año.
Relacionado
La comunidad de ProRealAlgos obtiene las reglas completas, el código completo y la cartera automatizada.