Variable Sine Wave Fit
Feb 18, 2026

The Variable Sine Wave Fit is an advanced trading indicator that applies Ordinary Least Squares (OLS) regression to fit a dynamic sine wave with a linear trend component to recent price data. By modeling price as a damped, expanding, or constant-amplitude cycle overlaid on a trend, this trading tool helps traders identify cyclical behavior, anticipate turning points, and better understand shifting market regimes. It provides both historical curve fitting and forward projections, offering a structured mathematical framework for cycle-based trading strategies.
This indicator is subject to repainting and is displayed retrospectively.
How to Trade the Variable Sine Wave Fit Indicator
This trading indicator works by fitting a complex trigonometric model to a rolling window of historical price data. The fitted curve appears as a solid line over past price action and transitions into a dashed line for future projections.
The goal is not to predict exact price levels, but to:
- Detect dominant market cycles
- Identify potential turning points
- Assess whether price action aligns with a cyclical regime
- Spot regime shifts when the model loses accuracy
The indicator also plots RMSE-based bands (Root Mean Square Error bands) around the fitted curve. These bands represent the average deviation of price from the modeled cycle.
Using RMSE Bands for Trade Confirmation
- If price remains within the RMSE bands, the current cyclical structure is considered valid.
- If price closes significantly outside the bands, the model may be breaking down, signaling a potential regime shift or volatility expansion.
- Persistent deviations can indicate that the market is transitioning from ranging to trending, or vice versa.
This makes the Variable Sine Wave Fit not just a cycle indicator, but a regime detection tool that can complement trend-following or mean-reversion trading strategies.
Extrema Markers and Cycle Timing
Small dot markers appear at projected local maxima and minima along the dashed forecast line.
These markers:
- Highlight potential future turning points
- Help time entries during cyclical pullbacks
- Assist in anticipating exhaustion points in trending markets
Because the model includes both exponential damping/expansion and linear trend components, the extrema adapt to changing volatility and directional bias.
Traders can use these projected highs and lows to:
- Plan counter-trend scalps in ranging conditions
- Time pullbacks in trending markets
- Manage exits more precisely
Understanding the Market Regime Dashboard
The built-in dashboard summarizes the internal characteristics of the fitted model in real time.
State Classification
The indicator classifies market conditions based on:
-
Amplitude behavior:
- Damped (shrinking cycles)
- Expanding (growing cycles)
- Constant (stable oscillations)
-
Linear component:
- Trending
- Ranging
This gives traders a structured view of whether the market is compressing, accelerating, or oscillating within equilibrium.
Best Period
The “Best Period” represents the cycle length (in bars) that currently minimizes error. It is calculated via grid search optimization, selecting the dominant local frequency.
This is especially useful for:
- Aligning multi-timeframe trading strategies
- Adjusting swing expectations
- Understanding short-term vs. longer-term cycle dominance
RMSE (Root Mean Square Error)
RMSE measures how closely price follows the fitted model.
- Low RMSE = Price closely follows the cycle
- High RMSE = Price deviates significantly, possible instability
A rising RMSE often signals that the underlying market structure is shifting.
Mathematical Foundation of the Indicator
The script fits the following equation:
y = e^(λ * t) * (a * sin(ω * t) + b * cos(ω * t)) + m * t + c
Where:
- e^(λ * t): The exponential damping or expansion factor
- If λ > 0 → Expanding cycle
- If λ < 0 → Damping cycle
- a, b: Coefficients defining phase and amplitude
- ω: Angular frequency (derived from the best-fit period)
- m * t + c: Linear regression component capturing trend direction
The Best Period is selected through a grid search that minimizes the Sum of Squared Errors (SSE), ensuring the frequency matches the most dominant cycle in the selected window.
By combining trigonometric modeling with linear regression, this trading indicator blends cycle theory and trend analysis into one unified framework.
Indicator Settings Explained
Core Settings
- Window Size (N): Number of historical bars used to calculate the fit. Larger windows capture broader cycles; smaller windows react faster.
- Auto Period: Automatically searches for the best cycle length within a defined range.
- Fixed Period (P): Manually set the cycle length if Auto Period is disabled.
- Min/Max Search Period: Defines the boundaries of the automatic cycle search.
- Forecast Length: Number of bars projected into the future.
- RMSE Band Multiplier: Controls the width of the error envelope. Higher values create wider bands.
These parameters allow traders to tailor the indicator to scalping, swing trading, or higher-timeframe analysis.
Visual Customization
- Bullish/Bearish Color: Determines the color of the fit line and extrema markers based on final slope direction.
- Band Color: Sets the appearance of the RMSE envelope.
Dashboard Controls
- Dashboard: Toggle visibility of the statistical summary.
- Position: Move the dashboard to different chart corners.
- Size: Adjust text and scaling for readability.
Best Trading Strategies with the Variable Sine Wave Fit
This trading indicator works particularly well in:
- Cycle-based trading strategies
- Range-bound market conditions
- Trend exhaustion detection
- Mean reversion setups
It can also be paired with:
- Volume analysis for confirmation
- Momentum oscillators for divergence
- Market structure tools for confluence
Because it incorporates both cyclical and linear components, it adapts across different market environments better than traditional sine-wave or fixed-cycle indicators.
FAQ
What is the Variable Sine Wave Fit indicator?
It is a statistical trading indicator that fits a dynamic sine wave with exponential and linear components to recent price action using Ordinary Least Squares (OLS), helping traders identify dominant cycles, turning points, and market regimes.
Does the indicator repaint?
Yes. The model recalculates as new data becomes available, and the fit may adjust retrospectively.
What does RMSE mean in this indicator?
RMSE (Root Mean Square Error) measures the average deviation between price and the fitted model. It helps determine whether the cyclical structure is still valid.
How do I access the Variable Sine Wave Fit indicator?
You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Trading & investing are risky and many will lose money in connection with trading and investing activities. All content on this site is not intended to, and should not be, construed as financial advice. Decisions to buy, sell, hold or trade in securities, commodities and other investments involve risk and are best made based on the advice of qualified financial professionals. Past performance does not guarantee future results.
Hypothetical or Simulated performance results have certain limitations. Unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, including, but not limited to, lack of liquidity. Simulated trading programs in general are designed with the benefit of hindsight, and are based on historical information. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.
Testimonials appearing on this website may not be representative of other clients or customers and is not a guarantee of future performance or success.
As a provider of technical analysis tools and strategies, we do not have access to the personal trading accounts or brokerage statements of our customers. As a result, we have no reason to believe our customers perform better or worse than traders as a whole based on any content, tool, or platform feature we provide.
Charts used on this site are by TradingView in which the majority of our technical indicators are built on. TradingView® is a registered trademark of TradingView, Inc. www.TradingView.comTradingView® has no affiliation with the owner, developer, or provider of the Services described herein.
Market data is provided by CBOE, CME Group, BarChart, CoinAPI. CBOE BZX real-time US equities data is licensed from CBOE and provided through BarChart. Real-time futures data is licensed from CME Group and provided through BarChart. Select cryptocurrency data, including major coins, is provided through CoinAPI. All data is provided “as is” and should be verified independently for trading purposes.
This does not represent our full Disclaimer. Please read our full disclaimer.
© 2026 LuxAlgo Global, LLC.

