이동 평균 크로스오버 전략

저자:차오장, 날짜: 2023-11-22 16:38:26
태그:

img

전반적인 설명

이동 평균 크로스오버 전략은 이동 평균을 기반으로 한 간단하면서도 효과적인 수치적 거래 전략이다. 빠른 이동 평균 라인과 느린 이동 평균 라인의 크로스오버를 사용하여 구매 및 판매 신호를 생성합니다. 빠른 라인이 아래에서 느린 라인을 통과하면 구매 신호가 생성됩니다. 빠른 라인이 위에서 느린 라인을 통과하면 판매 신호가 생성됩니다.

전략 논리

이 전략의 핵심 논리는 시장 트렌드를 판단하기 위해 이동 평균을 사용하는 데 있다. 이동 평균 자체는 무작위 시장 소음을 필터링하는 기능을 가지고 있다. 빠른 이동 평균은 가격 변화에 더 빨리 반응하고 최신 트렌드를 반영할 수 있으며 느린 이동 평균은 최신 가격 변화에 더 느리게 반응하고 중장기 트렌드를 나타낸다. 느린 라인을 통해 빠른 라인의 돌파는 단기 트렌드가 중장기 트렌드에 일치하도록 반전되어 거래 신호를 생성한다는 것을 의미한다.

구체적으로, 이 전략은 먼저 빠른 이동 평균 sig1과 느린 이동 평균 sig2를 정의하고, 그 다음 sig1과 sig2 사이의 교차 관계에 따라 구매 및 판매 포인트를 결정한다. sig1이 sig2를 아래로부터 뚫을 때, 긴 조건 longCondition이 생성된다. sig1이 위로부터 sig2를 뚫을 때, 짧은 조건 shortCondition이 생성된다. 전략은 긴 조건과 짧은 조건이 충족되면 주문을 배치하고, 종료 명령에 Stop Loss과 Take Profit을 설정한다.

이점 분석

이 전략의 장점은 크게 나타납니다.

  1. 간단한 논리, 이해하기 쉽고 실행하기 쉬운
  2. 유연한 매개 변수 조정, 다른 시장 조건 하에 최적화 될 수 있습니다
  3. 신호를 필터링하고 안정성을 향상시키기 위해 다른 지표와 결합 할 수 있습니다.
  4. 좋은 성능, 예를 들어 EMA15-EMA30 콤보는 EURCHF 일일 데이터에서 83% 승률을 달성 할 수 있습니다.

위험 분석

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

  1. 심각한 윙사 효과, 중지 손실 구성은 중요합니다.
  2. 차원, 측면 시장에서 낮은 성과
  3. 다양한 제품과 시간 프레임에 맞게 광범위한 테스트와 매개 변수 조정이 필요합니다.

최적화 조치:

  1. 심사를 위해 다른 지표를 추가 하 여 화이트사 를 피 합니다.
  2. 각종 제품에 맞게 MA 유형과 매개 변수를 조정합니다.
  3. 위험을 통제하기 위해 스톱 로스를 최적화하고 수익률을 취하십시오.

결론

일반적으로 이동 평균 크로스오버 전략은 간단한 논리, 강력한 실용성 및 안정성을 가진 양자 전략입니다. 매개 변수 조정 및 적절한 최적화로 다양한 시장 환경에서 안정적인 수익을 창출 할 수 있습니다. 양적 거래자에게 집중하고 적용 할 가치가 있습니다.


/*backtest
start: 2023-11-14 00:00:00
end: 2023-11-16 04:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
// Simple yet effective MA cross strategy.
// You'll have to tune the parameters to get an optimal win ratio.
// If JPY or XAU or any other currency with pips defined as the 
// second decimal digit are involved, do not forget to set the respective flag on.
//
// Created by vitelot/yanez/Vts, who's the same fellow with different user names
// December 2018 -- Merry Xmas
//
strategy("MA cross strategy Vts", overlay=true, initial_capital=1000, currency="EUR", pyramiding=0)

yr  = input(2016, title="Starting year to analyse")
src = input(close, title="Source")
maType = input( defval="EMA", title="MA Type", options=["SMA","EMA","HMA","McG","WMA"])
//
isJPY = input(false, title="Is JPY or XAU involved?") // JPY and Gold have the pips defined as the 2 decimal digit

maPar1 = input(26, minval=1, title="MA fast period")
maPar2 = input(51, minval=2, title="MA slow period")

atrPar = input(14,minval=1, title="ATR period")
atrMulSL = input(1.5, title="SL ATR multiplicator")
atrMulTP = input(1.0, title="TP ATR multiplicator")

hma(sig, n) => // Hull moving average definition
    wma( 2*wma(sig,round(n/2))-wma(sig,n), round(sqrt(n)))

mcg(sig,length) => // Mc Ginley MA definition
    mg = 0.0
    mg := na(mg[1]) ? ema(sig, length) : mg[1] + (sig - mg[1]) / (length * pow(sig/mg[1], 4))

ma(t,sig,len) =>
    if t =="SMA"
        sma(sig,len)
    else
        if t == "EMA"
            ema(sig,len)
        else
            if t == "HMA"
                hma(sig,len)
            else
                if t == "McG" // Mc Ginley
                    mcg(sig,len)
                else
                    wma(sig,len)
                    
        
sig1 = ma(maType, src, maPar1)
sig2 = ma(maType, src, maPar2)

tickFactor = isJPY? 1e3: 1e5
sl = atrMulSL*atr(atrPar)*tickFactor
tp = atrMulTP*atr(atrPar)*tickFactor

plot(sig1, color=aqua, title="MA1", linewidth=2)
plot(sig2, color=orange, title="MA2", linewidth=2)

longCondition = crossunder(sig2, sig1) and year>=yr // change the >= to == if you like exact years not a range
if (longCondition)
    strategy.entry("Long", strategy.long, qty=1) // exit trade when SL and TP are hit
    strategy.exit("Exit Long", "Long", loss=sl, profit=tp)
if (crossunder(sig1, sig2)) // or when the short condition is met
    strategy.close("Long")

shortCondition = crossover(sig2,sig1) and year>=yr // change the >= to == if you like exact years not a range
if (shortCondition)
    strategy.entry("Short", strategy.short, qty=1)
    strategy.exit("Exit Short", "Short", loss=sl, profit=tp)
if (crossover(sig1,sig2))
    strategy.close("Short")


더 많은