Interpolated Median Volatility LSMA
Jun 1, 2025

The Interpolated Median Volatility LSMA indicator combines trend-following and volatility analysis by applying percentile-based linear interpolation to the Least Squares Moving Average (LSMA) and standard deviation to produce a smoothed, noise-resistant trend signal.
Usage
The Usage section describes how the script can be used to identify trend direction and potential breakout points.
- Trend Identification: The indicator features a colored LSMA line and shaded volatility bands. When the price is above the upper band, the signal turns bullish (green), indicating a potential long entry. When the price falls below the lower band, the signal turns bearish (red/purple), indicating a potential short entry.
- Volatility Bands: Unlike standard Bollinger Bands, these bands use interpolated median values, making them less reactive to extreme outliers while remaining adaptive to structural shifts in market volatility.
- Bar Coloring: The script automatically colors the price bars or candles to match the current signal state, providing immediate visual feedback on the prevailing trend.
Details
This tool builds upon the Least Squares Moving Average (LSMA), which uses linear regression to calculate a moving average that is more reactive than simple or exponential averages. To enhance this further, the script incorporates:
- Percentile Linear Interpolation: Instead of using raw LSMA or Standard Deviation values, it calculates the 50th percentile (median) over a specific lookback period. This interpolation smooths the data by estimating values between data points, effectively filtering out market noise.
- Adaptive Volatility: The width of the bands is determined by the interpolated standard deviation multiplied by a user-defined factor. This ensures the bands expand and contract based on normalized volatility rather than single-bar spikes.
Settings
- Source: The price data point (e.g., Close, HL2) used for all calculations.
- LSMA Length: The lookback period for the initial Least Squares Moving Average calculation.
- SD Length: The period used to calculate the raw standard deviation (volatility).
- Percentile Length: The window used for the linear interpolation of the median values for both the LSMA and standard deviation.
- Multiplier: Adjusts the width of the volatility bands; higher values require more significant price moves to trigger a signal.
FAQ
How do I use the signals from this indicator?
A long signal is triggered when the close price crosses above the upper band, while a short signal is triggered when the close price crosses below the lower band.
Can I set alerts for trend changes?
Yes, the script includes alert conditions for long entries, short entries, and general state changes, allowing you to be notified when the price breaks through the volatility bands.
How can I access Interpolated Median Volatility LSMA?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.