Elliott Wave Noise Filter

Phillipklh · study · 78 行 · 点赞 252 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// @version=5
indicator("Elliott Wave Noise Filter", shorttitle="EW Noise Filter", overlay=true)
 
// Einstellungen
lookback = input.int(14, "ATR Zeitraum", minval=1)
noiseThreshold = input.float(0.3, "Noise Threshold (% vom ATR)", minval=0.1, maxval=1.0, step=0.1)
useVolume = input.bool(true, "Volumen-Filter aktivieren")
volumeThreshold = input.float(0.8, "Volumen-Threshold (x durchschn. Vol.)", minval=0.5, maxval=2.0, step=0.1)
showHMA = input.bool(true, "Hull Moving Average anzeigen")
hullLength = input.int(21, "Hull MA Länge", minval=5, maxval=200)
 
// ADX für Trendstärke
adxLength = input.int(14, "ADX Länge", minval=5, maxval=50)
adxThreshold = input.int(20, "Minimale ADX für Trend", minval=10, maxval=50)
diLen = 14
dirmov(len) =>
    up = ta.change(high)
    down = -ta.change(low)
    truerange = ta.rma(ta.tr, len)
    plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange)
    minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) / truerange)
    [plus, minus]
 
[plus, minus] = dirmov(diLen)
adx = 100 * ta.rma(math.abs(plus - minus) / (plus + minus), adxLength)
 
// Indikator-Berechnungen
// 1. ATR für Volatilitätsmessung
atr = ta.atr(lookback)
priceChange = math.abs(close - close[1])
isNoiseByATR = priceChange < (atr * noiseThreshold)
 
// 2. Volumen-basierter Noise-Filter
avgVolume = ta.sma(volume, 20)
isNoiseByVolume = useVolume ? volume < (avgVolume * volumeThreshold) : false
 
// 3. Hull Moving Average für glatte Trendlinie
hma(src, length) => 
    wma1 = ta.wma(src, length / 2)
    wma2 = ta.wma(src, length)
    ta.wma(2 * wma1 - wma2, math.round(math.sqrt(length)))
 
hullMA = showHMA ? hma(close, hullLength) : na
 
// 4. Fraktale für bedeutende Hochs und Tiefs
isFractalTop = high[2] < high[1] and high[1] > high and high[1] > high[3] and high[1] > high[4]
isFractalBottom = low[2] > low[1] and low[1] < low and low[1] < low[3] and low[1] < low[4]
 
// Noise-Status bestimmen:
// 1. Wenn der Preis sich weniger als Threshold vom ATR bewegt, ist es Noise
// 2. Wenn das Volumen unterdurchschnittlich ist
// 3. Wenn ADX unter dem Threshold ist (kein klarer Trend)
isNoise = isNoiseByATR or isNoiseByVolume or adx < adxThreshold
 
// Hintergrund einfärben basierend auf Noise-Status
bgcolor(isNoise ? color.new(color.red, 90) : color.new(color.green, 90))
 
// Hull MA für Trendrichtung darstellen
plot(hullMA, "Hull MA", color=color.blue, linewidth=2)
 
// Fraktale markieren (potenzielle Elliott-Wellen-Punkte)
plotshape(isFractalTop and not isNoise, style=shape.triangledown, location=location.abovebar, 
         color=color.red, size=size.small)
plotshape(isFractalBottom and not isNoise, style=shape.triangleup, location=location.belowbar, 
         color=color.green, size=size.small)
 
// Informationen auf dem Chart anzeigen
var table infoTable = table.new(position.top_right, 3, 2, color.new(color.black, 80), 
                              border_width=1, border_color=color.gray)
 
if (barstate.islast)
    table.cell(infoTable, 0, 0, "Noise Status:", text_color=color.white)
    table.cell(infoTable, 1, 0, isNoise ? "NOISE DETECTED" : "CLEAR SIGNAL", 
               text_color=isNoise ? color.red : color.green, bgcolor=isNoise ? color.new(color.red, 80) : color.new(color.green, 80))
    
    table.cell(infoTable, 0, 1, "ADX:", text_color=color.white)
    table.cell(infoTable, 1, 1, str.tostring(adx, "#.##"), 
               text_color=adx < adxThreshold ? color.red : color.green)

← 返回列表