
La estrategia de breakout de las dos orillas combina la estrategia de breakout de la ley de comercio de las orillas y el principio de stop loss móvil de Linda Raschke, con una excelente capacidad de breakout y un control estricto del riesgo. La estrategia monitorea al mismo tiempo la subida y bajada de los precios, establece posiciones de venta o cancelación cuando se produce una ruptura, y utiliza el stop loss móvil y las posiciones de gestión de stop loss móviles.
La lógica central es hacer un vacío cuando se rompe el pequeño ciclo de alta en el ciclo de alta, y hacer más cuando se rompe el pequeño ciclo de baja en el ciclo de baja en el ciclo de alta. Después de la creación de la posición, el establecimiento de la parada de movimiento y los paros móviles, primero el parón confirma el riesgo. Cuando el número de posiciones se acumula en el número de paradas de la configuración, en el siguiente ciclo de cancelar la orden de parada, y luego salir de la mitad de la posición y establecer el parón móvil y los parados móviles para bloquear los beneficios y seguir la diferencia de precios.
Los pasos son los siguientes:
Se trata de una estrategia de ruptura integrada que tiene las siguientes ventajas:
Los principales riesgos y respuestas son:
La estrategia también puede ser optimizada en los siguientes aspectos:
La estrategia de ruptura de las dos olas utiliza una combinación de técnicas de doble ciclo, teoría de ruptura y métodos estrictos de gestión de riesgos para garantizar la estabilidad de los ingresos, al tiempo que mantiene una alta tasa de éxito. El modelo de estrategia es simple y claro, fácil de entender y aplicar, y es una excelente estrategia cuantitativa.
/*backtest
start: 2022-11-21 00:00:00
end: 2023-11-27 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy(title = "Turtle soup plus one", shorttitle = "Turtle soup plus one", overlay=true)
bigPeriod = input(20)
smallPeriod = input(4)
takeProfitBars = input(0)
trailingStop = input(5, title = "Trailing stop percentages")
if (strategy.position_size == 0)
strategy.cancel("Long")
strategy.cancel("Short")
strategy.cancel("Stop")
stopLossPrice = 0.1
stopLossPrice := nz(stopLossPrice[1])
takeProfitStarted = false
takeProfitStarted := nz(takeProfitStarted[1])
prevHigh = highest(high, bigPeriod - smallPeriod)[smallPeriod]
smallPeriodHigh = highest(high, smallPeriod - 1)[1]
if (high > prevHigh and prevHigh > smallPeriodHigh and close > prevHigh and strategy.position_size == 0)
strategy.order("Short", strategy.short, stop = prevHigh)
if strategy.position_size < 0 and strategy.position_size[1] == 0
stopLossPrice := high[1]
strategy.order("Stop", strategy.long, qty = -strategy.position_size, stop = stopLossPrice)
takeProfitStarted := false
if (strategy.position_size < 0 and sum(strategy.position_size, takeProfitBars) == strategy.position_size * takeProfitBars and close < strategy.position_avg_price and not takeProfitStarted)
takeProfitStarted := true
strategy.cancel("Stop")
strategy.order("ExitHalf", strategy.long, qty = ceil(-strategy.position_size / 2), stop = close)
if (strategy.position_size != -1)
strategy.exit("ExitFull", "Short", qty = -strategy.position_size - ceil(-strategy.position_size / 2), loss = stopLossPrice, trail_price = close, trail_offset = -(close - strategy.position_avg_price) * trailingStop / 100 / syminfo.mintick)
prevLow = lowest(low, bigPeriod - smallPeriod)[smallPeriod]
smallPeriodLow = lowest(low, smallPeriod - 1)[1]
if (low < prevLow and prevLow < smallPeriodLow and close < prevLow and strategy.position_size == 0)
strategy.order("Long", strategy.long, stop = prevLow)
if strategy.position_size > 0 and strategy.position_size[1] == 0
stopLossPrice := low[1]
strategy.order("Stop", strategy.short, qty = strategy.position_size, stop = stopLossPrice)
takeProfitStarted := false
if (strategy.position_size > 0 and sum(strategy.position_size, takeProfitBars) == strategy.position_size * takeProfitBars and close > strategy.position_avg_price and not takeProfitStarted)
takeProfitStarted := true
strategy.cancel("Stop")
strategy.order("ExitHalf", strategy.short, qty = ceil(strategy.position_size / 2), stop = close)
if (strategy.position_size != 1)
strategy.exit("ExitFull", "Long", qty = strategy.position_size - ceil(strategy.position_size / 2),loss = stopLossPrice, trail_price = close, trail_offset = (close - strategy.position_avg_price) * trailingStop / 100 / syminfo.mintick)
// === Backtesting Dates ===
testPeriodSwitch = input(false, "Custom Backtesting Dates")
testStartYear = input(2018, "Backtest Start Year")
testStartMonth = input(3, "Backtest Start Month")
testStartDay = input(6, "Backtest Start Day")
testStartHour = input(08, "Backtest Start Hour")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,testStartHour,0)
testStopYear = input(2038, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(14, "Backtest Stop Day")
testStopHour = input(14, "Backtest Stop Hour")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,testStopHour,0)
testPeriod() =>
time >= testPeriodStart and time <= testPeriodStop ? true : false
isPeriod = testPeriodSwitch == true ? testPeriod() : true
// === /END
if not isPeriod
strategy.cancel_all()
strategy.close_all()