# Adaptive Harmonic Forecast

Adaptive Harmonic Forecast decomposes recent price into its dominant cycles, fits sine and cosine waves plus a linear trend by least squares, and extends the composite forward as a color-coded projection. Reversal dots mark forecast peaks and troughs, and a dashboard lists the detected cycle periods driving the model.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Feb 11, 2026.
- Access: free.
- Concepts: [FFT/spectral Analysis](https://www.luxalgo.com/library/concept/fft-spectral-analysis/) (primary), [Dominant Cycle Measurement](https://www.luxalgo.com/library/concept/dominant-cycle-measurement/)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=cmpwmzzmt0003vhsgskarz4w9
- Page: https://www.luxalgo.com/library/indicator/adaptive-harmonic-forecast/

**Adaptive Harmonic Forecast** models price as rhythm plus drift. It detrends the lookback window, scans candidate periods with [spectral analysis](https://www.luxalgo.com/library/concept/fft-spectral-analysis/) to find the cycles carrying meaningful power, then fits sines, cosines, and a first-order trend to the data with ordinary least squares. The composite plots as a solid line over history (showing how well the model explains what already happened) and extends forward as a dotted projection, green while the projected path rises, red while it falls.

## How to Trade the Adaptive Harmonic Forecast?

- **Alignment**: when live price agrees with the projected direction, treat it as confirmation for trend-continuation entries.
- **Reversal dots**: optional markers at forecast peaks and troughs give timing windows for pullbacks, or larger turns when they land on structural levels.
- **Trend line**: the linear-regression component separates the structural slope from the cycles riding on it, keeping directional bias visible.
- **Cycle table**: the Detected Cycles dashboard lists the [dominant cycle](https://www.luxalgo.com/library/concept/dominant-cycle-measurement/) periods in bars. Short periods flag a noisy, mean-reverting state; long ones a smoother structural regime.

Read the projection as directional rhythm and timing, not tick-level targets. It reflects the structure currently in the data.

## Adaptive Harmonic Forecast Settings

- **Fit Lookback (N)**: bars used for cycle detection and fitting. Larger captures broader structure, smaller reacts faster.
- **Extrapolation Bars**: how far forward the dotted forecast extends.
- **Number of Sinusoids (1-10)**: model complexity; more waves capture more structure at the cost of sensitivity.
- **Min Period**: floor on detected cycle length, filtering the shortest noise cycles.
- **Show Reversal Dots / Show Trend Line / Show Detected Periods**: toggle the markers, bias line, and cycle dashboard.

## Frequently Asked Questions

### Does the forecast repaint?

The model is refitted whenever a new bar arrives, so the dotted forward section updates with the latest data; historical values stay fixed once their bar closes. That behavior is inherent to a live-refitting forecast, which is why it suits timing rather than hindsight validation.

### Can it drive a systematic strategy?

Yes. The pipeline is mechanical end to end, periodogram detection feeding OLS fitting, so it slots into rule-based systems. A differently built projection like [The Echo Forecast](https://www.luxalgo.com/library/indicator/the-echo-forecast/) makes a useful second opinion.

### How do I access the Adaptive Harmonic Forecast?

It is free on the LuxAlgo Library. Load it from this page (including into Quant, our coding agent) and start with the default lookback before tuning the sinusoid count. You can also copy the source code from this page and run it anywhere Pine Script® runs.

## Related indicators

- [Normalized Resonator](https://www.luxalgo.com/library/indicator/normalized-resonator/) (Dominant Cycle Measurement): markdown at https://www.luxalgo.com/library/indicator/normalized-resonator.md
- [Variable Sine Wave Fit](https://www.luxalgo.com/library/indicator/variable-sine-wave-fit/) (Dominant Cycle Measurement): markdown at https://www.luxalgo.com/library/indicator/variable-sine-wave-fit.md
- [Spline Quantile Regression Channel](https://www.luxalgo.com/library/indicator/spline-quantile-regression-channel/) (Polynomial Regression): markdown at https://www.luxalgo.com/library/indicator/spline-quantile-regression-channel.md
- [Bitcoin Power Law](https://www.luxalgo.com/library/indicator/bitcoin-power-law/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/bitcoin-power-law.md
- [Recursive Least Squares Forecast](https://www.luxalgo.com/library/indicator/recursive-least-squares-forecast/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/recursive-least-squares-forecast.md
- [Kalman Filter](https://www.luxalgo.com/library/indicator/kalman-filter/) (Statistics): markdown at https://www.luxalgo.com/library/indicator/kalman-filter.md
- [Bitcoin Expectile Model](https://www.luxalgo.com/library/indicator/bitcoin-expectile-model/) (Quantile Regression): markdown at https://www.luxalgo.com/library/indicator/bitcoin-expectile-model.md
- [Rolling Segment](https://www.luxalgo.com/library/indicator/rolling-segment/) (Linear Regression): markdown at https://www.luxalgo.com/library/indicator/rolling-segment.md

---

Source: https://www.luxalgo.com/library/indicator/adaptive-harmonic-forecast/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
