Las primeras 7 barras de la sesión forman un rango de apertura, y un long se dispara cuando el TEMA(5) cruza por encima de su máximo. Los shorts necesitan un cruce del TEMA por debajo del mínimo más un cierre por debajo del cierre de ayer. El stop y el objetivo son ambos iguales a la altura del rango, y las operaciones abiertas se cierran en la primera barra de la sesión siguiente.
| startingCapital Tamaño de cuenta usado para el dimensionamiento | 10000 |
| riskFraction Proporción del capital arriesgada por operación | 0.01 |
| sizingStopPoints Distancia del stop asumida al dimensionar, en puntos | 10 |
| rangeBars Barras posteriores a la primera barra de la sesión que forman el rango de apertura | 6 |
| temaPeriod Longitud del TEMA para la señal de breakout | 5 |
El código
// ============================================================ // Opening Range Breakout TEMA // ProRealAlgos Strategy Library | prorealalgos.com // Type: Breakout // Direction: Long & short // Timeframe tested: Not yet tested // ============================================================ // --- Settings --- DEFPARAM CumulateOrders = false DEFPARAM PreloadBars = 1000 // --- Parameters --- startingCapital = 10000 // account size used for sizing riskFraction = 0.01 // share of capital risked per trade sizingStopPoints = 10 // stop distance assumed when sizing, in points rangeBars = 6 // bars after the session's first bar that build the opening range temaPeriod = 5 // TEMA length for the breakout signal ONCE dayBar = 0 ONCE longTrades = 0 ONCE shortTrades = 0 // --- Indicators --- // Size is fixed once on the first bar from capital, risk and the sizing stop. ONCE equity = startingCapital + StrategyProfit ONCE maxRisk = round(equity * riskFraction) ONCE positionSize = abs(round((maxRisk / sizingStopPoints) / PointValue) * PipSize) // Bar counter within the session, 0 on the first bar of a new day. IF Day <> Day[1] THEN dayBar = 0 ELSE dayBar = dayBar + 1 ENDIF temaValue = TEMA[temaPeriod](close) prevDayClose = DClose(1) // Opening range, plus a stop and target equal to its height. IF dayBar <= rangeBars THEN IF dayBar = 0 THEN rangeHigh = high rangeLow = low ENDIF IF high > rangeHigh THEN rangeHigh = high ENDIF IF low < rangeLow THEN rangeLow = low ENDIF stopDistance = rangeHigh - rangeLow targetDistance = stopDistance longTrades = 0 shortTrades = 0 ENDIF
32 líneas más: las reglas de entrada y salida.
Configuración
Preguntas
Está escrita para ProOrder, pero no se ha comprobado su compilación ni se le ha hecho backtest. Pruébala primero en demo.
Ninguna todavía. No hay resultados en este sitio.
El código dimensiona las operaciones a partir de 10000 de capital, 1% de riesgo y un stop de dimensionamiento de 10 puntos. Comprueba qué significa eso para el instrumento que operes, ya que el stop real es la altura del rango.
El rango se construye a partir de barras, así que el marco temporal fija su longitud. Un gráfico más rápido da una ventana de apertura más corta, uno más lento un rango más amplio con stops mayores.
Relacionado
La comunidad de ProRealAlgos obtiene las reglas completas, el código completo y la cartera automatizada.