Un sommet fractal démarre une ligne de tendance descendante, et une cassure en deux étapes de cette ligne arme un buy stop 0.3 ATR(7) au-dessus du plus haut récent. Les sorties utilisent une bande exponentielle et le RSI(2), fermant les longs dès que le RSI est à 85 ou plus et que le prix est repassé sous la bande supérieure. Les shorts suivent la logique en miroir.
Meilleure exécution sur 8. USD/JPY, 4 heures, spread 1, d'après l'exécution sweeps:2026-09-17-USDJPY-4h-opt.tsv:2.
| Période | Jusqu'au 2026-09-17 |
| Instrument | USD/JPY, 4 heures |
| Spread | 1 points |
| Contrats | 1 |
| Capital de départ | 1,000,000 |
| Coûts | Spread uniquement. Les commissions et le financement overnight ne sont pas inclus. |
| Barres | Jusqu'à 200,000 barres, moins lorsque l'instrument a moins d'historique |
| Dernier test | 2026-09-17 |
| positionSize Contrats par trade | 1 |
| fractalBars Bars que le centre du fractal à 5 bars doit dépasser (structurel, garder à 4) | 4 |
| breakoutBars Bars utilisés pour le plus haut ou plus bas du breakout | 2 |
| atrPeriod Période de l'ATR pour la marge d'entrée | 7 |
| atrMultiplier Marge d'entrée au-delà du niveau de breakout, en ATR | 0.3 |
| bandPeriod Longueur des bandes exponentielles de log-prix | 34 |
| seedPeriod Période de la SMA utilisée pour initialiser les bandes sur les premiers bars | 3 |
| bandWidth Largeur des bandes en écarts-types | 1.618 |
| rsiPeriod Période du RSI pour la sortie | 2 |
| overboughtLevel Niveau de RSI requis pour une sortie de long | 85 |
| oversoldLevel Niveau de RSI requis pour une sortie de short | 15 |
| lookbackPeriod Fenêtre pour le plus haut et le plus bas de swing précédents | 100 |
Chaque exécution
| Marché | Unité de temps | PF | Trades | % de réussite | Net | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYMeilleure exécution | 4 heures | n/a | 819 | 53.36 | 161,440 JPY | -93,910 |
| USD/JPY | Journalier | n/a | 300 | 59.00 | 754,540 JPY | -174,840 |
| Nikkei 225 | Journalier | n/a | 262 | 61.07 | 20,201 USD | -12,694 |
| Argent | Journalier | n/a | 255 | 50.59 | 8,055 USD | -2,895 |
| Pétrole Brent | Journalier | n/a | 119 | 60.50 | 4,755 EUR | -4,645 |
| GBP/USD | Journalier | n/a | 334 | 59.88 | 3,432 USD | -2,003 |
| FTSE 100 | Journalier | n/a | 297 | 54.55 | 2,325 EUR | -948 |
| Or | Journalier | n/a | 287 | 55.05 | 624 EUR | -317 |
Graphiques
Le code
// ============================================================ // Trend Breakout // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long & short // Timeframe tested: 4 hours // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false // --- Parameters --- positionSize = 1 // contracts per trade fractalBars = 4 // bars the centre of the 5-bar fractal must beat, keep at 4 breakoutBars = 2 // bars for the breakout high / low atrPeriod = 7 // ATR length for the entry buffer atrMultiplier = 0.3 // entry buffer beyond the breakout level, in ATRs bandPeriod = 34 // length of the log-price exponential bands seedPeriod = 3 // SMA used to seed the bands on early bars bandWidth = 1.618 // band width in standard deviations rsiPeriod = 2 // RSI length for the exit overboughtLevel = 85 // long exit needs RSI at or above this oversoldLevel = 15 // short exit needs RSI at or below this lookbackPeriod = 100 // window for the prior swing high / low // State, seeded so every value is defined on the first bar. ONCE fractalHighCount = 0 ONCE fractalLowCount = 0 ONCE trendBreak = 0 ONCE bearSetup = 0 ONCE bullSetup = 0 ONCE fractalHigh = 0 ONCE fractalLow = 0 ONCE fractalBar = 0 ONCE trendHeight = 0 ONCE closeHeight = 0 ONCE maxAngle = 0 ONCE logEma = 0 ONCE logVariance = 0 ONCE longExitArmed = 0 ONCE shortExitArmed = 0 // --- Indicators --- // Count how many of the last five bars the bar two back beats. FOR i = 0 TO fractalBars DO IF high[2] > high[i] THEN fractalHighCount = fractalHighCount + 1 ENDIF IF low[2] < low[i] THEN fractalLowCount = fractalLowCount + 1 ENDIF NEXT // A fractal high starts a bearish trend line, a fractal low a bullish one. IF fractalHighCount = fractalBars THEN IF bearSetup = 0 AND bullSetup = 0 THEN bearSetup = 1 ENDIF fractalHigh = high[2] fractalBar = BarIndex - 2 ENDIF IF fractalLowCount = fractalBars THEN IF bearSetup = 0 AND bullSetup = 0 THEN bullSetup = 1 ENDIF fractalLow = low[2] fractalBar = BarIndex - 2 ENDIF fractalHighCount = 0 fractalLowCount = 0 IF bearSetup = 1 THEN trendHeight = fractalHigh - high closeHeight = fractalHigh - close ELSIF bullSetup = 1 THEN trendHeight = low - fractalLow closeHeight = close - fractalLow ENDIF // Track the steepest angle of the trend line from the fractal, then detect // a two-step break of that line (trendBreak 1, then 2). IF BarIndex - 2 = fractalBar THEN maxAngle = Tan(2 / trendHeight) ENDIF IF BarIndex - 2 > fractalBar THEN IF bearSetup = 1 THEN IF Tan((BarIndex - fractalBar) / trendHeight) > maxAngle AND (close < open OR close < close[1]) THEN maxAngle = Tan((BarIndex - fractalBar) / trendHeight) trendBreak = 0 ENDIF IF trendBreak = 0 AND Tan((BarIndex - fractalBar) / closeHeight) > maxAngle AND close > open THEN trendBreak = 1 ELSIF trendBreak = 1 AND Tan(((BarIndex - 1) - fractalBar) / closeHeight) > maxAngle AND close > close[1] THEN trendBreak = 2 ENDIF ELSIF bullSetup = 1 THEN IF Tan((BarIndex - fractalBar) / trendHeight) > maxAngle AND (close > open OR close > close[1]) THEN maxAngle = Tan((BarIndex - fractalBar) / trendHeight) trendBreak = 0 ENDIF IF trendBreak = 0 AND Tan((BarIndex - fractalBar) / closeHeight) > maxAngle AND close < open THEN trendBreak = 1 ELSIF trendBreak = 1 AND Tan(((BarIndex - 1) - fractalBar) / closeHeight) > maxAngle AND close < close[1] THEN trendBreak = 2 ENDIF ENDIF ENDIF atrValue = AverageTrueRange[atrPeriod](close)
67 lignes de plus : les règles d'entrée et de sortie.
Configuration
Questions
Oui, les entrées sont des ordres stop en attente valables pour un bar. Le code a été réécrit mais pas vérifié à la compilation, et les statistiques proviennent de la version antérieure.
Les sept lignes étaient profitables. USD/JPY journalier a rapporté JPY 754,540 sur 300 trades, et Nikkei 225 journalier USD 20,201.20.
Avec 1 contrat, la meilleure exécution a eu un max drawdown de JPY 93,910. Gold journalier était bien plus faible à EUR 317.10.
Les lignes de tendance tracées depuis des fractals ont besoin d'assez de bars entre les points de swing. Chaque ligne testée utilisait des bars de 4 heures ou journaliers.
Voir aussi
La communauté ProRealAlgos obtient les règles complètes, le code complet et le portefeuille automatisé.