
A estratégia de ruptura de dupla praia combina a estratégia de ruptura da lei de negociação da praia com o princípio de stop loss móvel de Linda Raschke, com excelente desempenho de ruptura e controle rigoroso do risco. A estratégia monitora simultaneamente as rupturas ascendentes e descendentes do preço, estabelece posições de compra ou venda em caso de ruptura e utiliza o stop loss móvel e a gestão de stop loss móvel.
A lógica central é fechar a posição quando a alta do ciclo maior quebra a alta do ciclo menor, e fazer mais quando a baixa do ciclo menor quebra a baixa do ciclo maior. Após a criação da posição, configure um stop loss móvel e um stop loss móvel, primeiro confirmando o risco de parada. Quando o número de posições acumulado atinge o número de paradas definidas, cancele o stop loss no próximo ciclo, e depois saia da posição e configure um stop loss móvel e um stop stop móvel para bloquear o lucro e acompanhar a diferença de preço.
Os passos são os seguintes:
É uma estratégia de ruptura muito abrangente, mas com as seguintes vantagens:
Os principais riscos e medidas de resposta são:
A estratégia também pode ser melhorada em alguns aspectos:
A estratégia de quebra de dupla praia combina técnicas de dois ciclos, teoria de quebra e métodos rigorosos de gerenciamento de risco para garantir a estabilidade dos ganhos, mantendo uma alta taxa de vitória. O modelo da estratégia é simples, claro, fácil de entender e aplicar, e é uma excelente estratégia quantitativa.
/*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()