동력 이동 평균 크로스오버 거래 전략

저자:차오장, 날짜: 2024-01-24 11:09:58
태그:

img

전반적인 설명

이 전략은 빠른 이동 평균선과 느린 이동 평균선 사이의 교차를 기반으로 거래 신호를 생성하여 시장 추세와 입점 지점을 결정합니다. 빠른 EMA가 느린 EMA 위에 넘어가면 시장이 상승 추세에 있다고 판단되고 구매 신호가 생성됩니다. 빠른 EMA가 느린 EMA 아래에 넘어가면 시장이 하락 추세에 있다고 판단되며 판매 신호가 생성됩니다. 전략은 또한 위험을 관리하기 위해 스톱 로스를 설정하고 수익 가격을 취합니다.

전략 논리

이 전략은 시장 트렌드를 결정하기 위해 빠른 EMA (8일) 와 느린 EMA (21일) 사이의 교차를 사용합니다. 구체적인 논리는:

  1. 8일 EMA와 21일 EMA를 계산합니다
  2. 8일 EMA가 21일 EMA를 넘으면 시장 트렌드가 역전되고 상승 추세가 시작되었다는 것을 결정합니다.
  3. 8일 EMA가 21일 EMA를 넘으면 시장 트렌드가 역전되고 하향 트렌드가 시작되었다는 것을 결정합니다.
  4. 상승 추세 동안 구매 신호가 생성됩니다. 하락 추세 동안 판매 신호가 생성됩니다.
  5. 각 포지션의 위험을 관리하기 위해 스톱 로스 및 영업 가격을 설정합니다.

이 전략은 동력 지표와 트렌드 분석을 결합하여 시장 방향과 반전 지점을 효과적으로 파악합니다. 이동 평균과 함께 빠른 및 느린 EMA 크로스오버는 소름 끼치는 거래 신호를 필터링 할 수 있습니다.

이점 분석

이 전략의 주요 장점은 다음과 같습니다.

  1. 빠르고 느린 EMA 교차는 시장 추세와 거래 신호를 효과적으로 결정할 수 있습니다.
  2. EMA 기간을 더 조정 할 수있는 전략 매개 변수에 대한 큰 최적화 공간
  3. 소음 신호는 모멘텀 표시기를 통합함으로써 효과적으로 필터링 될 수 있습니다.
  4. 스톱 로스 및 영업 로직을 구성하여 적극적인 리스크 제어

요약하자면, 전략은 트렌드 및 모멘텀 지표를 결합합니다. 매개 변수 조정을 통해 다른 시장 환경에 적응 할 수 있으며 비교적 유연한 단기 거래 전략입니다.

위험 분석

이 전략에는 몇 가지 위험도 있습니다.

  1. 범위에 있는 시장에서 빈번한 EMA 크로스오버 신호는 더 많은 잘못된 거래를 유발할 수 있습니다.
  2. 격차 위험은 효과적으로 처리되지 않습니다
  3. 장기적 경향 방향은 고려되지 않습니다.

이러한 위험을 해결하기 위해 몇 가지 최적화가 이루어질 수 있습니다.

  1. 잘못된 신호를 줄이기 위해 볼링거 밴드, KDJ 같은 다른 필터를 추가합니다.
  2. 장기적 경향을 결정하기 위해 더 높은 시간 프레임 인디케이터를 포함
  3. 다른 시장에 적응하기 위해 EMA 길이와 같은 매개 변수를 최적화하십시오.
  4. 격차로 인한 거대한 미끄러짐 손실을 피하기 위해 수동 개입

최적화 방향

이 전략을 최적화 할 수있는 많은 공간이 있습니다.

  1. 역사적인 성과에 기초한 EMA 기간 매개 변수를 최적화
  2. 신호 필터링을 위한 다른 기술적 지표, 예를 들어 KDJ, MACD를 추가하여 정확도를 향상시킵니다.
  3. 시장 특성에 더 잘 맞는 스톱 로스 및 수익 설정 최적화
  4. 자동화된 매개 변수 최적화를 위해 기계 학습 기술을 사용

이러한 조치는 전략의 안정성, 적응력 및 수익성을 크게 향상시킬 수 있습니다.

결론

결론적으로, 이것은 트렌드 추종과 모멘텀 지표의 교차를 기반으로 한 전형적인 단기 거래 전략이다. EMA 크로스오버 논리와 스톱 로스/프로피트를 결합하여 방향 시장 기회를 빠르게 포착합니다. 다른 보조 지표와 자동 매개 변수 조정 방법을 도입하여 최적화 할 수있는 충분한 공간이 있습니다. 이는 전략 성능을 더 안정적이고 뛰어난 것으로 만들 수 있습니다. 시장에 대한 약간의 이해와 자주 거래하려는 투자자에게 적합합니다.


/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 1h
basePeriod: 15m
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/
// © TradersPostInc

//@version=5
strategy('TradersPost Example MOMO Strategy', overlay=true)

