• 概述
  • 评论
  • 评论 (14)
  • 新特性

ClusterSMA for MT4

This is the first public MQL4 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 and a few additions included. Conversion of the entire project into MQL4 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 most recent zero bar) and is a copy of the MetaTrader 5 version.


Parameters

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:
    • No - no conversion, the source series (price) is used;
    • Haar wavelet - Haar wavelet is used for converting the source series (price).
    • Modified SMA - a modified simple moving average from the article Technical Analysis: How Do We Analyze? (fig.2) is used for converting the source series (price).

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.


Appearance

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). When choosing options in the Transform parameter, an additional dotted line is drawn for clarity.

Check out the Comments and What's new tabs, as well as my blog (in Russian) for the news about the project.
无评论
版本 1.7 - 2016.01.07
1. Added settings for color, thickness and style of the ClusterSMA indicator line to the section "1. General settings" of the input parameters.
2. Added settings for color, thickness and style of the SMA indicator line to the section "2. SMA settings" of the input parameters.
3. Added an option to enable/disable the following alerts about a trend change to the section "4. Alerts" of the input parameters.
Log - prints a message about the signal in the log;
Alert - generates a sound alert, displays a message about the signal in the log and the opened dialog;
Mail - sends an email about the signal to the address, specified in the "Email" tab of the terminal settings window.
Notification - sends a notification to the mobile terminals, which have their MetaQuotes ID specified in the "Notifications" tab of the terminal settings window.
版本 1.6 - 2015.12.02
1. Indicator calculation time reduced, code optimized.
2. Improved indicator reaction in the areas of possible trend change, lag reduced. Please see the Comments section for details
3. Section 4 "Alerts" is added in inputs - configuration of indicator signals:
"Bar of alert" - the number of the bar to check the signal (0 - last incomplete bar);
"Sound" - enable/disable sound alert.
Alerts are generated in case of change of the indicator line trend. If "Bar of alert" is above 0, the signal is only generated if the indicator shows the same direction on the specified bar and all the following bars. So the alerts are generated only on the stable trend, and are ignored in all other cases to reduce false signals.
版本 1.5 - 2015.10.21
1. In the indicator settings window, the inputs are divided into three groups.
2. New parameter Max bars in chart - the maximum number of bars calculated and displayed in the indicator window at the indicator start or recalculation. the default value is 256 bars. It considerably facilitates indicator preparation, including that in testing. If t he parameter is set to zero, all the available history data are used for the indicator calculation. The minimum number of displayed bars is three.
3. New parameter 'Recalculation of the last bar' - allows selecting the mode of recalculation of the last unclosed bar. The default value is Every tick. Thre options are available in this version:
Every tick - like in the previous version, the indicator recalculates every tick on the last unclosed bar. This mode is recommended if the last bar values are important.
Every new minute bar - the indicator is recalculated only at the moment of a new M1 bar opening. This mode is recommended on timeframes higher than M1. It allows to cut CPU usage and track indicator changes once per minute.
Every new bar - the indicator is recalculated only when a new bar opens on the current timeframe. The indicator values on this bar are often ignored when defining a signal for a trading system. Select this option to significantly reduce the indicator calculation time, especially when you test strategies.
4. New parameter 'Line SMA' - show/hide the SMA line in the terminal window and its values in the data window. This option does not disable SMA calculation in the indicator, because these values are used.
5. New parameter 'Line of transform' - show/hide the price transformation line in the terminal window and its values in the data window. This option does not disable calculation in the indicator.
6. Fixed errors in the cluster filter, which could affect the final indicator line. I recommend that you review the strategies that use this indicator.