OPEN-SOURCE SCRIPT
ML Kernel Regression + EMA Trend

// This work is based on concepts by Uptrick
// Modified and updated by marjyhen1921
[ML] Nadaraya-Watson Kernel Regression (Multi-EMA Filter Edition)
Overview
This indicator features a Non-Parametric Machine Learning estimator based on the Nadaraya-Watson (NW) Kernel Regression. Unlike traditional moving averages that rely on fixed time-windows, this model uses a Gaussian Kernel to assign weights to historical data points, effectively estimating the underlying price trend with minimal lag.
Credits & Inspiration
Special thanks to Uptrick for the original logic and the machine learning concepts that inspired this implementation. This version has been refined for Pine Script V6 with added multi-filter flexibility.
What’s New:
Triple EMA Filter System: To help traders avoid "whipsaws" in sideways markets, I have integrated independent toggles for EMA 9, EMA 20, and EMA 50.
Default "No Filter" Mode: The script starts with all filters disabled, allowing for pure ML signal analysis out of the box.
Dynamic Volatility Bands: The bands are calculated based on the standard deviation of residuals (price error relative to the kernel), providing a "confidence interval" for price movement.
How to Use:
Mean Reversion: Trade the "B" (Buy) and "S" (Sell) labels when price breaks out of the upper/lower bands and the kernel flips color.
Trend Alignment: In the settings, enable the EMA filter of your choice. A Buy signal will only trigger if the price is above your selected EMA; a Sell signal will only trigger if it is below.
Customization: Use the "Visuals" section to show or hide the EMA lines and change the lookback windows to fit your timeframe.
// Modified and updated by marjyhen1921
[ML] Nadaraya-Watson Kernel Regression (Multi-EMA Filter Edition)
Overview
This indicator features a Non-Parametric Machine Learning estimator based on the Nadaraya-Watson (NW) Kernel Regression. Unlike traditional moving averages that rely on fixed time-windows, this model uses a Gaussian Kernel to assign weights to historical data points, effectively estimating the underlying price trend with minimal lag.
Credits & Inspiration
Special thanks to Uptrick for the original logic and the machine learning concepts that inspired this implementation. This version has been refined for Pine Script V6 with added multi-filter flexibility.
What’s New:
Triple EMA Filter System: To help traders avoid "whipsaws" in sideways markets, I have integrated independent toggles for EMA 9, EMA 20, and EMA 50.
Default "No Filter" Mode: The script starts with all filters disabled, allowing for pure ML signal analysis out of the box.
Dynamic Volatility Bands: The bands are calculated based on the standard deviation of residuals (price error relative to the kernel), providing a "confidence interval" for price movement.
How to Use:
Mean Reversion: Trade the "B" (Buy) and "S" (Sell) labels when price breaks out of the upper/lower bands and the kernel flips color.
Trend Alignment: In the settings, enable the EMA filter of your choice. A Buy signal will only trigger if the price is above your selected EMA; a Sell signal will only trigger if it is below.
Customization: Use the "Visuals" section to show or hide the EMA lines and change the lookback windows to fit your timeframe.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.