모멘텀 풀백 전략

저자:차오장, 날짜: 2024-01-26 11:07:47
태그:

img

전반적인 설명

모멘텀 풀백 전략 (Momentum Pullback Strategy) 은 이동 평균과 촛불 패턴을 결합하여 브레이크업과 풀백을 감지하여 거래 기회를 식별하는 중장기 거래 전략이다. 옵션과 선물과 같은 고레버리지 금융 상품 거래에 적합하다.

전략 논리

이 전략의 핵심 논리는 5일 간 간단한 이동 평균에 기반한다. 가격이 이 평균선을 뚫고 갈 때, 잠재적인 긴 또는 짧은 기회를 신호하는 격차 높은 또는 낮은 촛불을 형성한다. 이동 평균을 넘어서 두 번째 촛불이 닫히면 이전 격차 촛불의 낮거나 높은 수준을 깨지 않을 때 엔트리 신호가 발동된다. 그 후 위험-상금 비율에 따라 스톱 로스와 이익 목표 수준이 설정된다.

가격이 5일 MA를 넘어서고 닫을 때, 이전 격차 촛불의 높이는 스톱 로스 수준이다. 이윤 목표는 원하는 리스크-어워드 비율로 곱한 낮은 것에서 특정 리트레이싱 범위를 빼서 설정된다. 마찬가지로 하향 브레이크오웃의 경우, 이전 격차 촛불의 낮은 스톱 로스 수준이며, 이윤 취득 수준은 높은 것 이상이며 리스크-어워드 비율에 의해 인해서 리트레이싱 범위를 요인한다.

현재 촛불의 닫힘이 추가 확인을 위해 간격 촛불의 닫힘보다 약간 낮거나 높아야하는 경우 선택적 필터가 제공되며 잘못된 신호를 피합니다.

이점 분석

  • 명확하고 간단한 전략 논리, 이해하기 쉽고 실행하기 쉬운
  • 이동 평균을 사용하여 트렌드 및 인하를 식별합니다.
  • 촛불 패턴을 조합하여 더 정확한 거래 시기를 설정합니다.
  • 위험과 보상을 맞추고 신중한 거래와 일치합니다
  • 각기 다른 제품 및 시간 프레임에 대한 조정 가능한 매개 변수
  • 선택 필터는 일부 잘못된 신호를 피합니다.

위험 분석

  • 트렌드에 걸리거나 실행을 중단하는 것과 같은 일반적인 기술 분석 위험
  • 이동 평균의 지연 성격은 빠른 반전을 놓칠 수 있습니다.
  • 범위에 묶인 시장에서 더 많은 잘못된 신호가 발생할 가능성이 있습니다.
  • 패러미터 조정이 제대로 되지 않아 거래가 과도하다

합리적인 스톱 로스, 포지션 사이즈, 덜 빈번한 거래 등으로 위험을 줄일 수 있습니다. 다른 지표를 필터 신호로 결합하는 것도 옵션입니다.

최적화 방향

  • 최상의 성능을 위해 다른 매개 변수 세트를 테스트
  • 신호 필터에 다른 지표 또는 차트 패턴을 추가
  • 동적, 후속 스톱 손실 향상 탐구
  • 매개 변수를 자동 최적화하기 위해 기계 학습을 적용
  • 자동 중지 손실 / 수익 플러그인을 개발
  • 제품 및 시간 프레임에 걸쳐 견고성 검사

결론

전체적으로 이것은 이해하기 쉽고 중장기 거래 전략이다. 이 방법은 합리적인 리스크 제어 프레임워크와 함께 이동 평균과 간격 촛불에 의해 식별된 트렌드 역전에서 활용된다. 추가 개선이 가능하지만, 핵심 논리는 매개 변수 조정, 신호 필터링 등을 통해 더 넓은 응용을 위해 다재다능하다.


