NLMS Adaptive Trend Filter [BackQuant]NLMS Adaptive Trend Filter
Overview
The NLMS Adaptive Trend Filter is a machine learning inspired trend-following indicator built around one of the most important adaptive filtering algorithms in signal processing: the Normalized Least Mean Squares (NLMS) filter .
Unlike traditional moving averages that use fixed weighting schemes, the NLMS filter continuously learns from incoming market data and updates its internal coefficients in real time. Rather than assuming that price behavior remains constant, the filter attempts to adapt its structure as market conditions evolve.
This approach originates from the field of digital signal processing, where adaptive filters have been used for decades in applications such as:
• Telecommunications
• Radar systems
• Echo cancellation
• Noise reduction
• Speech processing
• Control systems
• Financial signal extraction
The goal of this indicator is to bring one of these adaptive filtering concepts into market analysis by creating a trend model that continually adjusts itself based on prediction error rather than relying on static averaging methods.
Historical Background
The roots of the NLMS filter can be traced back to the work of Bernard Widrow and Ted Hoff in the late 1950s and early 1960s.
While working at Stanford University, they developed what became known as the:
Least Mean Squares (LMS) Algorithm
The LMS algorithm was revolutionary because it provided a computationally simple method for training adaptive systems using gradient descent.
Rather than solving a complex optimization problem all at once, the LMS algorithm updates its weights incrementally after each observation.
The basic concept was:
1. Make a prediction.
2. Measure the prediction error.
3. Adjust the model slightly.
4. Repeat indefinitely.
This idea eventually became one of the foundational concepts behind modern machine learning and online optimization.
Many modern neural networks still rely on the same underlying principle:
Error → Gradient → Weight Update
The LMS algorithm later evolved into several variants, one of the most important being:
Normalized Least Mean Squares (NLMS)
NLMS improves stability by scaling weight updates according to the energy of the input signal.
This prevents learning rates from becoming too aggressive during high-volatility periods and too weak during low-volatility periods.
As a result, NLMS became one of the most widely used adaptive filtering algorithms in engineering.
What Makes NLMS Different From Moving Averages?
Traditional moving averages use predetermined weights.
For example:
Simple Moving Average (SMA)
Every observation receives equal weight.
Example:
20-period SMA
Each bar contributes:
1 / 20 = 5%
regardless of market conditions.
Exponential Moving Average (EMA)
Recent observations receive more weight.
The weighting structure is fixed and never changes.
Weighted Moving Average (WMA)
Uses linearly decreasing weights.
Again, the weighting scheme is fixed.
The problem is that markets do not operate under fixed conditions.
Volatility changes.
Trend persistence changes.
Noise levels change.
Market structure changes.
Yet traditional moving averages continue using the exact same weighting model.
NLMS takes a different approach.
Instead of assigning permanent weights, it learns them dynamically.
The filter constantly asks
"What weighting structure would have predicted the current market best?"
It then updates itself accordingly.
The Core Idea Behind Adaptive Filters
Imagine trying to forecast today's price using the previous 20 bars.
A normal moving average assumes a fixed weighting pattern.
An adaptive filter attempts to learn the optimal weighting pattern.
At every bar:
• A prediction is generated.
• Actual price is observed.
• Prediction error is measured.
• Weights are adjusted.
The process repeats indefinitely.
Over time, the filter learns which historical observations are most useful and which are less important.
Understanding Filter Taps
One of the most important concepts in adaptive filtering is the idea of:
Taps
A tap is simply a historical observation used as an input.
If the indicator uses:
20 taps
it means:
Price
Price
Price
...
Price
are all being used to generate the prediction.
Each tap receives a learned weight.
Instead of:
Current Estimate =Average of past 20 bars
the filter becomes:
Current Estimate =
(w1 × Price ) +
(w2 × Price ) +
(w3 × Price )
...
(w20 × Price )
The weights are continuously adjusted through learning.
How Prediction Works
The indicator attempts to estimate current price using previous observations.
Mathematically:
Prediction = Σ(weight × historical price)
This prediction becomes the filter output.
If the prediction is accurate:
Weights change very little.
If the prediction is poor:
Weights adjust more aggressively.
This allows the model to gradually adapt to changing market conditions.
Prediction Error
The engine measures:
Error = Actual Price − Predicted Price
This error drives all learning.
Large error means:
The model is wrong.
Small error means:
The model is performing well.
The objective is to minimize prediction error over time.
The LMS Learning Rule
The original LMS update rule is:
New Weight =Old Weight + Learning Rate × Error × Input
This is effectively a form of gradient descent.
The filter moves its weights in the direction that reduces future prediction error.
This is conceptually identical to many machine learning optimization methods.
Why Normalization Matters
The original LMS algorithm has a weakness.
When input values become very large:
Weight updates can become unstable.
This is particularly problematic in financial markets where volatility constantly changes.
NLMS solves this problem by normalizing updates according to signal energy.
Instead of:
Weight Update ∝ Error
it becomes:
Weight Update ∝ Error / Signal Power
This creates adaptive scaling.
When volatility expands:
Updates automatically shrink.
When volatility contracts:
Updates automatically expand.
This improves stability significantly.
How the Indicator Uses NLMS
The script implements an online one-step predictor.
For every new bar:
1. Previous M bars are gathered.
2. Current price is predicted.
3. Prediction error is calculated.
4. Weight vector is updated.
5. New estimate becomes available.
This process occurs continuously as new data arrives.
Because no future data is used, the filter remains fully causal and suitable for live trading.
Weight Initialization
Initially all weights are equal:
1 / M
This effectively starts the model as a simple moving average.
Over time the filter learns a custom weighting structure based on market behavior.
The initial equal-weight state acts as a neutral prior.
Step Size (μ)
The learning rate controls how aggressively the filter adapts.
Lower values:
• More stable
• Smoother output
• Slower adaptation
Higher values:
• Faster adaptation
• More responsiveness
• Greater noise sensitivity
Think of μ as controlling the intelligence speed of the model.
Small values make it conservative.
Large values make it reactive.
Regularization (ε)
Regularization prevents division by very small values.
Without it:
Periods of extremely low signal power could create unstable updates.
Regularization improves numerical stability and robustness.
It acts as a safety mechanism for the learning process.
Output Smoothing
After the NLMS estimate is generated, an optional EMA can be applied.
This smoothing is not part of the NLMS algorithm itself.
It exists purely for visual clarity.
The raw adaptive filter already contains the learning logic.
The smoothing stage simply reduces small fluctuations.
Setting smoothing to 1 effectively disables it.
Trend Detection
Trend direction is derived from the slope of the adaptive filter.
Bullish:
NLMS Output > Previous Output
Bearish:
NLMS Output < Previous Output
This creates a directional state machine.
Unlike crossover systems, trend changes occur whenever the adaptive estimate changes slope.
Bullish Flips
A bullish signal occurs when:
Trend changes from bearish to bullish.
This means the adaptive filter has transitioned from declining to rising.
Bearish Flips
A bearish signal occurs when:
Trend changes from bullish to bearish.
This means the adaptive filter has transitioned from rising to falling.
Visual Components
The indicator includes several visualization layers.
Adaptive Filter Line
The main output of the NLMS model.
This represents the learned trend estimate.
Gradient Fill
The space between price and filter is colorized.
Price Above Filter:
Bullish shading.
Price Below Filter:
Bearish shading.
This provides immediate visual context regarding trend alignment.
Edge Glow
An ATR-based glow surrounds price.
This helps emphasize directional conditions while improving chart readability.
Trend Candles
Candles can optionally inherit trend coloration.
Green:
Adaptive trend rising.
Red:
Adaptive trend falling.
This allows traders to visualize the model's directional state directly on price.
How It Differs From Traditional Trend Filters
Most trend indicators answer:
"What is the average price?"
NLMS attempts to answer:
"What weighting structure best predicts current price?"
This distinction is extremely important.
The indicator is not simply smoothing price.
It is continuously learning how price behaves.
Traditional indicators use fixed mathematics.
NLMS uses adaptive mathematics.
Strengths
• Self-adjusting weighting structure.
• Adapts to changing market conditions.
• Based on established signal-processing theory.
• Stable due to normalization.
• Less reliant on arbitrary moving-average formulas.
• Learns continuously.
• Fully causal and non-lookahead.
Limitations
• Not a predictive model in the forecasting sense.
• Can still lag during major regime shifts.
• Excessively large learning rates may introduce noise.
• Small tap counts can become unstable.
• Large tap counts can become sluggish.
Like all adaptive systems, there is a tradeoff between responsiveness and stability.
Best Use Cases
The NLMS Adaptive Trend Filter is particularly effective for:
• Trend identification.
• Regime classification.
• Dynamic support/resistance visualization.
• Adaptive trend following.
• Noise reduction.
• Signal confirmation.
Summary
The NLMS Adaptive Trend Filter applies one of the most important adaptive algorithms in modern signal processing to financial markets. Rather than relying on fixed moving-average weights, it continuously learns from prediction error and updates its internal model in real time. Built upon the pioneering work of Widrow and Hoff, the indicator combines adaptive filtering, normalized gradient descent, and online learning principles into a practical trend-following tool that evolves alongside changing market conditions. The result is a trend model that is fundamentally different from traditional moving averages, not because it smooths price differently, but because it learns how to smooth price as new information arrives.
Indicator

