
이 글은 래리 윌리엄스 3주기 동적 평균을 기반으로 한 거래 전략에 대해 소개한다. 이 전략은 두 개의 지수 이동 평균 ((EMA) 를 사용하여 가격 추세를 포착하고, 3개의 연속적인 K선 종결 가격이 EMA를 돌파할 때 거래 신호를 발생시킨다. 전략의 매개 변수는 조정 가능하며, 다른 시장과 주기에는 적용된다.
래리 윌리엄스 3주기 동적 평행선 거래 전략은 쌍 EMA와 연속 K선 방향에 기반한 트렌드 추적 전략으로, 변수 최적화를 통해 다양한 시장에 적응할 수 있다. 그러나 전략 자체는 비교적 간단하며, 불안정한 시장에서 좋지 않은 성능을 보이고, 풍력 조절 조치가 부족하며, 추가적인 최적화와 개선이 필요하다. 전략의 장단점을 종합적으로 고려하면, 이 전략은 트렌드가 뚜렷한 시장에서 사용하기에 더 적합하며, 포지션 관리 및 위험 제어 조치가 조화를 이루며, 전반적인 성능과 안정성을 향상시킨다.
/*backtest
start: 2023-05-05 00:00:00
end: 2024-05-10 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Larry Williams 3 Periodos Editável de MarcosJr", overlay=true, process_orders_on_close=true)
// Parametrização do período do EMA
emaPeriodHighs = input.int(title="Highs Period", defval=3, minval=1, maxval=9999)
emaPeriodLows = input.int(title="Lows Period", defval=3, minval=1, maxval=9999)
// Parametrização da data de início e fim do período a ser coletado
startYear = input.int(title="Start Year", defval=2020)
startMonth = input.int(title="Start Month", defval=1, minval=1, maxval=12)
startDay = input.int(title="Start Day", defval=1, minval=1, maxval=31)
endYear = input.int(title="End Year", defval=2020)
endMonth = input.int(title="End Month", defval=12, minval=1, maxval=12)
endDay = input.int(title="End Day", defval=31, minval=1, maxval=31)
// Convertendo data de início e fim para timestamp
startDate = timestamp(startYear, startMonth, startDay, 00, 00)
endDate = timestamp(endYear, endMonth, endDay, 23, 59)
// EMA
emaH = ta.ema(high, emaPeriodHighs)
emaL = ta.ema(low, emaPeriodLows)
// PLOT:
// Desenha as linhas EMA no gráfico
plot(emaH, color=color.green, linewidth=2)
plot(emaL, color=color.red, linewidth=2)
// Condições
inDateRange = true
// Verifica se houve mais de três candles consecutivos do mesmo sentido
checkThreeConsecutiveCandles = (close[0] > close[1] and close[1] > close[2] and close[2] > close[3]) or (close[0] < close[1] and close[1] < close[2] and close[2] < close[3])
if(close < emaL and inDateRange and checkThreeConsecutiveCandles and barstate.isconfirmed)
strategy.entry("Long", strategy.long, comment="Long", when=strategy.position_size == 0)
if(close > emaH and inDateRange and checkThreeConsecutiveCandles and barstate.isconfirmed)
strategy.close("Long", comment="Close Long")
// Fechar a operação no fechamento do pregão
if(strategy.position_size > 0 and na(time_close[0]))
strategy.close("Long", comment="Close Long")