/*backtest
start: 2024-01-18 00:00:00
end: 2024-01-25 00:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradingInsights2

//@version=5
strategy("Ultimate 5EMA Strategy By PowerOfStocks", overlay=true)

Eusl = input.bool(false, title="Enable the Extra SL shown below")
usl = input.int(defval=5, title='Value to set SL number of points below-low or above-high', minval=1, maxval=100)
RiRe = input.int(defval=3, title='Risk to Reward Ratio', minval=1, maxval=25)
ShowSell = input.bool(true, 'Show Sell Signals')
ShowBuy = input.bool(false, 'Show Buy Signals')
BSWCon = input.bool(defval=false, title='Buy/Sell with Extra Condition - candle close')

// Moving Average 

ema5 = ta.ema(close, 5)
pema5 = plot(ema5, '5 Ema', color=color.new(#da1a1a, 0), linewidth=2)

var bool Short = na
var bool Long = na
var shortC = 0
var sslhitC = 0
var starhitC = 0
var float ssl = na
var float starl = na
var float star = na
var float sellat = na
var float alert_shorthigh = na
var float alert_shortlow = na
var line lssl = na
var line lstar = na
var line lsell = na
var label lssllbl = na
var label lstarlbl = na
var label lselllbl = na
var longC = 0
var lslhitC = 0
var ltarhitC = 0
var float lsl = na
var float ltarl = na
var float ltar = na
var float buyat = na
var float alert_longhigh = na
var float alert_longlow = na
var line llsl = na
var line lltar = na
var line lbuy = na
var label llsllbl = na
var label lltarlbl = na
var label lbuylbl = na

ShortWC = low[1] > ema5[1] and low[1] > low and shortC == 0 and close < close[1]
ShortWOC = low[1] > ema5[1] and low[1] > low and shortC == 0
Short := BSWCon ? ShortWC : ShortWOC
sslhit = high > ssl and shortC > 0 and sslhitC == 0
starhit = low < star and shortC > 0 and starhitC == 0
LongWC = high[1] < ema5[1] and high[1] < high and longC == 0 and close > close[1]
LongWOC = high[1] < ema5[1] and high[1] < high and longC == 0
Long := BSWCon ? LongWC : LongWOC
lslhit = low < lsl and longC > 0 and lslhitC == 0
ltarhit = high > ltar and longC > 0 and ltarhitC == 0

if Short and ShowSell
    shortC := shortC + 1
    sslhitC := 0
    starhitC := 0
    alert_shorthigh := high[1]
    if Eusl
        ssl := high[1] + usl
        starl := BSWCon ? ((high[1] - close) + usl) * RiRe : ((high[1] - low[1]) + usl) * RiRe
    else
        ssl := high[1]
        starl := BSWCon ? (high[1] - close) * RiRe : (high[1] - low[1]) * RiRe
    star := BSWCon ? close - starl : low[1] - starl
    sellat := BSWCon ? close : low[1]
    // lssl := line.new(bar_index, ssl, bar_index, ssl, color=color.new(#fc2d01, 45), style=line.style_dashed)
    // lstar := line.new(bar_index, star, bar_index, star, color=color.new(color.green, 45), style=line.style_dashed)
    // lsell := line.new(bar_index, sellat, bar_index, sellat, color=color.new(color.orange, 45), style=line.style_dashed)
    // lssllbl := label.new(bar_index, ssl, style=label.style_none, text='Stop Loss - Short' + ' (' + str.tostring(ssl) + ')', textcolor=color.new(#fc2d01, 35), color=color.new(#fc2d01, 35))
    // lstarlbl := label.new(bar_index, star, style=label.style_none, text='Target - Short' + ' (' + str.tostring(star) + ')', textcolor=color.new(color.green, 35), color=color.new(color.green, 35))
    // lselllbl := label.new(bar_index, sellat, style=label.style_none, text='Sell at' + ' (' + str.tostring(sellat) + ')', textcolor=color.new(color.orange, 35), color=color.new(color.orange, 35))

if sslhit == false and starhit == false and shortC > 0
    // line.set_x2(lssl, bar_index)
    // line.set_x2(lstar, bar_index)
    // line.set_x2(lsell, bar_index)
    sslhitC := 0
    starhitC := 0
else
    if sslhit
        shortC := 0
        sslhitC := sslhitC + 1
    else
        if starhit
            shortC := 0
            starhitC := starhitC + 1

if Long and ShowBuy
    longC := longC + 1
    lslhitC := 0
    ltarhitC := 0
    alert_longlow := low[1]
    if Eusl
        lsl := low[1] - usl
        ltarl := BSWCon ? ((close - low[1]) + usl) * RiRe : ((high[1] - low[1]) + usl) * RiRe
    else
        lsl := low[1]
        ltarl := BSWCon ? (close - low[1]) * RiRe : (high[1] - low[1]) * RiRe
    ltar := BSWCon ? close + ltarl : high[1] + ltarl
    buyat := BSWCon ? close : high[1]
    llsl := line.new(bar_index, lsl, bar_index, lsl, color=color.new(#fc2d01, 45), style=line.style_dotted)
    lltar := line.new(bar_index, ltar, bar_index, ltar, color=color.new(color.green, 45), style=line.style_dotted)
    lbuy := line.new(bar_index, buyat, bar_index, buyat, color=color.new(color.orange, 45), style=line.style_dotted)
    llsllbl := label.new(bar_index, lsl, style=label.style_none, text='Stop Loss - Long' + ' (' + str.tostring(lsl) + ')', textcolor=color.new(#fc2d01, 35), color=color.new(#fc2d01, 35))
    lltarlbl := label.new(bar_index, ltar, style=label.style_none, text='Target - Long' + ' (' + str.tostring(ltar) + ')', textcolor=color.new(color.green, 35), color=color.new(color.green, 35))
    lbuylbl := label.new(bar_index, buyat, style=label.style_none, text='Buy at' + ' (' + str.tostring(buyat) + ')', textcolor=color.new(color.orange, 35), color=color.new(color.orange, 35))

if lslhit == false and ltarhit == false and longC > 0
    // line.set_x2(llsl, bar_index)
    // line.set_x2(lltar, bar_index)
    // line.set_x2(lbuy, bar_index)
    lslhitC := 0
    ltarhitC := 0
else
    if lslhit
        longC := 0
        lslhitC := lslhitC + 1
    else
        if ltarhit
            longC := 0
            ltarhitC := ltarhitC + 1

strategy.entry("Buy", strategy.long, when=Long)
strategy.entry("Sell", strategy.short, when=Short)
strategy.close("ExitBuy", when=sslhit or starhit)
strategy.close("ExitSell", when=lslhit or ltarhit)

plotshape(ShowSell and Short, title='Sell', location=location.abovebar, offset=0, color=color.new(#e74c3c, 45), style=shape.arrowdown, size=size.normal, text='Sell', textcolor=color.new(#e74c3c, 55))
plotshape(ShowSell and sslhit, title='SL Hit - Short', location=location.abovebar, offset=0, color=color.new(#fc2d01, 25), style=shape.arrowdown, size=size.normal, text='SL Hit - Short', textcolor=color.new(#fc2d01, 25))
plotshape(ShowSell and starhit, title='Target Hit - Short', location=location.belowbar, offset=0, color=color.new(color.green, 45), style=shape.arrowup, size=size.normal, text='Target Hit - Short', textcolor=color.new(color.green, 55))
plotshape(ShowBuy and Long, title='Buy', location=location.belowbar, offset=0, color=color.new(#2ecc71, 45), style=shape.arrowup, size=size.normal, text='Buy', textcolor=color.new(#2ecc71, 55))
plotshape(ShowBuy and lslhit, title='SL Hit - Long', location=location.belowbar, offset=0, color=color.new(#fc2d01, 25), style=shape.arrowdown, size=size.normal, text='SL Hit - Long', textcolor=color.new(#fc2d01, 25))
plotshape(ShowBuy and ltarhit, title='Target Hit - Long', location=location.abovebar, offset=0, color=color.new(color.green, 45), style=shape.arrowup, size=size.normal, text='Target Hit - Long', textcolor=color.new(color.green, 55))

if ShowSell and Short
    alert("Go Short@ " + str.tostring(sellat) + " : SL@ " + str.tostring(ssl) + " : Target@ " + str.tostring(star) + " ", alert.freq_once_per_bar )

if ShowBuy and Long
    alert("Go Long@ " + str.tostring(buyat) + " : SL@ " + str.tostring(lsl) + " : Target@ " + str.tostring(ltar) + " ", alert.freq_once_per_bar )

///// End of code

더 많은