이동평균 교차 전략


생성 날짜: 2024-01-12 14:04:37 마지막으로 수정됨: 2024-01-12 14:04:37
복사: 0 클릭수: 615
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이동평균 교차 전략

이동 평균의 교차는 일반적인 거래 신호이다. 이 전략은 빠른 이동 평균과 느린 이동 평균의 교차를 거래 신호로 사용합니다. 구체적으로, 빠른 이동 평균이 아래에서 느린 이동 평균을 통과 할 때, 더 많이; 빠른 이동 평균이 위에서 아래에서 느린 이동 평균을 통과 할 때, 공백.

이 전략은 20일 기하급수적인 이동 평균 (EMA) 을 빠른 이동 평균으로, 50일 EMA를 중속선으로, 그리고 20일 EMA를 느린 이동 평균으로 사용합니다. 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 하고, 20일 EMA와 50일 EMA가 동시에 200일 EMA를 상회할 때 더 많은 것을 합니다.

전략적 이점

  1. 이동 평균 전략은 간단하고 이해하기 쉽고 실행이 가능합니다.
  2. 여러 이동 평균 조합을 사용하여 가짜 신호를 필터링 할 수 있습니다.
  3. 다공간 조건이 명확하고 출전 시기를 판단하기 쉽다.

전략적 위험

  1. “이런 일이 벌어진다면, 우리는 그 사실을 알 수 있을 것입니다”.
  2. 이동 평균은 가격 전환을 적시에 잡지 못하여 지연되어 있습니다.
  3. 이 사건의 결과는, 이 사건으로 인해 벌어진 수익을 제대로 활용하지 못한다는 것입니다.

더 나은 생각

  1. 이동 평균의 주기 변수를 최적화하여 다양한 품종과 주기에 적합합니다.
    1. 거래량, 브린 띠 등과 같은 다른 지표 필터 신호를 추가하십시오.
  2. 트렌드와 역전 전략의 조합으로, 트렌드 시나리오를 추적하고, 재조정 시 기회를 기다립니다.

요약하다

이동 평균 경로 전략 개념은 간단하고 쉽게 익힐 수 있으며, 수량 거래의 기본 전략 중 하나이다. 이 전략은 입문 학습으로서 좋은 참고 가치가 있다. 그러나 실전에서는 여전히 품종과 주기에 대한 파라미터 최적화가 필요하며, 다른 더 복잡한 기술 지표와 함께 신호를 필터링하여 전략의 실전 효과를 향상시킨다.

전략 소스 코드
/*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)