Estrategia de inversión de tendencia de seguimiento

El autor:¿ Qué pasa?, fecha: 2024-01-16 14:44:35
Las etiquetas:

img

Resumen general

La estrategia de inversión de tendencia es una estrategia de trading de tendencia a corto plazo basada en futuros de NQ de 15 minutos.

Estrategia lógica

La estrategia se basa principalmente en los siguientes principios:

  1. Utilice una EMA de 8 períodos como el filtro principal de tendencia, con señales largas por encima de la EMA y señales cortas por debajo de la EMA.

  2. Identificar patrones específicos de reversión de candelabros como señales de entrada, incluyendo velas verdes largas seguidas de velas rojas cortas para señales largas y velas rojas largas seguidas de velas verdes cortas para señales cortas.

  3. Los puntos de entrada se establecen cerca del alto/bajo de la vela de reversión, con niveles de stop loss en el alto/bajo de la vela de reversión misma, lo que permite relaciones de riesgo/recompensación eficientes.

  4. Valida las señales de reversión utilizando reglas de relación de velas, por ejemplo, el precio de apertura de la vela roja está por encima del cuerpo de la última vela verde, el cuerpo se engulle completamente, etc. para filtrar el ruido.

  5. La estrategia solo debe aplicarse durante horas de negociación específicas, evitando los períodos volátiles en torno a los principales cambios de contrato, etc., para evitar pérdidas innecesarias por la acción anormal de los precios.

Análisis de ventajas

Las principales ventajas de esta estrategia incluyen:

  1. Lógica de señal simple y eficaz que es fácil de comprender y ejecutar.

  2. Basado en tendencias e inversiones, evitando los golpes de los mercados alcistas y bajistas.

  3. Un buen control del riesgo con una colocación razonable de stop loss para preservar el capital.

  4. Las bajas necesidades de datos se adaptan a diversas plataformas y herramientas.

  5. La alta frecuencia de negociación conviene al estilo de negociación activo a corto plazo.

Riesgos y soluciones

Hay algunos riesgos a tener en cuenta:

  1. Oportunidades de reversión insuficientes y señales limitadas.

  2. Añadir más filtros para la lógica de combinación.

  3. Volatilidad en las sesiones nocturnas y no principales.

  4. Flexibilidad de optimización limitada. Considere el aprendizaje automático para un mejor ajuste de parámetros.

Oportunidades de mejora

Hay espacio para la optimización:

  1. Prueba períodos de EMA más largos para mejorar la definición de tendencia.

  2. Añadir filtros de índices de renta variable como filtros de tendencia suplementarios.

  3. Utilice técnicas de aprendizaje automático para ajustar automáticamente la entrada y detener los niveles de pérdida.

  4. Introducir el tamaño de posición ajustado a la volatilidad y las paradas dinámicas.

  5. Explorar el arbitraje entre activos para diversificar los riesgos sistémicos de un solo activo.

Conclusión

La estrategia de inversión de seguimiento de tendencias ofrece un marco de estrategia a corto plazo muy práctico que es simple de implementar con parámetros limitados y un buen control del riesgo personal. Es adecuado para los operadores activos a corto plazo en los foros de negociación diaria. Con más I + D, puede ser potencialmente aplicable para el comercio algorítmico a mediano y largo plazo, demostrando una gran versatilidad y potencial de desarrollo.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bdrex95

//@version=5

// Rob Reversal Strategy - Official
// Using Rob Reversal Indicator: Original
// Description
// This indicator is based on the strategy created by Trader Rob on the NQ 15m chart.
// 
// Timeframe for trading is 8:30am-1:15pm Central.
// 
// Above the EMA line, look for a long position. You will have a short candle, then a long candle that opens below the short candle. It will have a lower high and a lower low. Once the long candle closes, your entry will be 1 tick above the wick (green line) and stop loss will be at the bottom of the bottom wick (red line).
// 
// Below the EMA line, look for a short position. You will have a long candle, then a short candle that opens above the long candle. It will have a higher high and a higher low. Once the short candle closes, your entry will be 1 tick below the wick (green line) and stop loss will be at the top of the top wick (red line).
//

strategy("Trader Rob Reversal Strategy NQ 15min", shorttitle="Official Rob Rev Strat", overlay=true)


