
삼평선 교차 전략은 다른 시간 주기 이동 평균의 교차를 구매 및 판매 신호로 사용하여 트렌드 추적 전략에 속한다. 이 전략은 단기 이동 평균, 중기 이동 평균 및 장기 이동 평균을 포함한 세 가지 이동 평균을 사용하여 거래 신호를 형성합니다.
이 전략은 먼저 단기 이동 평균 (기본 7일), 중기 이동 평균 (기본 25일), 장기 이동 평균 (기본 99일) 을 계산하고 다음 규칙에 따라 거래 신호를 생성합니다.
단기 이동 평균에서 중기 이동 평균을 통과할 때 구매 신호가 발생한다.
단기 이동 평균 아래에서 중기 이동 평균을 통과할 때, 판매 신호가 발생한다.
단기 이동 평균 위에 장기 이동 평균을 뚫을 때 빠른 구매 신호가 발생한다.
단기 이동 평균 아래에서 장기 이동 평균을 뚫을 때, 빠른 판매 신호가 발생한다.
이 전략은, 단기 이동 평균 상의 중간 이동 평균을 가로지르는 것은 시장의 추세가 상승으로 전환되어 구매 신호를 생성하는 것을 나타냅니다. 단기 이동 평균 아래의 중간 이동 평균을 가로지르는 것은 시장의 추세가 하락으로 전환되어 판매 신호를 생성하는 것을 나타냅니다. 마찬가지로, 단기 이동 평균과 장기 이동 평균의 교차는 긴 선의 추세 변화를 포착하기 위해 빠른 거래 신호를 생성합니다.
이동 평균 주기를 적절히 조정하거나 필터링 조건을 추가하여 최적화하여 가짜 신호를 줄일 수 있다. 빠른 거래 주기를 적절히 단축하여 거래 빈도를 줄일 수도 있다.
삼평선 교차전략은 전체적으로 간단하고 직접적이며, 다른 시간 주기의 평행선의 교차를 통해 트렌드 방향을 결정하여 거래 신호를 생성한다. 이 전략은 구현하기 쉽고, 변수를 조정하는 것이 유연하며, 트렌드의 변화를 잡을 수 있다. 그러나 이동 평균 지연의 문제가 있으며, 가짜 신호가 너무 많은 위험이 있다. 필터 조건을 추가하고, 변수 조합을 최적화하는 방법 등으로 전략의 효과를 개선할 수 있다.
/*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)