Introduction: The end of static analysis
Financial markets are not static. They are living, breathing, chaotic systems. But for decades, traders have relied on static indicators that use the same RSI settings, the same MACD parameters, and the same moving averages, regardless of whether the market is trending, chopping, or crashing.
Multicycle prediction systems (MCPS) represent a paradigm shift. This is more than just an indicator. This is an adaptive machine learning engine that runs directly on charts.
By integrating a fully functional Gradient Boosting Machine (GBM), this script learns rather than guesses. It monitors 13 different algorithmic models, calculates real-time accuracy for future price movements, and uses gradient descent to dynamically reassign influence to the “winning” model.
This is an application of the survival of the fittest method to technical analysis.
1. Core Engine: Gradient Boosting and Adaptive Learning
At the heart of MCPS is a custom-coded gradient boosting machine. While most of TradingView's “ML” scripts simply average a few metrics, this system replicates the architecture of advanced data science models.
How GBM works:
Ensemble prediction: The system aggregates signals from 13 different mathematical models.
Calculate residuals: Compare the ensemble's previous predictions with the actual price movements (price returns) to calculate the error (residuals).
Gradient Descent: Calculates the gradient of the loss function. It utilizes a Huber loss slope that is robust to outliers (market spikes) and prevents the model from overreacting to volatility.
Weight optimization: Using a configurable learning rate, the system updates the weights of each sub-algorithm. The model correctly predicted weight gain. Failing models lose their impact.
Softmax normalization: Finally, the weights are passed to a Softmax function (with temperature control) to convert them into probabilities that sum to 1.0.
“Winner-takes-all” philosophy
A common failure in ensemble systems is “signal dilution.” In other words, the good signal gets drowned out by the bad signal.
MCPS solves this through aggressive weight concentration.
Top 3 logic: The script identifies the top three performing algorithms based on historical accuracy.
90% Rule: Forces the system to assign up to 90% of the total decision weight to the top three performers.
Result: If Ehlers and Schaff are reading the market correctly but the MACD is failing, then the MACD is effectively silent. The system only listens to the winners.
2. 13 pillars of the algorithm
MCPS utilizes a diverse library of digital signal processing (DSP), statistical, and momentum algorithms. It does not rely on simple moving averages.
Ehlers Bandpass Filter: Isolates dominant cycles in price data and removes trends and noise.
Zero Lag EMA (ZLEMA): Reduces lag to nearly zero and tracks momentum changes instantly.
Coppock Curve: A classic long-term momentum indicator, modified here for adaptive responsiveness.
Detrended Price Oscillator (DPO): Removes trends to identify short-term cycles.
Shuff Trend Cycle (STC): A double-smoothed stochastic version of the MACD that is great at identifying turns in the cycle.
Fisher Transform: Converts prices to a Gaussian normal distribution to pinpoint turning points.
MESA Adaptive: Finds the current dominant cycle period using maximum entropy spectral analysis.
Goertzel Algorithm: A DSP technique used to identify the magnitude of specific frequency components of price waves.
Hilbert Transform: Extracts the instantaneous amplitude and phase of price movements.
Autocorrelation: Measures the similarity between a price series and a lagged version of itself to detect periodicity.
Singular Spectrum Analysis (SSA): Decomposes time series into trend, seasonal, and noise components (simplification).
Wavelet transform: Analyze data at different scales (frequencies) simultaneously.
Empirical mode decomposition (EMD): Split the data into eigenmode functions (IMFs) to isolate pure cycles.
3. Dashboard: Full transparency
Black box algorithms are dangerous. You need to know why the signal is generated. MCPS has two detailed dashboards (tables) at the bottom of the screen.
Weight and accuracy table (bottom right)
This is the “internal” view. It will look like this:
Algorithm: Name of the model.
Accuracy: The rolling historical accuracy of that particular model over the lookback period (e.g. 58.2%).
Weight: The current influence the model has on the final signal. Observe this change in real time. We see the system “give up'' on bad models and “bet big'' on good ones.
Prob/Sig: Raw probability and direction signals (up/down).
GBM statistics table (bottom left)
Track the state of your machine learning engine.
Iterations: The number of learning cycles that have occurred.
Entropy: A measure of market turbulence. High entropy means the weights are distributed (the model disagrees). Low entropy means the model is consistent.
Top 3 weights: Shows how concentrated your decision-making power is. If this is greater than 80%, the system has high reliability for a particular model.
Reliability and agreement: statistical measurements of signal strength.
4. How to trade with MCPS
This system outputs a single composite cycle line (oscillating between -1 and 1) and a background regime color.
Strategy A: Zero Cross (Trend Reversal)
Bullish: If the cycle line crosses 0. This indicates that the weighted average of the best performing algorithms has shifted towards a net positive expected value.
Bearish: If the cycle line falls below 0.
Strategy B: Extreme probabilities (mean reversion)
Strong Buy: When the cycle line falls below -0.5 (oversold) and turns upward. This indicates the bottom of the cycle with high probability.
Strong Sell: When the cycle line rises above +0.5 (overbought) and turns downward.
Strategy C: Regime filtering
The background color changes based on aggregated consensus.
Green/Lime: Bullish regime. Look primarily for long entries. Ignore weak sell signals.
Red/Orange: Bearish regime. I mainly look for short entries.
Gray: Neutral/Choppy. Please reduce your position size or wait.
5. Configuration and GBM settings
This script is highly customizable for advanced users who want to tune machine learning hyperparameters.
Prediction Range: How many days into the future are you trying to predict? (Default: 3).
Accuracy lookback: How far back does the model check to calculate “accuracy”?
GBM learning rate: Controls how fast the model adapts.
High (0.2+): Adapts quickly to new market conditions, but may “jump”.
Low (0.05): Very stable long-term adaptation.
Temperature: Controls the “soft max” function. Higher temperatures allow for softer, more distributed weight. Cold temperatures force a “winner-takes-all” outcome.
Max Top 3 Weight: Upper limit of power that the top 3 models can hold (default: 90%).
6. Technical nuances (for geeks)
Huber gradient: Gradient descent uses Huber loss instead of MSE (mean squared error). This is very important for financial time series, as price spikes (outliers) can disrupt the learning process of standard ML models. The Huber loss moves from a quadratic error to a linear error, making the model robust.
Regularization: L2 regularization is applied to prevent overfitting and ensure that the model does not just remember noise from the past.
Memory fading: The model has “memory fading.” Recent precision is weighted more heavily than precision from 200 bars ago, allowing the system to detect regime shifts (such as transitions from a trending market to a range market).
Disclaimer:
This tool is an advanced analytical instrument, not a crystal ball. Machine learning attempts to optimize probabilities based on past patterns, but no algorithm can predict black swan events or fundamental news shocks. Always carry out appropriate risk management.
A “warm-up period” is required. The script must process 50 bars of history before the GBM engine is initialized and generates a signal.
Author's note:
I built MCPS because I was tired of indicators that stopped working when the “character” of the market changed. By integrating GBM, this script adapts to market personalities in real time. If the market is cyclical, Ehlers and Goertzel will take over. If the market is trending, Coppock and ZLEMA will take the lead. No need to choose. Mathematics will automatically select.
If you found this helpful, please boost and leave a comment.