startTime = input(defval = timestamp('01 Jan 2021 00:00 +0000'), title = 'Start Time', group = 'Date Range')
endTime = input(defval = timestamp('31 Dec 2023 23:59 +0000'), title = 'End Time', group = 'Date Range')
timeCondition = true
timeConditionEnd = timeCondition[1] and not timeCondition

fastEmaLength = input.int(defval = 8, title = 'Fast EMA Length')
slowEmaLength = input.int(defval = 21, title = 'Slow EMA Length')
sides = input.string(defval = 'Both', title = 'Sides', options = ['Long', 'Short', 'Both', 'None'])

fastEma = ta.ema(close, fastEmaLength)
slowEma = ta.ema(close, slowEmaLength)

isUptrend = fastEma >= slowEma
isDowntrend = fastEma <= slowEma
trendChanging = ta.cross(fastEma, slowEma)

ema105 = request.security(syminfo.tickerid, '30', ta.ema(close, 105)[1], barmerge.gaps_off, barmerge.lookahead_on)
ema205 = request.security(syminfo.tickerid, '30', ta.ema(close, 20)[1], barmerge.gaps_off, barmerge.lookahead_on)
plot(ema105, linewidth=4, color=color.new(color.purple, 0), editable=true)
plot(ema205, linewidth=2, color=color.new(color.purple, 0), editable=true)

aa = plot(fastEma, linewidth=3, color=color.new(color.green, 0), editable=true)
bb = plot(slowEma, linewidth=3, color=color.new(color.red, 0), editable=true)
fill(aa, bb, color=isUptrend ? color.green : color.red, transp=90)

tradersPostBuy = trendChanging and isUptrend and timeCondition
tradersPostSell = trendChanging and isDowntrend and timeCondition

pips = syminfo.pointvalue / syminfo.mintick

percentOrPipsInput = input.string('Percent', title='Percent or Pips', options=['Percent', 'Pips'])

stopLossLongInput = input.float(defval=0, step=0.01, title='Stop Loss Long', minval=0)
stopLossShortInput = input.float(defval=0, step=0.01, title='Stop Loss Short', minval=0)

takeProfitLongInput = input.float(defval=0, step=0.01, title='Target Profit Long', minval=0)
takeProfitShortInput = input.float(defval=0, step=0.01, title='Target Profit Short', minval=0)

stopLossPriceLong = ta.valuewhen(tradersPostBuy, close, 0) * (stopLossLongInput / 100) * pips
stopLossPriceShort = ta.valuewhen(tradersPostSell, close, 0) * (stopLossShortInput / 100) * pips

takeProfitPriceLong = ta.valuewhen(tradersPostBuy, close, 0) * (takeProfitLongInput / 100) * pips
takeProfitPriceShort = ta.valuewhen(tradersPostSell, close, 0) * (takeProfitShortInput / 100) * pips

takeProfitALong = takeProfitLongInput > 0 ? takeProfitLongInput : na
takeProfitBLong = takeProfitPriceLong > 0 ? takeProfitPriceLong : na

takeProfitAShort = takeProfitShortInput > 0 ? takeProfitShortInput : na
takeProfitBShort = takeProfitPriceShort > 0 ? takeProfitPriceShort : na

stopLossALong = stopLossLongInput > 0 ? stopLossLongInput : na
stopLossBLong = stopLossPriceLong > 0 ? stopLossPriceLong : na

stopLossAShort = stopLossShortInput > 0 ? stopLossShortInput : na
stopLossBShort = stopLossPriceShort > 0 ? stopLossPriceShort : na

takeProfitLong = percentOrPipsInput == 'Pips' ? takeProfitALong : takeProfitBLong
stopLossLong = percentOrPipsInput == 'Pips' ? stopLossALong : stopLossBLong
takeProfitShort = percentOrPipsInput == 'Pips' ? takeProfitAShort : takeProfitBShort
stopLossShort = percentOrPipsInput == 'Pips' ? stopLossAShort : stopLossBShort

buyAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "buy", "price": ' + str.tostring(close) + '}'
sellAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "sell", "price": ' + str.tostring(close) + '}'

exitLongAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "exit", "price": ' + str.tostring(close) + '}'
exitShortAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "exit", "price": ' + str.tostring(close) + '}'

if (sides != "None")
    if tradersPostBuy
        strategy.entry('Long', strategy.long, when = sides != 'Short', alert_message = buyAlertMessage)
        strategy.close('Short', when = sides == "Short" and timeCondition, alert_message = exitShortAlertMessage)

    if tradersPostSell
        strategy.entry('Short', strategy.short, when = sides != 'Long', alert_message = sellAlertMessage)
        strategy.close('Long', when = sides == 'Long', alert_message = exitLongAlertMessage)

exitAlertMessage = '{"ticker": "' + syminfo.ticker + '", "action": "exit"}'

strategy.exit('Exit Long', from_entry = "Long", profit = takeProfitLong, loss = stopLossLong, alert_message = exitAlertMessage)
strategy.exit('Exit Short', from_entry = "Short", profit = takeProfitShort, loss = stopLossShort, alert_message = exitAlertMessage)

strategy.close_all(when = timeConditionEnd)

더 많은