# Variable Sine Wave Fit

Variable Sine Wave Fit is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

The Variable Sine Wave Fit applies least-squares regression to recent price, fitting a sine wave with damped, expanding, or constant amplitude on top of a linear trend, then projects the curve forward with RMSE error bands. A dashboard classifies the regime and reports the dominant cycle length for cycle-minded traders.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Feb 18, 2026.
- Access: free.
- Concepts: [Sinewave Indicator](https://www.luxalgo.com/library/concept/sinewave-indicator/) (primary), [Dominant Cycle Measurement](https://www.luxalgo.com/library/concept/dominant-cycle-measurement/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwn6vya009qvhsgvlk8cunv
- Page: https://www.luxalgo.com/library/indicator/variable-sine-wave-fit/

The **Variable Sine Wave Fit** takes the [sinewave indicator](https://www.luxalgo.com/library/concept/sinewave-indicator/) idea to a fully fitted model. Over a rolling window it uses Ordinary Least Squares to fit price with a sine wave whose amplitude can damp, expand, or stay constant, riding on a linear trend component. The curve is drawn solid across the last Window Size bars and dashed into the future, wrapped in RMSE bands showing how tightly price follows the model. The fit recalculates on new data and adjusts retrospectively, so read it as regime context rather than fixed signals.

## How to Trade the Variable Sine Wave Fit?

- **Price inside the RMSE bands**: the modeled cycle remains valid. Trade with the oscillation's rhythm.
- **Closes well outside the bands**: the model is breaking down, often a regime shift or volatility expansion.
- **Peaks and troughs of the dashed projection**: candidate turning points for timing pullbacks, counter-trend scalps, and exits.
- **Dashboard state**: Damped, Expanding, or Constant amplitude paired with Trending or Ranging shows whether cycles are compressing, accelerating, or stable.
- **Best Period**: the grid-searched cycle length in bars, a live [dominant cycle](https://www.luxalgo.com/library/concept/dominant-cycle-measurement/) estimate for aligning swing expectations across timeframes.

A rising RMSE readout is information in itself: price is peeling away from the fitted structure, which often accompanies a transition between ranging and trending conditions.

## Variable Sine Wave Fit Settings

- **Window Size (N)**: bars used for the fit; larger windows capture broader cycles, smaller ones react faster.
- **Auto Period / Fixed Period (P)**: search for the best cycle length automatically or pin it manually.
- **Min/Max Search Period**: boundaries for the automatic search.
- **Forecast Length**: bars the dashed projection extends.
- **RMSE Band Multiplier**: width of the error envelope.
- Dashboard visibility, position, and size are adjustable, as are the bullish/bearish and band colors.

## Frequently Asked Questions

### Does the Variable Sine Wave Fit repaint?

Yes. The model refits as each new bar arrives, so the historical curve can adjust retrospectively. Use it for cycle and regime context, not as a signal generator frozen in place.

### How does it differ from classic cycle oscillators?

A tool like [Even Better Sinewave](https://www.luxalgo.com/library/indicator/even-better-sinewave/) distills price into a bounded cyclic oscillator. The Variable Sine Wave Fit instead fits amplitude, frequency, phase, and trend directly onto price, quantifies the fit error, and adds forward projections with a regime dashboard.

### Is the indicator free to access?

It is part of the LuxAlgo Library's free collection, and it can be run in Quant, our coding agent, right from this page. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Correlated Sine Oscillator](https://www.luxalgo.com/library/indicator/correlated-sine-oscillator/) (Sinewave Indicator): markdown at https://www.luxalgo.com/library/indicator/correlated-sine-oscillator.md
- [Normalized Resonator](https://www.luxalgo.com/library/indicator/normalized-resonator/) (Dominant Cycle Measurement): markdown at https://www.luxalgo.com/library/indicator/normalized-resonator.md
- [Adaptive Harmonic Forecast](https://www.luxalgo.com/library/indicator/adaptive-harmonic-forecast/) (Dominant Cycle Measurement): markdown at https://www.luxalgo.com/library/indicator/adaptive-harmonic-forecast.md
- [Adaptive Momentum Oscillator](https://www.luxalgo.com/library/indicator/adaptive-momentum-oscillator/) (Adaptive-parameter Technique): markdown at https://www.luxalgo.com/library/indicator/adaptive-momentum-oscillator.md
- [Swiss Army Knife Filter](https://www.luxalgo.com/library/indicator/swiss-army-knife-filter/) (Ehlers Bandpass Filter): markdown at https://www.luxalgo.com/library/indicator/swiss-army-knife-filter.md
- [Roofing Filter](https://www.luxalgo.com/library/indicator/roofing-filter/) (Statistics): markdown at https://www.luxalgo.com/library/indicator/roofing-filter.md
- [Even-better Sinewave](https://www.luxalgo.com/library/indicator/even-better-sinewave/) (Statistics): markdown at https://www.luxalgo.com/library/indicator/even-better-sinewave.md
- [Decycler](https://www.luxalgo.com/library/indicator/decycler/) (Statistics): markdown at https://www.luxalgo.com/library/indicator/decycler.md

---

Source: https://www.luxalgo.com/library/indicator/variable-sine-wave-fit/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
