기하급수적인 이동평균의 크로스오버 전략

저자:차오장, 날짜: 2024-01-12 14:04:37
태그:

img

기하급수적인 이동 평균 (EMA) 크로스오버는 일반적인 거래 신호입니다. 이 전략은 빠른 EMA와 느린 EMA의 크로스오버를 사용하여 거래 신호를 생성합니다. 구체적으로, 빠른 EMA가 느린 EMA를 넘을 때 긴 지위가 취해지고, 빠른 EMA가 느린 EMA를 넘을 때 짧은 지위가 취됩니다.

이 전략은 20일 EMA를 빠른 EMA로, 50일 EMA를 중간 EMA로, 200일 EMA를 느린 EMA로 사용합니다. 20일 EMA와 50일 EMA가 모두 200일 EMA를 넘을 때 긴 포지션을 취하고, 둘 다 그 아래를 넘을 때 짧은 포지션을 취합니다. 이것은 일부 잘못된 신호를 필터링하는 데 도움이됩니다.

전략 의 장점

  1. 이동평균의 크로스오버 전략은 간단하고 이해하기 쉽고 실행하기 쉽습니다.
  2. 여러 이동 평균 을 사용 하는 것 은 거짓 신호 를 필터링 하는 데 도움 이 될 수 있다
  3. 진입과 출입 신호가 명확합니다.

전략 의 위험

  1. 범위에 제한된 시장에서 잘못된 신호를 생성하는 경향이 있습니다.
  2. 이동 평균은 지연을 가지고 있으며 빠르게 회전하지 않을 수 있습니다.
  3. 폭발적인 움직임을 최대한 활용할 수 없습니다.

개선 방법

  1. 다양한 제품 및 시간 프레임에 대한 이동 평균 기간을 최적화하십시오.
  2. 부피와 볼링거 밴드 같은 필터를 추가합니다
  3. 유연성을 위해 트렌드 다음과 평균 회귀와 결합

요약

이동 평균 크로스오버 전략은 이해하기 쉽고 기초적인 양적 거래 전략 중 하나입니다. 이 구현은 도입 사례로 잘 사용됩니다. 그러나 라이브 거래에서 매개 변수는 최적화가 필요하며 신호를 필터하고 성능을 향상시키기 위해 더 고급 기술 지표가 추가되어야합니다.


/*backtest
start: 2023-01-05 00:00:00
end: 2024-01-11 00:00:00
period: 1d
basePeriod: 1h
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/
// © rt-maax

//@version=5

strategy(title = "rt maax EMA cross strategy", shorttitle = "rt maax ema ", overlay = true, precision = 8, max_bars_back = 200, pyramiding = 0, initial_capital = 100000, 
     currency = currency.USD, default_qty_type = strategy.cash, default_qty_value = 100000, commission_type = "percent", commission_value = 0.27)
fastema = ta.ema (close , 50)
fema=ta.ema(close,20)
slowema= ta.ema(close,200)
price = close

// === INPUT BACKTEST RANGE ===
fromMonth = input.int(defval = 1,    title = "From Month",  minval = 1, maxval = 12)
fromDay   = input.int(defval = 1,    title = "From Day",    minval = 1, maxval = 31)
fromYear  = input.int(defval = 2021, title = "From Year",   minval = 1970)
thruMonth = input.int(defval = 10,    title = "Thru Month",  minval = 1, maxval = 12)
thruDay   = input.int(defval = 25,    title = "Thru Day",    minval = 1, maxval = 31)
thruYear  = input.int(defval = 2112, title = "Thru Year",   minval = 1970)

// === INPUT SHOW PLOT ===
showDate  = input(defval = true, title = "Show Date Range")

// === FUNCTION EXAMPLE ===



longCondition1= ta.crossover (fema , fastema) 
longcondition2= fema> slowema
longcondition3=fastema>slowema


if (longCondition1 and longcondition2 and longcondition3 )
    stoploss=low*0.97
    takeprofit=high*1.12
    strategy.entry("Long Entry", strategy.long)
    strategy.exit ("exit","long",stop=stoploss,limit=takeprofit)
   


shortCondition1 = ta.crossunder (fema , fastema )
shortcondition2= fastema< slowema
shortcondition3= fema< slowema

if (shortCondition1 and shortcondition2 and shortcondition3 )
    stoploss=low*0.97 
    takeprofit=high*1.5
    strategy.entry("Short Entry", strategy.short)
    strategy.exit("exit","short",stop=stoploss,limit=takeprofit)






더 많은