If you're looking to refine your trading strategy, the Caterpillar Trend Indicator based on Singular Spectrum Analysis (SSA) might just be the tool you need. This powerful indicator helps extract trends while filtering out noise, allowing you to make more informed trading decisions.
The beauty of this indicator lies in its adaptability. By tweaking its parameters, you can control how smooth the extracted trend is and set thresholds for noise filtering. This means that whether you’re day trading or swing trading, you can tailor it to fit your style.
One of the standout features of the SSA method is that it doesn't suffer from phase delays, which can often plague conventional filtering methods. Instead, it provides a clearer picture of the market trends, allowing you to act confidently.
The Caterpillar method expands the price series into additive components without needing the series to be stationary or having prior knowledge of the trend model. This flexibility is a game changer for many traders.
Key Parameters of the Indicator
Here are the main parameters you’ll want to pay attention to:
- SegmentLength — This defines the length of the “latest history” fragment in your price series.
- SegmentLag — The length of the caterpillar, which you should choose between 1/4 to 1/2 of the segment length. This affects how distinct the components are and the smoothness of the trend.
- EigMax — The number of principal components (modes of dissection). This is crucial for defining how signals are categorized and how fluctuations across different scales are considered.
- EigNoiseFlag — This flag determines how the number of principal components is calculated. You can toggle between a fixed number of modes or a noise threshold, with options of 0, 1, or 2.
- EigNoiseLevel — This sets the allowed noise percentage within the total fluctuation energy of the series, especially relevant when EigNoiseFlag is not zero.
Options for the EigNoiseFlag parameter:
- 0 - The signal space dimension is fixed: [1, EigMax]. In this case, EigNoiseLevel is ignored.
- 1 - Each mode’s value must represent at least the specified error EigNoiseLevel. The EigMax is chosen automatically.
- 2 - Only modes with a total share not exceeding EigNoiseLevel will be considered.
Typical Parameter Selection and Their Effects:
- SegmentLength — This is selected based on the history stability and the uniformity of data changes.
- SegmentLag — Sets the filter width for individual modes, inversely affecting trend smoothness.
- EigMax — Determines the threshold for “noise”.
- EigNoiseLevel — Specifies the “noise” level in percentage.
Implementation
The CCaterpillar class, found in the CCaterpillar.mqh file, includes everything you need for trend calculations, excluding linear algebra procedures (where the ALGLIB library comes in). The code in this file contains detailed descriptions for class members and procedures.
To run this indicator, you’ll need the following files:
- 1) MQL5\Include\SSA\CCaterpillar.mqh
- 2) MQL5\Indicators\SingularMA.mq5
- 3) The ALGLIB library, which many traders appreciate for its robust numerical methods.
Usage Tips
A few tips to keep in mind: It’s best not to set a data fragment longer than 300 values due to high computational load. A range of 150-200 values tends to work best. You can always switch to a different timeframe to cover a larger historical interval.
When adjusting the caterpillar window, aim for a length between 1/3 and 1/2 of the fragment length. Going beyond half can lead to symmetry issues in the trajectory and matrix, affecting your results. A smaller window length may not provide quality averaging.
If you experience lag in the price series on your graphical interface, consider decreasing the fragment length or increasing the ReCalcLim parameter for recalculation discreteness.

Fig. 1. Period of 5 minutes showing trends SSA(120,50,4), SSA(50,20,7), and moving average MA(14)

Fig. 2. Period of 1 hour showing trends SSA(120,50,4), SSA(50,20,7), and moving average MA(14)

Fig. 3. Period of 1 day showing trends SSA(120,50,4), SSA(50,20,7), and moving average MA(14)
This application of Singular Spectrum Analysis for trend indicators is just the tip of the iceberg. SSA methods are widely used in the financial sector for time series analysis and forecasting.
References
- Elsner J.B., Tsonis A.A. Singular Spectrum Analysis: A New Tool in Time Series Analysis. Plenum Press. New York, 1996.
- D. L. Danilov and A. A. Zhiglyavskii Principal Components in Time Series: the Caterpillar Method. St. Petersburg State Univ., St. Petersburg, 1997.
- N. E. Golyandina The "Caterpillar"-SSA method: analysis of time series: Study Guide. St. Petersburg: 2004.
- Principal Components in Time Series: the Caterpillar Method, edited by D. L. Danilov, A. A. Zhigljavsky. St. Petersburg: Presskom, 1997.
- Method of "Caterpillar"-SSA — ARIMA — SIGARCH for financial time series analysis: Proceedings of the Second International Scientific Conference on Mathematical methods, 2011.
- Kozhihova N.A., Shiryaev V.I. Time series forecasting using chaotic components. Bulletin of the South Ural State University, 2010.
- A.M. Avdeenko Advisors and indicators based on the SSA models and non-linear generalizations.
Related Posts
- Unlocking MetaCOT 2: Your Ultimate CFTC Indicator Toolkit for MT4
- Unlocking the Power of Master Tools for MetaTrader 4
- Visualize Current Trends Across All Time Frames with This MetaTrader 4 Indicator
- Mastering the Open Range Breakout Indicator for MetaTrader 5
- Unlock Trading Insights with Volume Profile + Range v6.0 for MetaTrader 5