Extracting trend and filtering noises using the method of singular spectrum analysis. Adjusting the indicator parameters allows to control the smoothness of the extracted trend and noise filtering threshold.
The time horizon of the trading strategy determines the optimum dissection of data into trend, low-frequency and high-frequency additive components, followed by signal reconstruction. The indicator (smoothed trend) does not have phase delays, unlike the conventional filtering methods and smoothed average.
Trend indicator based on the "Caterpillar" method involves expansion of the price series into additive components. This does not require the series to be stationary, knowing the trend model or information on presence of period components and their periods [1-4].
Capabilities of the developed indicator allow to smooth the series, extract the trend and (by selecting the adjustment parameters of the model for the initial price series) consider the contribution of the oscillator summands on a smaller time scale — filter out the "noise" fluctuations.
The main parameters are:
Options of the EigNoiseFlag integer parameter:
Typical selection and impact of parameters:
The CCaterpillar class implemented in the CCaterpillar.mqh file includes everything necessary for the calculation of trend, except the linear algebra procedures (the ALGLIB library is used for the singular dissection of the trajectory matrix). The code presented in the file includes the descriptions for members and procedures of the class.
The indicator operation requires the files:
It is not recommended to set a data fragment greater than 300 values due to high computational load. It is optimal to use 150-200. You can always switch to another period of chart calculations to cover a larger history interval.
It is advisable to change the "caterpillar" window in the range from 1/3 to 1/2 of the fragment length. If the window exceeds half of the fragment, then due to the symmetry of the trajectory and the matrix transposed of it, that is equivalent to a segment with length, symmetrical relative to the middle of the fragment. Small window length does not provide qualitative averaging and splitting of information to by certain modes.
If there is a slow flow of data in the graphical interface of the price series, the possible solutions may be: a) decrease the fragment length; b) increase the ReCalcLim parameter of recalculation discreteness in the OnCalculate function.
Fig.1. Period of 5 minutes. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)
Fig. 2. Period of 1 hour. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)
Fig. 3. Period of 1 day. Two trends SSA(120,50,4), SSA(50,20,7) and moving average MA(14)
The use of the singular analysis for the implementation of a trend indicator in this form is a basic illustration. Widespread use of the SSA methods in financial sector for the analysis and forecasting of time series is presented in [5-7].
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/15865
The Volume_Weighted_MA indicator that fills the chart space with a colored background and displays the most recent value as a price label with the possibility to round the channel levels up to a required number of digits.Volume_Weighted_MA_StDev_HTF
The Volume_Weighted_MA_StDev indicator with the timeframe selection option available in input parameters.