Los longs se activan cuando el cierre rompe por encima del máximo de las 9 barras anteriores mientras el histograma del MACD sube, el RSI(4) está por encima de 63 y el precio se mantiene por encima de la SMA de 50. Los shorts usan un mínimo de 7 barras, un histograma a la baja, el RSI(4) por debajo de 31 y la SMA de 500. Las posiciones salen en el borde opuesto del canal, sin objetivo de beneficio.
| positionSize Acciones por operación, tal como se publica | 2 |
| longChannelPeriod Longitud de Donchian para las entradas long y el stop del long | 9 |
| shortChannelPeriod Longitud de Donchian para las entradas short y el stop del short | 7 |
| macdFast Longitud rápida del MACD | 12 |
| macdSlow Longitud lenta del MACD | 26 |
| macdSignalPeriod Longitud de la señal del MACD | 9 |
| rsiPeriod Longitud del RSI | 4 |
| longRsiLevel El RSI debe estar por encima de este valor para comprar | 63 |
| shortRsiLevel El RSI debe estar por debajo de este valor para ir short | 31 |
| longTrendPeriod SMA en o por encima de la cual debe estar el cierre para comprar | 50 |
| shortTrendPeriod SMA en o por debajo de la cual debe estar el cierre para ir short | 500 |
El código
// ============================================================ // 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)
20 líneas más: las reglas de entrada y salida.
Configuración
Preguntas
Las reglas están escritas para ProOrder, pero el código reescrito no se ha comprobado en compilación ni se le ha hecho backtest. Tómalo como punto de partida para tus propias pruebas.
Ninguna todavía. No se le ha hecho backtest en este sitio.
Por defecto son 2 por operación, fijado por el parámetro positionSize. Sin un backtest no hay cifra de drawdown, así que opera con un tamaño pequeño hasta que tengas tus propios resultados.
El filtro de la SMA de 500 en los shorts necesita mucho historial, así que tiene sentido un marco temporal con amplia cobertura de datos. Aquí todavía no se ha probado ningún marco temporal.
Relacionado
La comunidad de ProRealAlgos obtiene las reglas completas, el código completo y la cartera automatizada.