Indicator

Indicator

Indicator

Alpine Predictive BandsAlpine Predictive Bands - ADX & Trend Projection is an advanced indicator crafted to estimate potential price zones and trend strength by integrating dynamic support/resistance bands, ADX-based confidence scoring, and linear regression-based price projections. Designed for adaptive trend analysis, this tool combines multi-timeframe ADX insights, volume metrics, and trend alignment for improved confidence in trend direction and reliability.
Key Calculations and Components:
Linear Regression for Price Projection:
Purpose: Provides a trend-based projection line to illustrate potential price direction.
Calculation: The Linear Regression Centerline (LRC) is calculated over a user-defined lookbackPeriod. The slope, representing the rate of price movement, is extended forward using predictionLength. This projected path only appears when the confidence score is 70% or higher, revealing a white dotted line to highlight high-confidence trends.
Adaptive Prediction Bands:
Purpose: ATR-based bands offer dynamic support/resistance zones by adjusting to volatility.
Calculation: Bands are calculated using the Average True Range (ATR) over the lookbackPeriod, multiplied by a volatilityMultiplier to adjust the width. These shaded bands expand during higher volatility, guiding traders in identifying flexible support/resistance zones.
Confidence Score (ADX, Volume, and Trend Alignment):
Purpose: Reflects the reliability of trend projections by combining ADX, volume status, and EMA alignment across multiple timeframes.
ADX Component: ADX values from the current timeframe and two higher timeframes assess trend strength on a broader scale. Strong ADX readings across timeframes boost the confidence score.
Volume Component: Volume strength is marked as “High” or “Low” based on a moving average, signaling trend participation.
Trend Alignment: EMA alignment across timeframes indicates “Bullish” or “Bearish” trends, confirming overall trend direction.
Calculation: ADX, volume, and trend alignment integrate to produce a confidence score from 0% to 100%. When the score exceeds 70%, the white projection line is activated, underscoring high-confidence trend continuations.
User Guide
Projection Line: The white dotted line, which appears only when the confidence score is 70% or higher, highlights a high-confidence trend.
Prediction Bands: Adaptive bands provide potential support/resistance zones, expanding with market volatility to help traders visualize price ranges.
Confidence Score: A high score indicates a stronger, more reliable trend and can support trend-following strategies.
Settings
Prediction Length: Determines the forward length of the projection.
Lookback Period: Sets the data range for calculating regression and ATR.
Volatility Multiplier: Adjusts the width of bands to match volatility levels.
Disclaimer: This indicator is for educational purposes and does not guarantee future price outcomes. Additional analysis is recommended, as trading carries inherent risks.
Indicator

