OPEN-SOURCE SCRIPT
Multi Cycles Slope-Fit System ML

Multi Cycles Predictive System [ML]: A Slope-Adaptive Ensemble
Executive Summary:
The MCPS-Slope (Multi Cycles Slope-Fit System) represents a paradigm shift from static technical analysis to adaptive, probabilistic market modeling. Unlike traditional indicators that rely on a single algorithm with fixed settings, this system deploys a "Mixture of Experts" (MoE) ensemble comprising 13 distinct cycle and trend algorithms.
Using a Gradient-Based Memory (GBM) learning engine, the system dynamically solves the "Cycle Mode" problem by real-time weighting. It aggressively curve-fits the Slope of component cycles to the Slope of the price action, rewarding algorithms that successfully predict direction while suppressing those that fail.
This is a non-repainting, adaptive oscillator designed to identify market regimes, pinpoint high-probability reversals via OB/OS logic, and visualize the aggregate consensus of advanced signal processing mathematics.
1. The Core Philosophy: Why "Slope" Matters:
In technical analysis, most traders focus on Levels (Price is above X) or Values (RSI is at 70). However, the primary driver of price action is Momentum, which is mathematically defined as the Rate of Change, or the Slope.
This script introduces a novel approach: Slope Fitting.
Instead of asking "Is the cycle high or low?", this system asks: "Is the trajectory (Slope) of this cycle matching the trajectory of the price?"
The Dual-Functionality of the Normalized Oscillator
The final output is a normalized oscillator bounded between -1.0 and +1.0. This structure serves two critical functions simultaneously:
Directional Bias (The Slope):
When the Combined Cycle line is rising (Positive Slope), the aggregate consensus of the 13 algorithms suggests bullish momentum. When falling (Negative Slope), it suggests bearish momentum. The script measures how well these slopes correlate with price action over a rolling lookback window to assign confidence weights.
Overbought / Oversold (OB/OS) Identification:
Because the output is mathematically clipped and normalized:
Approaching +1.0 (Overbought): Indicates that the top-weighted algorithms have reached their theoretical maximum amplitude. This is a statistical extreme, often preceding a mean reversion or trend exhaustion.
Approaching -1.0 (Oversold): Indicates the aggregate cycle has reached maximum bearish extension, signaling a potential accumulation zone.
Zero Line (0.0): The equilibrium point. A cross of the Zero Line is the most traditional signal of a trend shift.
2. The "Mixture of Experts" (MoE) Architecture:
Markets are dynamic. Sometimes they trend (Trend Following works), sometimes they chop (Mean Reversion works), and sometimes they cycle cleanly (Signal Processing works). No single indicator works in all regimes.
This system solves that problem by running 13 Algorithms simultaneously and voting on the outcome.
The 13 "Experts" Inside the Code:
All algorithms have been engineered to be Non-Repainting.
Ehlers Bandpass Filter: Extracts cycle components within a specific frequency bandwidth.
Schaff Trend Cycle: A double-smoothed stochastic of the MACD, excellent for cycle turning points.
Fisher Transform: Normalizes prices into a Gaussian distribution to pinpoint turning points.
Zero-Lag EMA (ZLEMA): Reduces lag to track price changes faster than standard MAs.
Coppock Curve: A momentum indicator originally designed for long-term market bottoms.
Detrended Price Oscillator (DPO): Removes trend to isolate short-term cycles.
MESA Adaptive (Sine Wave): Uses Phase accumulation to detect cycle turns.
Goertzel Algorithm: Uses Digital Signal Processing (DSP) to detect the magnitude of specific frequencies.
Hilbert Transform: Measures the instantaneous position of the cycle.
Autocorrelation: measures the correlation of the current price series with a lagged version of itself.
SSA (Simplified): Singular Spectrum Analysis approximation (Lag-compensated, non-repainting).
Wavelet (Simplified): Decomposes price into approximation and detail coefficients.
EMD (Simplified): Empirical Mode Decomposition approximation using envelope theory.
3. The Adaptive "GBM" Learning Engine
This is the "Machine Learning" component of the script. It does not use pre-trained weights; it learns live on your chart.
How it works:
Fitting Window: On every bar, the system looks back 20 days (configurable).
Slope Correlation: It calculates the correlation between the Slope of each of the 13 algorithms and the Slope of the Price.
Directional Bonus: It checks if the algorithm is pointing in the same direction as the price.
Weight Optimization:
Algorithms that match the price direction and correlation receive a higher "Fit Score."
Algorithms that diverge from price action are penalized.
A "Softmax" style temperature function and memory decay allow the weights to shift smoothly but aggressively.
The Result: If the market enters a clean sine-wave cycle, the Ehlers and Goertzel weights will spike. If the market explodes into a linear trend, ZLEMA and Schaff will take over, suppressing the cycle indicators that would otherwise call for a premature top.
4. How to Read the Interface:
The visual interface is designed for maximum information density without clutter.
The Dashboard (Bottom Left - GBM Stats)
Combined Fit: A percentage score (0-100%). High values (>70%) mean the system is "Locked In" and tracking price accurately. Low values suggest market chaos/noise.
Entropy: A measure of disorder. High entropy means the algorithms disagree (Neutral/Chop). Low entropy means the algorithms are unanimous (Strong Trend).
Top 1 / Top 3 Weight: Shows how concentrated the decision is. If Top 1 Weight is 50%, one algorithm is dominating the decision.
The Matrix (Bottom Right - Weight Table)
This table lifts the hood on the engine.
Fit Score: How well this specific algo is performing right now.
Corr/Dir: Raw correlation and Direction Match stats.
Weight: The actual percentage influence this algorithm has on the final line.
Cycle: The current value of that specific algorithm.
Regime: Identifies if the consensus is Bullish, Bearish, or Neutral.
The Chart Overlay
The Line: The Gradient-Colored line is the Weighted Ensemble Prediction.
Green: Bullish Slope.
Red: Bearish Slope.
Triangles: Zero-Cross signals (Bullish/Bearish).
"STRONG" Labels: Appears when the cycle sustains a value above +0.5 or below -0.5, indicating strong momentum.
Background Color: Changes subtly to reflect the aggregate Regime (Strong Up, Bullish, Neutral, Bearish, Strong Down).
5. Trading Strategies:
A. The Slope Reversal (OB/OS Fade)
Concept: Catching tops and bottoms using the -1/+1 normalization.
Signal: Wait for the Combined Cycle to reach extreme values (>0.8 or <-0.8).
Trigger: The entry is taken not when it hits the level, but when the Slope flips.
Short: Cycle hits +0.9, color turns from Green to Red (Slope becomes negative).
Long: Cycle hits -0.9, color turns from Red to Green (Slope becomes positive).
B. The Zero-Line Trend Join
Concept: Joining an established trend after a correction.
Signal: Price is trending, but the Cycle pulls back to the Zero line.
Trigger: A "Triangle" signal appears as the cycle crosses Zero in the direction of the higher timeframe trend.
C. Divergence Analysis
Concept: Using the "Fit Score" to identify weak moves.
Signal: Price makes a Higher High, but the Combined Cycle makes a Lower High.
Confirmation: Check the GBM Stats table. If "Combined Fit" is dropping while price is rising, the trend is decoupling from the cycle logic. This is a high-probability reversal warning.
6. Technical Configuration:
Fitting Window (Default: 20): The number of bars the ML engine looks back to judge algorithm performance. Lower (10-15) for scalping/quick adaptation. Higher (30-50) for swing trading and stability.
GBM Learning Rate (Default: 0.25): Controls how fast weights change.
High (>0.3): The system reacts instantly to new behaviors but may be "jumpy."
Low (<0.15): The system is very smooth but may lag in regime changes.
Max Single Weight (Default: 0.55): Prevents one single algorithm from completely hijacking the system, ensuring an ensemble effect remains.
Slope Lookback: The period over which the slope (velocity) is calculated.
7. Disclaimer & Notes:
Repainting: This indicator utilizes closed bar data for calculations and employs non-repainting approximations of SSA, EMD, and Wavelets. It does not repaint historical signals.
Calculations: The "ML" label refers to the adaptive weighting algorithm (Gradient-based optimization), not a neural network black box.
Risk: No indicator guarantees future performance. The "Fit Score" is a backward-looking metric of recent performance; market regimes can shift instantly. Always use proper risk management.
Author's Note
The MCPS-Slope was built to solve the frustration of "indicator shopping." Instead of switching between an RSI, a MACD, and a Stochastic depending on the day, this system mathematically determines which one is working best right now and presents you with a single, synthesized data stream.
If you find this tool useful, please leave a Boost and a Comment below!
Executive Summary:
The MCPS-Slope (Multi Cycles Slope-Fit System) represents a paradigm shift from static technical analysis to adaptive, probabilistic market modeling. Unlike traditional indicators that rely on a single algorithm with fixed settings, this system deploys a "Mixture of Experts" (MoE) ensemble comprising 13 distinct cycle and trend algorithms.
Using a Gradient-Based Memory (GBM) learning engine, the system dynamically solves the "Cycle Mode" problem by real-time weighting. It aggressively curve-fits the Slope of component cycles to the Slope of the price action, rewarding algorithms that successfully predict direction while suppressing those that fail.
This is a non-repainting, adaptive oscillator designed to identify market regimes, pinpoint high-probability reversals via OB/OS logic, and visualize the aggregate consensus of advanced signal processing mathematics.
1. The Core Philosophy: Why "Slope" Matters:
In technical analysis, most traders focus on Levels (Price is above X) or Values (RSI is at 70). However, the primary driver of price action is Momentum, which is mathematically defined as the Rate of Change, or the Slope.
This script introduces a novel approach: Slope Fitting.
Instead of asking "Is the cycle high or low?", this system asks: "Is the trajectory (Slope) of this cycle matching the trajectory of the price?"
The Dual-Functionality of the Normalized Oscillator
The final output is a normalized oscillator bounded between -1.0 and +1.0. This structure serves two critical functions simultaneously:
Directional Bias (The Slope):
When the Combined Cycle line is rising (Positive Slope), the aggregate consensus of the 13 algorithms suggests bullish momentum. When falling (Negative Slope), it suggests bearish momentum. The script measures how well these slopes correlate with price action over a rolling lookback window to assign confidence weights.
Overbought / Oversold (OB/OS) Identification:
Because the output is mathematically clipped and normalized:
Approaching +1.0 (Overbought): Indicates that the top-weighted algorithms have reached their theoretical maximum amplitude. This is a statistical extreme, often preceding a mean reversion or trend exhaustion.
Approaching -1.0 (Oversold): Indicates the aggregate cycle has reached maximum bearish extension, signaling a potential accumulation zone.
Zero Line (0.0): The equilibrium point. A cross of the Zero Line is the most traditional signal of a trend shift.
2. The "Mixture of Experts" (MoE) Architecture:
Markets are dynamic. Sometimes they trend (Trend Following works), sometimes they chop (Mean Reversion works), and sometimes they cycle cleanly (Signal Processing works). No single indicator works in all regimes.
This system solves that problem by running 13 Algorithms simultaneously and voting on the outcome.
The 13 "Experts" Inside the Code:
All algorithms have been engineered to be Non-Repainting.
Ehlers Bandpass Filter: Extracts cycle components within a specific frequency bandwidth.
Schaff Trend Cycle: A double-smoothed stochastic of the MACD, excellent for cycle turning points.
Fisher Transform: Normalizes prices into a Gaussian distribution to pinpoint turning points.
Zero-Lag EMA (ZLEMA): Reduces lag to track price changes faster than standard MAs.
Coppock Curve: A momentum indicator originally designed for long-term market bottoms.
Detrended Price Oscillator (DPO): Removes trend to isolate short-term cycles.
MESA Adaptive (Sine Wave): Uses Phase accumulation to detect cycle turns.
Goertzel Algorithm: Uses Digital Signal Processing (DSP) to detect the magnitude of specific frequencies.
Hilbert Transform: Measures the instantaneous position of the cycle.
Autocorrelation: measures the correlation of the current price series with a lagged version of itself.
SSA (Simplified): Singular Spectrum Analysis approximation (Lag-compensated, non-repainting).
Wavelet (Simplified): Decomposes price into approximation and detail coefficients.
EMD (Simplified): Empirical Mode Decomposition approximation using envelope theory.
3. The Adaptive "GBM" Learning Engine
This is the "Machine Learning" component of the script. It does not use pre-trained weights; it learns live on your chart.
How it works:
Fitting Window: On every bar, the system looks back 20 days (configurable).
Slope Correlation: It calculates the correlation between the Slope of each of the 13 algorithms and the Slope of the Price.
Directional Bonus: It checks if the algorithm is pointing in the same direction as the price.
Weight Optimization:
Algorithms that match the price direction and correlation receive a higher "Fit Score."
Algorithms that diverge from price action are penalized.
A "Softmax" style temperature function and memory decay allow the weights to shift smoothly but aggressively.
The Result: If the market enters a clean sine-wave cycle, the Ehlers and Goertzel weights will spike. If the market explodes into a linear trend, ZLEMA and Schaff will take over, suppressing the cycle indicators that would otherwise call for a premature top.
4. How to Read the Interface:
The visual interface is designed for maximum information density without clutter.
The Dashboard (Bottom Left - GBM Stats)
Combined Fit: A percentage score (0-100%). High values (>70%) mean the system is "Locked In" and tracking price accurately. Low values suggest market chaos/noise.
Entropy: A measure of disorder. High entropy means the algorithms disagree (Neutral/Chop). Low entropy means the algorithms are unanimous (Strong Trend).
Top 1 / Top 3 Weight: Shows how concentrated the decision is. If Top 1 Weight is 50%, one algorithm is dominating the decision.
The Matrix (Bottom Right - Weight Table)
This table lifts the hood on the engine.
Fit Score: How well this specific algo is performing right now.
Corr/Dir: Raw correlation and Direction Match stats.
Weight: The actual percentage influence this algorithm has on the final line.
Cycle: The current value of that specific algorithm.
Regime: Identifies if the consensus is Bullish, Bearish, or Neutral.
The Chart Overlay
The Line: The Gradient-Colored line is the Weighted Ensemble Prediction.
Green: Bullish Slope.
Red: Bearish Slope.
Triangles: Zero-Cross signals (Bullish/Bearish).
"STRONG" Labels: Appears when the cycle sustains a value above +0.5 or below -0.5, indicating strong momentum.
Background Color: Changes subtly to reflect the aggregate Regime (Strong Up, Bullish, Neutral, Bearish, Strong Down).
5. Trading Strategies:
A. The Slope Reversal (OB/OS Fade)
Concept: Catching tops and bottoms using the -1/+1 normalization.
Signal: Wait for the Combined Cycle to reach extreme values (>0.8 or <-0.8).
Trigger: The entry is taken not when it hits the level, but when the Slope flips.
Short: Cycle hits +0.9, color turns from Green to Red (Slope becomes negative).
Long: Cycle hits -0.9, color turns from Red to Green (Slope becomes positive).
B. The Zero-Line Trend Join
Concept: Joining an established trend after a correction.
Signal: Price is trending, but the Cycle pulls back to the Zero line.
Trigger: A "Triangle" signal appears as the cycle crosses Zero in the direction of the higher timeframe trend.
C. Divergence Analysis
Concept: Using the "Fit Score" to identify weak moves.
Signal: Price makes a Higher High, but the Combined Cycle makes a Lower High.
Confirmation: Check the GBM Stats table. If "Combined Fit" is dropping while price is rising, the trend is decoupling from the cycle logic. This is a high-probability reversal warning.
6. Technical Configuration:
Fitting Window (Default: 20): The number of bars the ML engine looks back to judge algorithm performance. Lower (10-15) for scalping/quick adaptation. Higher (30-50) for swing trading and stability.
GBM Learning Rate (Default: 0.25): Controls how fast weights change.
High (>0.3): The system reacts instantly to new behaviors but may be "jumpy."
Low (<0.15): The system is very smooth but may lag in regime changes.
Max Single Weight (Default: 0.55): Prevents one single algorithm from completely hijacking the system, ensuring an ensemble effect remains.
Slope Lookback: The period over which the slope (velocity) is calculated.
7. Disclaimer & Notes:
Repainting: This indicator utilizes closed bar data for calculations and employs non-repainting approximations of SSA, EMD, and Wavelets. It does not repaint historical signals.
Calculations: The "ML" label refers to the adaptive weighting algorithm (Gradient-based optimization), not a neural network black box.
Risk: No indicator guarantees future performance. The "Fit Score" is a backward-looking metric of recent performance; market regimes can shift instantly. Always use proper risk management.
Author's Note
The MCPS-Slope was built to solve the frustration of "indicator shopping." Instead of switching between an RSI, a MACD, and a Stochastic depending on the day, this system mathematically determines which one is working best right now and presents you with a single, synthesized data stream.
If you find this tool useful, please leave a Boost and a Comment below!
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.