//--- Session Input ---
sess = input(defval = "0930-1415", title="Trading Session")
t = time(timeframe.period, sess)
sessionOpen = na(t) ? false : true

flat_time = input(defval = "1515-1558", title="Close All Open Trades")
ft = time(timeframe.period, flat_time)
flatOpen = na(ft) ? false : true


// Calculate start/end date and time condition
startDate = input(timestamp('2018-12-24T00:00:00'),group = "ALL STRATEGY SETTINGS BELOW")
finishDate = input(timestamp('2029-02-26T00:00:00'),group = "ALL STRATEGY SETTINGS BELOW")
time_cond = true


emaColor = input.color(color.orange, title="EMA Color")
emaLength = input.int(8, title="EMA Length")


emaInd = ta.ema(close, emaLength)


rr = input(1.0,"Enter RR",group = "TP/SL CONDITION INPUTS HERE")


sellShapeInput = input.string("Arrow", title="Sell Entry Shape", options=["Arrow", "Triangle"])
buyShapeInput = input.string("Arrow", title="Buy Entry Shape", options=["Arrow", "Triangle"])


sellShapeOption = switch sellShapeInput
    "Arrow" => shape.arrowdown
    "Triangle" => shape.triangledown
   
buyShapeOption = switch buyShapeInput
    "Arrow" => shape.arrowup
    "Triangle" => shape.triangleup


O = open
C = close
H = high
L = low


sellEntry = (C[1] > O[1]) and (C < O) and (H[1] < H) and (C < H[1]) and (C > L[1]) and (L > L[1]) and (C < emaInd) and sessionOpen and time_cond
buyEntry = (C[1] < O[1]) and (C > O) and (H[1] > H) and (L[1] > L) and (C < H[1]) and (C > L[1]) and (C > emaInd) and sessionOpen and time_cond


sellEntry_index = ta.valuewhen(sellEntry,bar_index,0)
sellEntry_hi = ta.valuewhen(sellEntry,high,0)
sellEntry_low = ta.valuewhen(sellEntry,low,0)
buyEntry_index = ta.valuewhen(buyEntry,bar_index,0)
buyEntry_hi = ta.valuewhen(buyEntry,high,0)
buyEntry_lo = ta.valuewhen(buyEntry,low,0)


plotshape(buyEntry, color = color.green, location = location.belowbar, style = buyShapeOption, size = size.small)
plotshape(sellEntry, color = color.red, location = location.abovebar, style = sellShapeOption, size = size.small)
plot(emaInd, color=emaColor)


// Risk Management
entry_price_long = (buyEntry_hi + syminfo.mintick)
entry_price_short = (sellEntry_low - syminfo.mintick)
long_sl_price = (buyEntry_lo-syminfo.mintick)
short_sl_price = (sellEntry_hi + syminfo.mintick)
long_tp_price = ((entry_price_long - long_sl_price)*rr) + entry_price_long
short_tp_price = entry_price_short - ((short_sl_price - entry_price_short)*rr)


long_sl_ticks = (entry_price_long - long_sl_price) / syminfo.mintick
short_sl_ticks = (short_sl_price - entry_price_short) / syminfo.mintick


long_tp_ticks = (long_tp_price - entry_price_long) / syminfo.mintick
short_tp_ticks = (entry_price_short - short_tp_price) / syminfo.mintick


// Positions
if (buyEntry)
    strategy.entry("Long", strategy.long,stop = H + syminfo.mintick)
if strategy.position_size > 0
    strategy.exit("Long Ex","Long", loss = long_sl_ticks, profit = long_tp_ticks, comment_loss = "SL Long", comment_profit = "TP Long")


if (sellEntry)
    strategy.entry("Short", strategy.short,stop = L - syminfo.mintick)
if strategy.position_size < 0
    strategy.exit("Short Ex","Short",loss = short_sl_ticks, profit = short_tp_ticks, comment_loss = "SL Short", comment_profit = "TP Short")


// Cancel order if close beyond ema
if (C < emaInd)
    strategy.cancel("Long")


if (C > emaInd)
    strategy.cancel("Short")


// Go flat at close (for futures funded account)
if strategy.position_size > 0 and flatOpen
    strategy.close_all(comment = "EOD Flat")
if strategy.position_size < 0 and flatOpen
    strategy.close_all(comment = "EOD Flat")
 
//END

Más.