
この戦略は,Nadaraya-Watsonの核推定方法と移動平均の交差に基づいたトレンド追跡取引システムである.この戦略は,高士の核関数によって価格データをスムーズに処理し,移動平均の交差信号と組み合わせて,市場トレンドを捉え,取引をスマートにトレンド追跡する.この戦略は,パーセントポジション管理方式を採用し,デフォルトでは,取引ごとに10%の口座権益を使用する.
策略の核心は,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")