Trend indicator based on singular spectrum analysis - MetaTrader 5 script | Forex indicator download - MT4/MT5 resources



Use singular spectrum analysis to extract trends and filter noise. Adjusting the indicator parameters can control the smoothness of the extracted trend and the noise filtering threshold.
The time horizon of your trading strategy determines the best way to decompose the data into trend, low-frequency and high-frequency additive components and then reconstruct the signal. Unlike traditional filtering methods and smoothed averages, this indicator (smoothed trend) has no phase delay.
Trend indicators based on the "Caterpillar" method involve expanding the price series to additional components. This does not require that the series be stationary, know the trend model or have information about the existence of cyclical components and their periods [1-4].
The functionality of the developed indicator allows smoothing the series, extracting the trend and (by choosing the tuning parameters of the initial price series model) taking into account the contribution of the oscillator's summand on smaller time scales - filtering out "noise" fluctuations.
The main parameters are:
Options for the feature noise flag integer argument:
Typical choices and effects of parameters:
The CCaterpillar class implemented in the CCaterpillar.mqh file includes everything needed to calculate trends, except linear algebra procedures ( ALGLIB library for singular dissection of trajectory matrices). The code provided in the file includes descriptions of the members and procedures of the class.
Indicator operation requires files:
Due to the high computational load, it is not recommended to set data fragments larger than 300 values. The optimal dosage is 150-200. You can always switch to another chart calculation period to cover a larger historical range.
It is recommended to change the Caterpillar window within 1/3 to 1/2 of the clip length. If the window exceeds half the segment, it is equivalent to a segment whose length is symmetrical relative to the middle of the segment due to the symmetry of the trajectory and its transpose matrix. Small window lengths cannot provide qualitative averaging and information segmentation through certain modes.
If the data flows slowly in the graphical interface of the price series, possible solutions may be: a) reduce the segment length; b) increase the recalculation function when recalculating discreteness parameters.

Figure 1. Duration 5 minutes. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)

Figure 2. 1-hour time period. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)

Figure 3. 1-day cycle. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)
Using singular analysis to implement this form of trend indicator is a basic illustration. [5-7] introduced the widespread use of SSA methods in the financial field to analyze and predict time series.
Attachment download
📎 ccaterpillar.mqh (14.36 KB)
📎 singularma.mq5 (7.59 KB)
Source: MQL5 #15865
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •