Neural Spectrogram Heatmap [AI Cycle Prediction]

More exclusive indicators from Alien_Algorithms
Subscribe to Alien_Algorithms | Premium Analytics for $63.00/month to get exclusive indicators by this author. You pay right on TradingView and can use them on your charts straight away.
Explore Alien_Algorithms | Premium AnalyticsNeural Spectrogram Heatmap is an AI cycle prediction indicator: a wavelet spectrogram of every market cycle, with machine learning neural networks that forecast the next highs and lows and keep score of how far their forecasts land.
The engine scans every cycle length at once, follows the dominant cycle as it stretches and compresses, rebuilds it on the price chart, and projects its next turning points with timing windows sized from its own track record. Most cycle tools assume a fixed length: an RSI set to 14 has already decided the market moves in a 14 bar rhythm. Here, the data picks the rhythm. Traders familiar with Hurst cycles, Fourier spectra or Ehlers DSP will recognise the goal: measure the dominant cycle, then time its turns. It works on crypto, forex, stocks, commodities and indices, on any timeframe with enough history.
Note on Architecture: This is a single, interdependent engine. The heatmap finds the dominant cycle, the overlay rebuilds and projects it, and two NeuraLib neural networks may correct the forecast only once they have proven, out of sample, that they improve it.
Below, on Bitcoin's 3 day chart: the dominant cycle drawn over price, colour graded by its length, the dotted forecast leading to the next projected low and high with their timing windows, and the heatmap in the pane underneath.

----------------------------------------------------------------------------------------------------------------
🔷 1.0 - Cycles and Wavelengths
A cycle is a repeating swing from a high (the crest) to a low (the trough) and back. Its length in bars is the wavelength.
Below are three pure cycles, 10, 22 and 45 bars long. Added together, they already look like price:

Real price is many cycles at once, mixed with trend and noise, and their lengths drift as conditions change. The indicator answers three questions: which cycle is in control, how long it is, and when it turns next.
----------------------------------------------------------------------------------------------------------------
🔷 2.0 - The Cycle Wave and Forecast
The strongest cycle is pulled out of price and drawn on top of it. Left of the dotted line it is final, right of it still forming. Past the last bar, the dotted forecast runs on to the next projected low and high, each with its timing window:

On the chart, the overlay is made of:
----------------------------------------------------------------------------------------------------------------
🔷 3.0 - The Spectrogram Heatmap
The heatmap is how the dominant cycle is found. A wavelet, a short burst of wave, is slid along price at every length: each column is one moment, each row one wavelength, and brightness is how well that wavelength fits. Strictly, this makes it a scalogram, the wavelet form of a spectrogram: where a spectrogram measures every cycle through one fixed window, the wavelet sizes its window to each cycle, so short cycles stay sharp in time and long ones sharp in length.
Here, the three cycles of section 1.0 are mixed into one market. Each one lights up its own row, exactly at its wavelength, while it is in control, and the price line on top takes the colour of whichever cycle leads:

On a real chart, the heatmap pane adds:
----------------------------------------------------------------------------------------------------------------
🔷 4.0 - How the Cycle Is Measured
Anyone can draw a sine wave on a chart. A cycle has to earn the label "dominant":
----------------------------------------------------------------------------------------------------------------
🔷 5.0 - AI Cycle Prediction
The projection continues the cycle from the wave's current value and slope, with no jump at the last bar. Two compact neural networks then work on what a fixed sine cannot know.
🔸 5.1 - Period Network: predicts the dominant period at four horizons from causal inputs only (the live band-pass spectrum, its drift, and the volatility and cycle energy regimes), so a cycle about to compress or stretch is drawn that way.
🔸 5.2 - Turn Network: learns how the edge's reading relates to the final wave: whether turns come early or late, and how far the cycle really reaches.
🔸 5.3 - Network Design: both are feed-forward neural networks (multilayer perceptrons) built on NeuraLib's Sequential API: 9 inputs, one hidden layer of 12 tanh neurons, and a linear output layer, with 4 outputs for the period path and 3 for the turn correction (phase shift and height). They train with the AdamW optimiser on a Huber loss, with gradient clipping, taking two passes over up to 320 of the newest samples after every second new one. Every input is dimensionless, so the same networks work on any symbol and timeframe, and fixed seeds mean the same history always trains the same networks.
🔸 5.4 - Proven Before Use: both networks train walk-forward, on your chart. Every sample is predicted out of sample and scored against the plain projection before it is learned, and a network's output is used only once it beats the plain projection with 95% confidence. The timing windows are measured the same way: they come from the 80th percentile of the latest 120 errors between the edge's turns and the final wave.
Every tooltip shows what is in use, its score, its confidence and its sample count. On many charts the timing correction stays off, because a cycle's phase cannot be known before its prices happen. The height correction usually qualifies first.
----------------------------------------------------------------------------------------------------------------
🔷 6.0 - How to Use It
Learned Forecast and Extra Training History control the networks. More history gives them a better chance to prove themselves, at the cost of a slower load.
----------------------------------------------------------------------------------------------------------------
🔹 Alerts
Cycle low / high window opens fires on the bar close at which the next predicted turn enters its 80% window. Any alert() function call carries the same events with their details: bars until the turn, where the window ends, and the current cycle period.
🔹 Performance
The heatmap holds 64,000 cells at the default settings, and 90,000 on the publication chart (a 2,000 bar History Window at 900 columns and 90 rows), each a weighted sum over hundreds of bars. The engine works incrementally: it updates once per bar close, computes every cell once when its window completes, and caches each bar's final wave, so an update only recomputes the unfinished edge. The heatmap is rendered by PineCanvas as merged colour regions, and the rolling stores use OptiPine row rings.
⚠️ Repainting
The wavelet is zero-phase: each bar uses bars on both sides of it, which keeps turns aligned with price and free of lag. The newest bars (230 at the default settings) are therefore still refining, and are marked by the repaint line, the dotted ridge and the faded turn dots. Everything left of the line is final. Drawings update once per confirmed bar, never intrabar. Predicted turns are an extrapolation of the current cycle, not a promise: cycles drift, vanish and reappear. The script needs roughly the History Window plus the Extra Training History plus a few hundred bars, and says on the chart when it has too little.
This indicator is built on three Alien_Algorithms libraries: NeuraLib for the neural networks, PineCanvas for the heatmap graphics and OptiPine for the rolling data stores. Its source is organised as a reference for using the three together.
Disclaimer: Past performance is not indicative of future results. This indicator is an analytical and educational tool, not a signal service, and offers no promise of financial gain. Use it as one component of a broader trading process, under your own responsibility. Conceptual architecture and quantitative development by Alien_Algorithms.
----------------------------------------------------------------------------------------------------------------
This work is licensed under (CC BY-NC-SA 4.0), meaning usage is free for non-commercial purposes given that Alien_Algorithms is credited in the description for the underlying software. For commercial use licensing, contact Alien_Algorithms
The engine scans every cycle length at once, follows the dominant cycle as it stretches and compresses, rebuilds it on the price chart, and projects its next turning points with timing windows sized from its own track record. Most cycle tools assume a fixed length: an RSI set to 14 has already decided the market moves in a 14 bar rhythm. Here, the data picks the rhythm. Traders familiar with Hurst cycles, Fourier spectra or Ehlers DSP will recognise the goal: measure the dominant cycle, then time its turns. It works on crypto, forex, stocks, commodities and indices, on any timeframe with enough history.
Note on Architecture: This is a single, interdependent engine. The heatmap finds the dominant cycle, the overlay rebuilds and projects it, and two NeuraLib neural networks may correct the forecast only once they have proven, out of sample, that they improve it.
Below, on Bitcoin's 3 day chart: the dominant cycle drawn over price, colour graded by its length, the dotted forecast leading to the next projected low and high with their timing windows, and the heatmap in the pane underneath.
----------------------------------------------------------------------------------------------------------------
🔷 1.0 - Cycles and Wavelengths
A cycle is a repeating swing from a high (the crest) to a low (the trough) and back. Its length in bars is the wavelength.
Below are three pure cycles, 10, 22 and 45 bars long. Added together, they already look like price:
Real price is many cycles at once, mixed with trend and noise, and their lengths drift as conditions change. The indicator answers three questions: which cycle is in control, how long it is, and when it turns next.
----------------------------------------------------------------------------------------------------------------
🔷 2.0 - The Cycle Wave and Forecast
The strongest cycle is pulled out of price and drawn on top of it. Left of the dotted line it is final, right of it still forming. Past the last bar, the dotted forecast runs on to the next projected low and high, each with its timing window:
On the chart, the overlay is made of:
- Cycle Wave: the isolated dominant cycle over the candles, colour graded by its wavelength, with a dot at each past high and low.
- Repaint Line: left of it, the wave is final. Right of it, the wavelet window is still filling, and the wave refines as new bars arrive.
- Projected Path: the forecast, coloured by the wavelength it expects, between two ghost paths at the 10% and 90% period forecasts.
- Turn Windows: every predicted high (red) and low (green) carries a timing bar, faint across its 80% window and stronger across its 50% window, labelled with the bars remaining. Hover any label for the full readout.
----------------------------------------------------------------------------------------------------------------
🔷 3.0 - The Spectrogram Heatmap
The heatmap is how the dominant cycle is found. A wavelet, a short burst of wave, is slid along price at every length: each column is one moment, each row one wavelength, and brightness is how well that wavelength fits. Strictly, this makes it a scalogram, the wavelet form of a spectrogram: where a spectrogram measures every cycle through one fixed window, the wavelet sizes its window to each cycle, so short cycles stay sharp in time and long ones sharp in length.
Here, the three cycles of section 1.0 are mixed into one market. Each one lights up its own row, exactly at its wavelength, while it is in control, and the price line on top takes the colour of whichever cycle leads:
On a real chart, the heatmap pane adds:
- Dominant Ridge: the cyan line tracks the band the wave follows, solid where final and dotted where it can still change.
- Cone of Influence: near the right edge, long cycles cannot be resolved yet. That area is dimmed and excluded from every measurement.
- Colour Key: the wavelength spectrum, with the Dominant and Live periods. The Dominant label is highlighted only when the cycle beats red noise, and an arrow means the strongest cycle sits at the edge of the scan range.
----------------------------------------------------------------------------------------------------------------
🔷 4.0 - How the Cycle Is Measured
Anyone can draw a sine wave on a chart. A cycle has to earn the label "dominant":
- Log price detrending: a centred Gaussian low-pass removes the trend, so trend power cannot flood the long periods.
- Complex Morlet wavelet (cmor8.0-1.0): its output is already the analytic signal, so amplitude, phase and turns come out directly, with no added lag.
- Scale normalisation: magnitude is divided by scale (Liu et al. 2007), so long periods get no free advantage.
- Cone of influence (Torrence & Compo, 1998): edge-contaminated cells never enter the dominant cycle or the significance test.
- AR(1) red noise test: the dominant peak must beat what autocorrelated noise would produce, at your chosen confidence level.
- Live edge estimate: where the zero-phase wavelet goes blind at the right edge, a causal Ehlers band-pass bank takes over. Fuse Live at Edge switches this off.
----------------------------------------------------------------------------------------------------------------
🔷 5.0 - AI Cycle Prediction
The projection continues the cycle from the wave's current value and slope, with no jump at the last bar. Two compact neural networks then work on what a fixed sine cannot know.
🔸 5.1 - Period Network: predicts the dominant period at four horizons from causal inputs only (the live band-pass spectrum, its drift, and the volatility and cycle energy regimes), so a cycle about to compress or stretch is drawn that way.
🔸 5.2 - Turn Network: learns how the edge's reading relates to the final wave: whether turns come early or late, and how far the cycle really reaches.
🔸 5.3 - Network Design: both are feed-forward neural networks (multilayer perceptrons) built on NeuraLib's Sequential API: 9 inputs, one hidden layer of 12 tanh neurons, and a linear output layer, with 4 outputs for the period path and 3 for the turn correction (phase shift and height). They train with the AdamW optimiser on a Huber loss, with gradient clipping, taking two passes over up to 320 of the newest samples after every second new one. Every input is dimensionless, so the same networks work on any symbol and timeframe, and fixed seeds mean the same history always trains the same networks.
🔸 5.4 - Proven Before Use: both networks train walk-forward, on your chart. Every sample is predicted out of sample and scored against the plain projection before it is learned, and a network's output is used only once it beats the plain projection with 95% confidence. The timing windows are measured the same way: they come from the 80th percentile of the latest 120 errors between the edge's turns and the final wave.
Every tooltip shows what is in use, its score, its confidence and its sample count. On many charts the timing correction stays off, because a cycle's phase cannot be known before its prices happen. The height correction usually qualifies first.
----------------------------------------------------------------------------------------------------------------
🔷 6.0 - How to Use It
- 1) Frame the range: set Min / Max Period to the cycles you care about. An arrow on the Dominant label means the cycle sits at the edge of the range: widen it.
- 2) Check the verdict: a highlighted Dominant label has beaten the red noise test. Dimmed means descriptive, not tradable.
- 3) Read the ridge: a rising ridge means the cycle is lengthening and momentum is slowing; a falling ridge means the rhythm is speeding up. Dominant and Live drifting apart usually marks a regime change.
- 4) Time with the windows: the 50% bar is where turns most often land, the 80% bar is the range to plan for. Use them as a timing bias alongside your own levels and confirmation, not as a trigger.
Learned Forecast and Extra Training History control the networks. More history gives them a better chance to prove themselves, at the cost of a slower load.
----------------------------------------------------------------------------------------------------------------
🔹 Alerts
Cycle low / high window opens fires on the bar close at which the next predicted turn enters its 80% window. Any alert() function call carries the same events with their details: bars until the turn, where the window ends, and the current cycle period.
🔹 Performance
The heatmap holds 64,000 cells at the default settings, and 90,000 on the publication chart (a 2,000 bar History Window at 900 columns and 90 rows), each a weighted sum over hundreds of bars. The engine works incrementally: it updates once per bar close, computes every cell once when its window completes, and caches each bar's final wave, so an update only recomputes the unfinished edge. The heatmap is rendered by PineCanvas as merged colour regions, and the rolling stores use OptiPine row rings.
⚠️ Repainting
The wavelet is zero-phase: each bar uses bars on both sides of it, which keeps turns aligned with price and free of lag. The newest bars (230 at the default settings) are therefore still refining, and are marked by the repaint line, the dotted ridge and the faded turn dots. Everything left of the line is final. Drawings update once per confirmed bar, never intrabar. Predicted turns are an extrapolation of the current cycle, not a promise: cycles drift, vanish and reappear. The script needs roughly the History Window plus the Extra Training History plus a few hundred bars, and says on the chart when it has too little.
This indicator is built on three Alien_Algorithms libraries: NeuraLib for the neural networks, PineCanvas for the heatmap graphics and OptiPine for the rolling data stores. Its source is organised as a reference for using the three together.
Disclaimer: Past performance is not indicative of future results. This indicator is an analytical and educational tool, not a signal service, and offers no promise of financial gain. Use it as one component of a broader trading process, under your own responsibility. Conceptual architecture and quantitative development by Alien_Algorithms.
----------------------------------------------------------------------------------------------------------------
This work is licensed under (CC BY-NC-SA 4.0), meaning usage is free for non-commercial purposes given that Alien_Algorithms is credited in the description for the underlying software. For commercial use licensing, contact Alien_Algorithms
Documentation for Indicators and Libraries on 👉 alienalgorithms.com/
Sentiment Analysis Platform 👉 Sentalysis.com/
Sentiment Analysis Platform 👉 Sentalysis.com/
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Documentation for Indicators and Libraries on 👉 alienalgorithms.com/
Sentiment Analysis Platform 👉 Sentalysis.com/
Sentiment Analysis Platform 👉 Sentalysis.com/
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.