OPEN-SOURCE SCRIPT
تم تحديثه Exponential Nadaraya Watson kernel regression [Jamallo]

(2025)
Intro
Nadaraya-Watson (N-W) kernel regression is a non-parametric smoothing technique that estimates the underlying trend of a price series without assuming any fixed model shape (like a straight line or curve). Unlike a simple moving average which weights bars equally, or an EMA which applies a fixed exponential decay, N-W regression derives its curve by computing a weighted average of all prices within a lookback window — where the weights are determined by a kernel function.
The most common kernel used is the Gaussian kernel, which assigns weights in a bell-curve shape — prices closer to the center of the window receive higher weight, prices at the edges receive lower weight. Most N-W implementations use a pure symmetric Gaussian kernel, meaning every bar within the lookback window is weighted purely by its distance from the center, with no preference for recency.
This indicator uses a hybrid Exponential Nadaraya-Watson (ENW) kernel that combines two weighting forces simultaneously:
Both weights are multiplied together for each bar, meaning a price bar must be both spatially central and recent to receive maximum influence. In practice this shifts the effective weight peak toward the recent end of the window, making the K Line more responsive to current price action than standard N-W.
Breakdown
K Line — ENW Kernel Regression
The central baseline of the indicator. A smooth adaptive curve derived from the hybrid ENW kernel applied to closing prices. Bandwidth is controlled via the Kernel Length and Alpha inputs — higher alpha increases the recency bias, lower alpha brings behavior closer to standard N-W.
Volatility Bands (Inner & Outer)
Rather than using ATR or standard deviation for band width, this indicator measures the absolute deviation of price from the K Line and smooths that deviation through the same ENW kernel. This means bands are fully adaptive — they expand and contract organically based on how far price has been straying from the regression curve, not a fixed statistical formula. Inner and outer bands are independently scaled via deviation multipliers.
A Line — Vervoort ATR Stop
A trailing stop built on the HLC4 price source with an ATR-based loss distance. Flips direction on a close beyond the stop level. Serves as the primary trend bias line — when above the K Line the fill turns bullish, when below it turns bearish. Cross signals (triangles) are plotted whenever the A Line crosses the K Line, marking potential trend shifts.
Signal Line — Vervoort ATR Stop (Secondary)
A second independent Vervoort trailing stop running on its own ATR period and multiplier settings. Typically configured looser than the A Line — wider multiplier, longer or equal period — so it acts as a slower confirmation layer. Useful for filtering noise on the A Line crosses: an A Line cross that also aligns with the Signal Line's bias carries more weight than one that doesn't.
-------
Nadaraya-Watson kernel regression concept — E. Nadaraya (1964), G.S. Watson (1964)
Vervoort ATR Stop — Sylvain Vervoort
Intro
Nadaraya-Watson (N-W) kernel regression is a non-parametric smoothing technique that estimates the underlying trend of a price series without assuming any fixed model shape (like a straight line or curve). Unlike a simple moving average which weights bars equally, or an EMA which applies a fixed exponential decay, N-W regression derives its curve by computing a weighted average of all prices within a lookback window — where the weights are determined by a kernel function.
The most common kernel used is the Gaussian kernel, which assigns weights in a bell-curve shape — prices closer to the center of the window receive higher weight, prices at the edges receive lower weight. Most N-W implementations use a pure symmetric Gaussian kernel, meaning every bar within the lookback window is weighted purely by its distance from the center, with no preference for recency.
This indicator uses a hybrid Exponential Nadaraya-Watson (ENW) kernel that combines two weighting forces simultaneously:
- Gaussian spatial weight — bell-curve weighting centered on the window, same as standard N-W
- Exponential time-decay weight — progressively heavier weighting on recent bars, similar to how an EMA behaves
Both weights are multiplied together for each bar, meaning a price bar must be both spatially central and recent to receive maximum influence. In practice this shifts the effective weight peak toward the recent end of the window, making the K Line more responsive to current price action than standard N-W.
Breakdown
K Line — ENW Kernel Regression
The central baseline of the indicator. A smooth adaptive curve derived from the hybrid ENW kernel applied to closing prices. Bandwidth is controlled via the Kernel Length and Alpha inputs — higher alpha increases the recency bias, lower alpha brings behavior closer to standard N-W.
Volatility Bands (Inner & Outer)
Rather than using ATR or standard deviation for band width, this indicator measures the absolute deviation of price from the K Line and smooths that deviation through the same ENW kernel. This means bands are fully adaptive — they expand and contract organically based on how far price has been straying from the regression curve, not a fixed statistical formula. Inner and outer bands are independently scaled via deviation multipliers.
A Line — Vervoort ATR Stop
A trailing stop built on the HLC4 price source with an ATR-based loss distance. Flips direction on a close beyond the stop level. Serves as the primary trend bias line — when above the K Line the fill turns bullish, when below it turns bearish. Cross signals (triangles) are plotted whenever the A Line crosses the K Line, marking potential trend shifts.
Signal Line — Vervoort ATR Stop (Secondary)
A second independent Vervoort trailing stop running on its own ATR period and multiplier settings. Typically configured looser than the A Line — wider multiplier, longer or equal period — so it acts as a slower confirmation layer. Useful for filtering noise on the A Line crosses: an A Line cross that also aligns with the Signal Line's bias carries more weight than one that doesn't.
-------
Nadaraya-Watson kernel regression concept — E. Nadaraya (1964), G.S. Watson (1964)
Vervoort ATR Stop — Sylvain Vervoort
ملاحظات الأخبار
- tooltips, minor code sanitizing. نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.