
이동 평균 크로스 트레이딩 전략은 좀 더 흔한 양적 트레이딩 전략이다. 이 전략은 서로 다른 주기의 이동 평균을 계산하고, 그들의 교차 상황에 따라 거래 신호를 생성한다. 구체적으로, 4주기, 8주기, 그리고 20주기의 지수 이동 평균을 계산하는 것이다.
이 전략의 핵심 논리는 다음과 같습니다.
이 방법을 통해, 우리는 시장의 신호를 판단하기 위해 서로 다른 주기적 평균선 사이의 교차점을 이용하고, 가장 긴 주기적 평균선의 방향을 사용하여 잘못된 신호를 필터링하여 안정적인 거래 전략을 구축합니다.
이 전략은 다음과 같은 장점을 가지고 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
이 문제를 해결하기 위한 주요 해결책은 다음과 같습니다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
사이클 최적화: 다양한 품종에 따라 최적의 MA 사이클 조합을 결정
모델 융합: 더 많은 알파를 추출하기 위해 LSTM, RNN 등의 딥 러닝 모델과 통합
포트폴리오 최적화: 다른 지표와 전략 포트폴리오를 구성
이동 평균 횡단 전략은 전체적으로 고전적이고 일반적으로 사용되는 양적 거래 전략이다. 이 전략의 논리는 간단하고 이해하기 쉽고 구현되며 안정성이 있다. 그러나 가짜 신호를 생성하고 시장 변화에 적응하지 못하는 등의 문제가 있다. 이러한 문제는 변수 최적화, 스톱 로스 최적화, 모델 통합 등의 방법으로 개선될 수 있다.
/*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"}]
*/
//@version=3
//future strategy
//strategy(title = "stub", default_qty_type = strategy.fixed, default_qty_value = 1, overlay = true, commission_type=strategy.commission.cash_per_contract,commission_value=2.05)
//stock strategy
strategy(title = "stub", overlay = true)
//forex strategy
//strategy(title = "stub", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true)
//crypto strategy
//strategy(title = "stub", default_qty_type = strategy.percent_of_equity, default_qty_value = 100, overlay = true, commission_type=strategy.commission.percent,commission_value=.0,default_qty_value=10000)
testStartYear = input(1900, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(1, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testEndYear = input(2018, "Backtest Start Year")
testEndMonth = input(12, "Backtest Start Month")
testEndDay = input(1, "Backtest Start Day")
testPeriodEnd = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testPeriod() => true
ema1 = ema(close,4)
ema2 = ema(close,8)
ema3 = ema(close,20)
go_long = ema1[0] > ema2[0] and ema3[0] > ema3[1]
exit_long = ema1[0] < ema2[0] or ema3[0] < ema3[1]
go_short = ema1[0] < ema2[0] and ema3[0] < ema3[1]
exit_short = ema1[0] > ema2[0] or ema3[0] > ema3[1]
if testPeriod()
strategy.entry("simpleBuy", strategy.long, when=go_long)
strategy.exit("simpleBuy", "simpleSell",when=exit_long)
strategy.entry("simpleSell", strategy.short,when=go_short)
strategy.exit("simpleSell", "simpleSell",when=exit_short)