The Next Pivot (With History) [Mxwll]Introducing "The Next Pivot (With History)"!
With permission from the author @KioseffTrading
The script "The Next Pivot" has been restructured to show historical projections!
Features
Find the most similar price sequence per time frame change.
Forecast almost any public indicator! Not just price!
Forecast any session i.e. 4Hr, 1Hr, 15m, 1D, 1W
Forecast ZigZag for any session
Spearmen
Pearson
Absolute Difference
Cosine Similarity
Mean Squared Error
Kendall
Forecasted linear regression channel
The image above shows/explains some of the indicator's capabilities!
Additionally, you can project almost any indicator!
Should load times permit it, the script can search all bar history for a correlating sequence. This won't always be possible, contingent on the forecast length, correlation length, and the number of bars on the chart.
If a load time error occurs, simple reduce the "Bars Back To Search" parameter!
The script can only draw 500 bars into the future. For whatever time frame you are on and the session you wish to project, ensure it will not exceeded a 500-bar forecast!
Reasonable Assessment
The script uses various similarity measures to find the "most similar" price sequence to what's currently happening. Once found, the subsequent price move (to the most similar sequence) is recorded and projected forward.
So,
1: Script finds most similar price sequence
2: Script takes what happened after and projects forward
While this may be useful, the projection is simply the reaction to a possible one-off "similarity" to what's currently happening. Random fluctuations are likely and, if occurring, similarities between the current price sequence and the "most similar" sequence are plausibly coincidental.
Thanks!
Indicator

