Un massimo frattale avvia una linea di tendenza discendente, e una rottura in due fasi di quella linea arma un buy stop 0.3 ATR(7) sopra il massimo recente. Le uscite usano una banda esponenziale e RSI(2), chiudendo i long quando l'RSI è a 85 o più e il prezzo è di nuovo sotto la banda superiore. Gli short rispecchiano la logica.
Migliore esecuzione su 8. USD/JPY, 4 ore, spread 1, dall'esecuzione sweeps:2026-09-17-USDJPY-4h-opt.tsv:2.
| Periodo | Fino al 2026-09-17 |
| Strumento | USD/JPY, 4 ore |
| Spread | 1 punti |
| Contratti | 1 |
| Capitale iniziale | 1,000,000 |
| Costi | Solo spread. Commissioni e finanziamento overnight non sono inclusi. |
| Barre | Fino a 200,000 barre, meno dove lo strumento ha meno storico |
| Ultimo test | 2026-09-17 |
| positionSize Contratti per operazione | 1 |
| fractalBars Bar che il centro del frattale a 5 bar deve superare (strutturale, mantenere a 4) | 4 |
| breakoutBars Bar usate per il massimo o minimo di breakout | 2 |
| atrPeriod Lunghezza ATR per il buffer di ingresso | 7 |
| atrMultiplier Buffer di ingresso oltre il livello di breakout, in ATR | 0.3 |
| bandPeriod Lunghezza delle bande esponenziali sul log-prezzo | 34 |
| seedPeriod Lunghezza SMA usata per inizializzare le bande sulle prime bar | 3 |
| bandWidth Ampiezza delle bande in deviazioni standard | 1.618 |
| rsiPeriod Lunghezza RSI per l'uscita | 2 |
| overboughtLevel Livello RSI richiesto per un'uscita long | 85 |
| oversoldLevel Livello RSI richiesto per un'uscita short | 15 |
| lookbackPeriod Finestra per il massimo e minimo di swing precedenti | 100 |
Ogni esecuzione
| Mercato | Timeframe | PF | Operazioni | % successo | Netto | Max DD |
|---|---|---|---|---|---|---|
| USD/JPYMiglior esecuzione | 4 ore | n/a | 819 | 53.36 | 161,440 JPY | -93,910 |
| USD/JPY | Giornaliero | n/a | 300 | 59.00 | 754,540 JPY | -174,840 |
| Nikkei 225 | Giornaliero | n/a | 262 | 61.07 | 20,201 USD | -12,694 |
| Argento | Giornaliero | n/a | 255 | 50.59 | 8,055 USD | -2,895 |
| Petrolio Brent | Giornaliero | n/a | 119 | 60.50 | 4,755 EUR | -4,645 |
| GBP/USD | Giornaliero | n/a | 334 | 59.88 | 3,432 USD | -2,003 |
| FTSE 100 | Giornaliero | n/a | 297 | 54.55 | 2,325 EUR | -948 |
| Oro | Giornaliero | n/a | 287 | 55.05 | 624 EUR | -317 |
Grafici
Il codice
// ============================================================ // 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)
Altre 67 righe: le regole di ingresso e di uscita.
Configurazione
Domande
Sì, gli ingressi sono ordini stop pendenti validi per una bar. Il codice è stato riscritto ma non verificato in compilazione, e le statistiche provengono dalla versione precedente.
Tutte e sette le righe sono state profittevoli. USD/JPY giornaliero ha prodotto JPY 754,540 su 300 operazioni, e Nikkei 225 giornaliero ha prodotto USD 20,201.20.
Con 1 contratto la migliore esecuzione ha avuto un max drawdown di JPY 93,910. Gold giornaliero è stato molto più piccolo, a EUR 317.10.
Le linee di tendenza tracciate dai frattali richiedono abbastanza bar tra i punti di swing. Ogni riga testata ha usato bar a 4 ore o giornaliere.
Correlati
La community ProRealAlgos ottiene le regole complete, il codice completo e il portafoglio automatizzato.