LSMA SD | GForgeLSMA SD | GForge
LSMA SD is a trend-following oscillator built for swing trading on higher timeframes. It generates rules-based long and exit signals by measuring where price sits within a statistically-defined volatility envelope anchored to a regression-based trend line.
Core Calculation
The basis line is a Least Squares Moving Average. Unlike a standard moving average which weights past prices, LSMA computes the mathematically optimal straight-line fit across a defined lookback window. This means the basis reflects the actual gradient of a trend — its slope tells you the rate and direction of price movement, not a smoothed echo of where price has been. A short EMA pass is applied to the raw LSMA output as a robustness measure, absorbing single-bar snap artifacts that occur when outlier candles enter or exit the regression window. This is not a smoothing aesthetic — it directly addresses a known fragility in raw LinReg endpoints.
The default source is hlc3 — the average of high, low, and close — rather than close alone. This distributes the regression input across the full bar range, reducing sensitivity to end-of-session price mechanics such as stop runs and last-minute order flow that can distort the trend line without reflecting genuine directional movement.
A Standard Deviation envelope is then constructed around the LSMA basis at a fixed multiplier. The band width is driven entirely by actual price volatility — it widens during high-volatility periods and tightens during quiet ones. There is no secondary adaptive scaling layer. This is intentional: additional dynamic scaling introduces a second noisy signal on top of the basis movement, which in practice degrades signal quality.
The Oscillator
The oscillator expresses where price currently sits within the SD bands on a 0–100 scale. A reading of 0 means price is at the lower band. A reading of 100 means price is at the upper band. A reading of 50 means price is sitting directly on the LSMA trend line itself — the neutral zone between the two signal thresholds represents price consolidating around the regression basis.
Long signals fire when the oscillator crosses above the long threshold (default 74), meaning price has broken decisively into the upper band zone — a momentum confirmation in the direction of the trend, not a mean-reversion trigger. Exit and short signals fire when the oscillator crosses below the short threshold (default 33).
This is a trend-continuation system, not a reversal indicator.
Parameters
The indicator is intentionally low-parameter. LSMA Length sets the regression window. StdDev Length sets the band width lookback and can differ from the LSMA length. StdDev Multiplier sets the fixed band scale. Endpoint Smoothing controls how aggressively window-edge artifacts are absorbed — setting it to 1 disables it entirely. Fewer parameters means less surface area for curve-fitting to historical data.
Default settings are optimised for BTC on the 1D timeframe. Optimize thresholds and lengths for different assets and timeframes before use.
Risk Warning
This indicator is provided for informational and educational purposes only. Past performance, including any results visible on historical bars, does not guarantee or imply future returns. All trading involves risk. You should not make trading decisions based solely on any single indicator. Always apply independent analysis and appropriate risk management.
Developed by GForge
Pine Script® göstergesi






















