This is the first public MQL5 indicator using the cluster filtering. The advanced smoothing effect allows the digital filter to transform an ordinary moving average into a new faster indicator providing fewer false signals. At least, that is the purpose of the new experimental project. The project stages and ClusterSMA features are described in the author's blog (in Russian).
The indicator is based on the cluster digital filter that is successfully used in another area. At the time of publication, only the first filter calculation module has been rewritten. Conversion of the entire project into MQL5 is on its initial stage. However, it is already possible to evaluate the entire idea by testing ClusterSMA. The indicator does not repaint, except for the very last (zero) bar.
1. General settings. This section includes the parameters for the appearance and calculation of the main line of the ClusterSMA indicator:
- Max bars in chart - the maximum number of bars, that are calculated and displayed in the indicator's window during the product's start or re-calculation. The default value is 256 bars. This greatly speeds up the preparation of the indicator for trading and testing. If 0, the indicator is calculated at the entire available history. The minimum amount of displayed bars is three.
- Recalculation of the last bar - select the re-calculation mode of the last unfinished bar. The 'Every tick' mode is set by default. There are three options:
- Every tick - the indicator is re-calculated at every tick on the last unfinished bar. Use this mode if the indicator readings are important on this bar.
- Every new minute bar - the indicator is re-calculated on the last unfinished bar only when a new bar arrives on the M1 timeframe. It is recommended to use the mode on timeframes exceeding M1. This reduces the load on CPU and allows tracking changes in the indicator readings once per minute.
- Every new bar - the indicator is re-calculated at the last unfinished bar only when a new bar arrives on the current timeframe. The indicator values on a new bar are often disregarded when defining a signal for a trading system. By selecting the option, you can significantly reduce the indicator calculation time in actual trading, as well as during strategy tests.
- Color ClusterSMA up - the ClusterSMA up line color.
- Color ClusterSMA down - the ClusterSMA down line color.
- Width ClusterSMA - width of the ClusterSMA line.
- Style ClusterSMA - style of the ClusterSMA line. When the "Width ClusterSMA" is set to 1, apart from the Solid line, you can also select Dash, Dotted, Dash-dot, or Dash - two dots.
2. SMA settings. This section includes the calculation and appearance settings of the SMA indicator line:
- Line SMA - enable/disable display of the SMA indicator line in the terminal window and the indicator's values in the data window This option does not disable SMA calculation in the indicator since its values are necessary for operation.
- Period SMA - period, valid values 1 to 255. It has the same physical meaning as the N parameter in the standard Simple Moving Average (SMA) indicator. The default value is 14. The maximum limitation of 255 has been introduced due to the "heavy" calculation part of the cluster filter.
- Color SMA up - the SMA up line color.
- Color SMA down - the SMA down line color.
- Width SMA - width of the SMA line.
- Style SMA - style of the SMA line. When the "Width SMA" is set to 1, apart from the Solid line, you can also select Dash, Dotted, Dash-dot, or Dash - two dots.
3. Settings of transform. This section includes the settings that affect the conversion of the source series (price):
- Line of transform - enable/disable the conversed price line in the terminal window and its values in the data window. This option does not disable the conversion calculation in the indicator. To disable conversion use the "Transform" parameter.
- Transform - select the method for the source series (price) conversion before the use in the ClusterSMA algorithm. The following options can be selected for this parameter:
Haar wavelet and Modified SMA are plotted as dotted lines for clarity, their values are then used in the ClusterSMA algorithm. Despite the fact that the last few values of these lines are redrawn, ClusterSMA is not redrawn (except for the zero bar). With these options, you can get earlier trend reversal signals, while maintaining acceptable stability on flat periods.
4. Alerts (Signals).
- Bar of alert - the number of the bar on which the signal is checked (0 - the last unfinished bar). Signals are generated when the trend of the ClusterSMA indicator line changes. If "Bar of alert" is greater than 0, then the signal will be generated only if the indicator moves in the same direction on the specified bar and all the subsequent bars. Thus, the signals are only generated during a steady trend and are ignored in all other cases, to reduce false triggers.
- Sound - enable/disable sound alert.
- Log - prints the signal message into the log.
- Alert - generates a sound alert, prints a message about the signal to the dialog box and to the log.
- Mail - sending an email using an address specified on the Email tab of the options window.
- Notification - sends a notification to mobile terminals which have their MetaQuotes IDs specified in the "Notifications" tab of the terminal settings.
The indicator plots two lines. One of them is a simple moving average (SMA), while the second one is a result of the cluster filter operation (SMA+Cluster).