Price Prediction With Rolling Volatility [TradeDots]The "Price Prediction With Rolling Volatility" is a trading indicator that estimates future price ranges based on the volatility of price movements within a user-defined rolling window.
HOW DOES IT WORK
This indicator utilizes 3 types of user-provided data to conduct its calculations: the length of the rolling window, the number of bars projecting into the future, and a maximum of three sets of standard deviations.
Firstly, the rolling window. The algorithm amasses close prices from the number of bars determined by the value in the rolling window, aggregating them into an array. It then calculates their standard deviations in order to forecast the prospective minimum and maximum price values.
Subsequently, a loop is initiated running into the number of bars into the future, as dictated by the second parameter, to calculate the maximum price change in both the positive and negative direction.
The third parameter introduces a series of standard deviation values into the forecasting model, enabling users to dictate the volatility or confidence level of the results. A larger standard deviation correlates with a wider predicted range, thereby enhancing the probability factor.
APPLICATION
The purpose of the indicator is to provide traders with an understanding of the potential future movement of the price, demarcating maximum and minimum expected outcomes. For instance, if an asset demonstrates a substantial spike beyond the forecasted range, there's a significantly high probability of that price being rejected and reversed.
However, this indicator should not be the sole basis for your trading decisions. The range merely reflects the volatility within the rolling window and may overlook significant historical price movements. As with any trading strategies, synergize this with other indicators for a more comprehensive and reliable analysis.
Note: In instances where the number of predicted bars is exceedingly high, the lines may become scattered, presumably due to inherent limitations on the PulseWire platform. Consequently, when applying three SD in your indicator, it is advised to limit the predicted bars to fewer than 80.
RISK DISCLAIMER
Trading entails substantial risk, and most day traders incur losses. All content, tools, scripts, articles, and education provided by TradeDots serve purely informational and educational purposes. Past performances are not definitive predictors of future results. Indicator

Indicator

Price PredictorGreetings Traders! I have decided to release a few scripts as open-source as I'm sure others can benefit from them and perhaps make them better.(Be sure to check my Profile for the other scripts as well: www.pulsewire.com).
This one is called Price Predictor.
How To Use Price Predictor
Price Predictor acquires potential targets by measuring the Average Change of Price from a user-defined resolution, from Open to Open. By default, the Resolution is set to 1 Day, however you can play around with Weekly, Monthly, etc. When a new resolution period begins, Price Predictor will automatically adjust based on the new Average Change of Price.
Due to the avoidance of Security() in this script, you may have to play around with the Timeframe that you use it in to ensure that you have enough bars on your chart to process the User-Defined Resolution.
The first Target Zone represents Target 5 of my other script, Trade Manager()(Given that you set the Target Multiple and Default Threshold Inputs as the same in each script), and is the most likely to be hit before the end of the resolution period.
In addition to a User-Defined Resolution, you also have the option of using a Custom Price to define Target Zones, however I'd recommend using my other script, Trade Manager(), if the volatility of the Instrument isn't too high.
I wanted to give a Special Thanks to @Pinecoders for the Custom RoundToTick Function from The Backtesting/Trading Engine --> (
If you like Price Predictor, be sure to Like, Follow, and if you have any questions, don't be afraid to drop a comment below. Indicator

Trade ManagerGreetings Traders! I have decided to release a few scripts as open-source as I'm sure others can benefit from them and perhaps make them better.(Be sure to check my Profile for the other scripts as well: www.pulsewire.com).
This one is called Trade Manager.
How To Use Trade Manager
Trade Manager acquires potential targets by measuring the Average Change of Price from a user-defined resolution, from Open to Open. By default, the Resolution is set to 1 Day, however you can play around with Weekly, Monthly, etc. When a new resolution period begins, Trade Manager will automatically adjust its Targets based on the new Average Change of Price.
Due to the avoidance of Security() in this script, you may have to play around with the Timeframe that you use it in to ensure that you have enough bars on your chart to process the User-Defined Resolution.
The idea behind Trade Manager is quite simple yet can be quite powerful at the same time. Consider a Daily Candle for example. You can clearly see how a vast amount of price movement can be encapsulated within it, sometimes in both directions. By measuring the Average Change of Price per day(From Open to Open), we can use this Average to build targets off of. Defining a small Threshold above and below the Open Price of the Daily Candle allows you to set Limit Orders at these levels with predefined Targets. Then, the use of the custom Trailing Stop and Break Even helps to secure profits without giving too much back to the market, all while managing your risk.
Within the Settings of Trade Manager, you have the option to alter the logic of whether Break-Even is set after the first Target or second Target is hit.
In addition to using a User-Defined Resolution Period, you can also input a Custom Price into the settings of Trade Manager and allow the Targets, Trailing Stop, and Break Even to be calculated from the Custom Price.
I wanted to give a Special Thanks to @PineCoders for the Custom RoundToTick Function from The Backtesting/Trading Engine --> ()
As a note, there are times where price will break out very strongly from the Limit Price, sometimes crossing the Stop and Limit Price on the same bar. When this happens, it is difficult for Pine to determine which occurred first intra-bar, and as a result, it does not record a new position. In these instances, I'd recommend adjusting the Default Stop Multiple so it is below the bar.
If you like Trade Manager, be sure to Like, Follow, and if you have any questions, don't be afraid to drop a comment below. Indicator
