삼중 이동 평균 크로스오버 전략

저자:차오장, 날짜: 2023-11-06 09:48:33
태그:

img

전반적인 설명

트리플 이동 평균 크로스오버 전략은 트렌드를 따르는 전략에 속하는 다른 기간 동안 이동 평균의 크로스오버를 거래 신호로 사용합니다. 단기, 중기 및 장기 이동 평균을 포함한 세 개의 이동 평균을 사용하여 크로스오버를 기반으로 거래 신호를 생성합니다.

전략 논리

우선 전략은 단기 (7일 기본), 중기 (25일 기본) 및 장기 (99일 기본) 이동 평균을 계산하고 다음 규칙에 따라 거래 신호를 생성합니다.

  1. 단기 MA가 중기 MA를 넘으면 구매 신호가 생성됩니다.

  2. 단기 MA가 중기 MA보다 낮을 때 판매 신호가 생성됩니다.

  3. 단기 MA가 장기 MA를 넘으면 빠른 구매 신호가 생성됩니다.

  4. 단기 MA가 장기 MA보다 낮을 때 빠른 판매 신호가 생성됩니다.

전략은 중장기 MA보다 짧은 기간 MA가 상승세를 나타내고 구매 신호가 생성된다는 것을 믿습니다. 중장기 MA보다 짧은 기간 MA가 하락세를 나타내고 판매 신호가 생성됩니다. 마찬가지로, 단기 MA와 장기 MA 사이의 크로스오버는 장기적인 트렌드 변화를 포착하기 위해 빠른 거래 신호를 생성합니다.

이점 분석

  • 전략 논리는 간단하고 이해하기 쉽고 구현하기 쉽습니다.

  • 다중 시간 프레임 분석을 사용하면 시장 트렌드의 변화를 효과적으로 파악할 수 있습니다.

  • 그 매개 변수들은 MA 기간을 조정함으로써 최적화될 수 있다.

  • 시각적 크로스오버 신호는 직관적으로 트렌드 변화를 반영합니다.

위험 분석

  • MAs는 문제가 뒤떨어지고 트렌드 반전 지점을 놓칠 수 있습니다.

  • 불시장에서 단기 MA가 장기 MA를 넘을 때 너무 많은 잘못된 신호가 있습니다.

  • 마이너 시장에서 단기 MA가 장기 MA보다 낮을 때 너무 많은 잘못된 신호가 있습니다.

  • 빠른 거래 신호는 너무 민감해 거래 빈도와 수수료를 증가시킬 수 있습니다.

MA 기간의 적절한 조정 또는 필터 조건을 추가하면 잘못된 신호를 최적화하고 줄이는 데 도움이 될 수 있습니다. 빠른 거래 기간을 단축하면 거래 빈도가 낮아질 수 있습니다.

최적화 방향

  • 특정 거래량이나 가격 변화 비율을 충족할 때만 신호를 생성하는 것과 같은 필터 조건을 추가합니다.

  • MACD, KDJ 같은 다른 지표와 결합하여 명확한 추세가 없을 때 잘못된 거래를 피합니다.

  • 잘못된 신호를 줄이기 위해 MA 기간 조합을 최적화합니다.

  • 황소시장과 곰시장을 구분하고 매입과 매출 매개 변수를 최적화합니다.

  • 거래 비용을 고려하고, 빠른 거래 매개 변수를 조정하여 주파수를 조절합니다.

요약

트리플 MA 크로스오버 전략은 상대적으로 간단하며, 트레이딩 신호를 생성하기 위해 다른 시간 프레임 MA의 크로스오버를 통해 트렌드 방향을 판단합니다. 트렌드 변화를 포착하기 위해 유연한 매개 변수 조정으로 구현하기가 쉽습니다. 그러나 MA 지연 및 과도한 잘못된 신호의 문제도 있습니다. 필터 추가 및 매개 변수 조합 최적화와 같은 방법은 전략을 향상시킬 수 있습니다. 최적화 및 응용을 위해 트렌드 크로스오버에 관심이있는 거래자에게 적합합니다.


/*backtest
start: 2023-10-06 00:00:00
end: 2023-11-05 00:00:00
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/
// © dadashkadir

//@version=4
strategy("Üç Hareketli Ortalama Str.", overlay=true, initial_capital=10000, commission_value=0.047, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding=0, calc_on_order_fills=true)

kisa = input(title = "Kısa Vade - Gün", defval = 7,  minval = 1)
orta = input(title = "Orta Vade - Gün", defval = 25, minval = 1)
uzun = input(title = "Uzun Vade - Gün", defval = 99, minval = 1)

sma7  = sma(close, kisa)
sma25 = sma(close, orta)
sma99  = sma(close, uzun)

alTrend  = plot (sma7, color=#2323F1, linewidth=2, title="Har.Ort. Kısa Vade", transp=0)
satTrend = plot (sma25, color=#FF0C00, linewidth=3, title="Har.Ort. Orta Vade", transp=0)
ort99    = plot (sma99, color=#DFB001, linewidth=3, title="Har.Ort. Uzun Vade", transp=0)

zamanaralik = input (2020, title="Backtest Başlangıç Tarihi")

al  = crossover (sma7, sma25) and zamanaralik <= year
sat = crossover (sma25, sma7) and zamanaralik <= year

hizlial = crossover (sma7, sma99) and zamanaralik <= year
hizlisat = crossover (sma99, sma7) and zamanaralik <= year

alkosul  = sma7 >= sma25
satkosul = sma25 >= sma7

hizlialkosul  = sma7 >= sma99
hizlisatkosul = sma99 >= sma7

plotshape(al,  title = "Buy",  text = 'Al',  style = shape.labelup,   location = location.belowbar, color= color.green, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(sat, title = "Sell", text = 'Sat', style = shape.labeldown, location = location.abovebar, color= color.red,   textcolor = color.white, transp = 0, size = size.tiny)

plotshape(hizlial,  title = "Hızlı Al",  text = 'Hızlı Al',  style = shape.labelup,   location = location.belowbar, color= color.blue, textcolor = color.white, transp = 0, size = size.tiny)
plotshape(hizlisat, title = "Hızlı Sat", text = 'Hızlı Sat', style = shape.labeldown, location = location.abovebar, color= #6106D6 , textcolor = color.white, transp = 0, size = size.tiny)

fill (alTrend, satTrend, color = sma7 >= sma25? #4DFF00 : #FF0C00, transp=80, title="Al-Sat Aralığı")
//fill (ort99, satTrend, color = sma7 >= sma25? #6106D6 : color.blue, transp=80, title="Hızlı Al-Sat Aralığı")

if (al)
    strategy.entry("LONG", strategy.long)
if (sat)
    strategy.entry("SHORT", strategy.short)
//if (hizlial)
//    strategy.entry("My Short Entry Id", strategy.long)
//if (hizlisat)
//    strategy.entry("My Short Entry Id", strategy.short)    

더 많은