
이 전략은 Nadaraya-Watson 핵 추정 방법과 이동 평균의 교차에 기반한 트렌드 추적 거래 시스템이다. 이 전략은 고스 핵 함수를 통해 가격 데이터를 부드럽게 처리하고, 이동 평균의 교차 신호와 결합하여 시장의 흐름을 포착하고, 지능화된 트렌드 추적 거래를 구현한다. 이 전략은 백분율 포지션 관리 방식을 채택하고, 기본적으로 매 거래마다 10%의 계정 이득을 사용한다.
전략의 핵심은 Nadaraya-Watson 핵 추정 방법이며, 이 방법은 고스 핵 함수를 사용하여 가격 데이터를 비변수적으로 매끄럽게합니다. 구체적인 구현에는 다음과 같은 단계가 포함됩니다:
이 전략은 혁신적으로 Nadaraya-Watson 핵 추정과 전통적인 기술 분석을 결합하여 견고한 트렌드 추적 시스템을 구축합니다. 고스 핵 평준화 및 이동 평균 교차를 통해 시장 추세를 효과적으로 포착하고 위험을 제어합니다. 이 전략은 더 나은 확장성과 최적화 공간을 가지고 있으며 추가 개발 및 실제 응용에 적합합니다.
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © UniCapInvest
//@version=5
strategy("Nadaraya-Watson Strategy with Moving Average Crossover", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10, max_bars_back=500)
// Girdiler
h = input.float(8.,'Bandwidth', minval = 0)
src = input(close,'Source')
lookback = input.int(15, "Moving Average Lookback", minval=1)
// Gaussian fonksiyonu
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))
// Nadaraya-Watson smoothed değerini hesaplama
var float smoothed = na
sum_w = 0.0
sum_xw = 0.0
for i = 0 to 499
w = gauss(i, h)
sum_w += w
sum_xw += src[i] * w
smoothed := sum_w != 0 ? sum_xw / sum_w : na
// Hareketli ortalama hesaplama
ma = ta.sma(smoothed, lookback)
// Alım ve satım koşulları (kesişimlere göre)
longCondition = ta.crossover(smoothed, ma)
shortCondition = ta.crossunder(smoothed, ma)
// Pozisyon durumu
var bool inPosition = false
// Strateji giriş ve çıkış koşulları
if (longCondition and not inPosition)
strategy.entry("Long", strategy.long)
inPosition := true
if (shortCondition and inPosition)
strategy.entry("Short", strategy.short)
inPosition := false
// Plotting
plot(smoothed, color=color.blue, title="Nadaraya-Watson Smoothed")
plot(ma, color=color.red, title="Moving Average")