I long si attivano quando la chiusura supera il massimo delle 9 bar precedenti mentre l'istogramma MACD è in salita, l'RSI(4) è sopra 63 e il prezzo si mantiene sopra la SMA 50. Gli short usano un minimo a 7 bar, un istogramma in discesa, l'RSI(4) sotto 31 e la SMA 500. Le posizioni escono al bordo opposto del canale senza obiettivo di profitto.
| positionSize Azioni per operazione, come pubblicato | 2 |
| longChannelPeriod Lunghezza Donchian per gli ingressi long e per lo stop long | 9 |
| shortChannelPeriod Lunghezza Donchian per gli ingressi short e per lo stop short | 7 |
| macdFast Lunghezza MACD veloce | 12 |
| macdSlow Lunghezza MACD lenta | 26 |
| macdSignalPeriod Lunghezza del segnale MACD | 9 |
| rsiPeriod Lunghezza RSI | 4 |
| longRsiLevel L'RSI deve essere sopra questo valore per comprare | 63 |
| shortRsiLevel L'RSI deve essere sotto questo valore per andare short | 31 |
| longTrendPeriod SMA a cui la chiusura deve essere pari o superiore per comprare | 50 |
| shortTrendPeriod SMA a cui la chiusura deve essere pari o inferiore per andare short | 500 |
Il codice
// ============================================================ // Donchian MACD Breakout // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 50000 // --- Parameters --- positionSize = 2 // shares per trade, as published longChannelPeriod = 9 // Donchian length for long entries and the long stop shortChannelPeriod = 7 // Donchian length for short entries and the short stop macdFast = 12 // MACD fast length macdSlow = 26 // MACD slow length macdSignalPeriod = 9 // MACD signal length rsiPeriod = 4 // RSI length longRsiLevel = 63 // RSI must be above this to buy shortRsiLevel = 31 // RSI must be below this to short longTrendPeriod = 50 // SMA the close must be at or above to buy shortTrendPeriod = 500 // SMA the close must be at or below to short // --- Indicators --- macdHistogram = MACD[macdFast, macdSlow, macdSignalPeriod](close) longChannelHigh = Highest[longChannelPeriod](high) longChannelLow = Lowest[longChannelPeriod](low) shortChannelHigh = Highest[shortChannelPeriod](high) shortChannelLow = Lowest[shortChannelPeriod](low) rsiValue = RSI[rsiPeriod](close) longTrendMA = Average[longTrendPeriod](close) shortTrendMA = Average[shortTrendPeriod](close)
Altre 20 righe: le regole di ingresso e di uscita.
Configurazione
Domande
Le regole sono scritte per ProOrder, ma il codice riscritto non è stato verificato in compilazione né sottoposto a backtest. Consideralo un punto di partenza per i tuoi test.
Nessuna per ora. Non è stata sottoposta a backtest su questo sito.
Il valore predefinito è 2 per operazione, impostato dal parametro positionSize. Senza un backtest non esiste un dato di drawdown, quindi usa una position size piccola finché non hai i tuoi risultati.
Il filtro SMA 500 sugli short richiede molta storia, quindi ha senso un timeframe con una lunga copertura di dati. Qui non è ancora stato testato alcun timeframe.
Correlati
La community ProRealAlgos ottiene le regole complete, il codice completo e il portafoglio automatizzato.