Download MetaTrader 5

Examples: Effective Averaging Algorithms with Minimal Lag: Use in Indicators and Expert Advisors

To add comments, please log in or register
Search in documentation is available via MetaTrader 5. Search and learn!
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2009.04.22 01:46 

New article Effective Averaging Algorithms with Minimal Lag: Use in Indicators and Expert Advisors has been published:

The article describes custom averaging functions of higher quality developed by the author: JJMASeries(), JurXSeries(), JLiteSeries(), ParMASeries(), LRMASeries(), T3Series() and MASeries(). The author considers the hot substitution of these functions in indicators using the call of the SmoothXSeries() function.

In mechanical trading systems built on the basis of indicators that are based on any averaging algorithms, their developers rarely use more than one averaging algorithm. In many cases, if an EA algorithm is based on simple movings and indicators that are included into the standard set of indicators of the MetaTrader 4 terminal, only four standard algorithms are used: simple, exponential, smoothed and linear-weighted averaging. Such an approach very much limits possibilities of an Expert Advisor.

One and the same trading system with the use of different averaging algorithms can show substantial differences in trading results. And it is impossible to say beforehand which of the available algorithms will show the maximum profitability of a trading system. So it is more reasonable to write a code with the possibility of using absolutely different averaging algorithms that can be chosen by changing values of external variables of an EA. As the result in such an approach we replace indicators used by an EA by our own ones with a more flexible setting of averaging algorithm selection. Thus, such an approach can be divided into three stages:

1. We write a code of an Expert Advisor based on standard movings and indicators included into the set of technical indicators in MetaTrader 4 client terminal.
2. We write custom indicators according to descriptions of standard indicators with the possibility of a more flexible replacement of smoothing algorithms.
3. We replace calls of technical indicators by calls of these custom indicators with extracting of external parameters of these indicators into external variables of the EA.

In this article I would like to dwell on more universal indicators with the possibility (if this can be said so) of a hot replacement of averaging algorithms that are used in these indicators. The article is the continuation of "Effective Averaging Algorithms with Minimal Lag: Use in Indicators", so before reading this one it is recommended to carefully study the previous article.

Author: Nikolay Kositsin

MQL4 Comments
MQL4 Comments 2009.04.22 03:09  

Dear Nikolay,

This is excellent programming and the wonderful explanations within the code are deeply appreciated. These explanations help us amateur programmers understand how and why the functions / structures of the code are implemented. You are gracious to share such astute programming with all of us. Thank you kindly. We will use your generous wisdom to grow and trade with deeper confidence.

Sincere Regards Nikolay,


Juan 2009.04.23 12:01  
Great explanatio
MQL4 Comments
MQL4 Comments 2009.04.25 22:01  

Nikolay, Great concepts and info for us that are just begining with programming.

Thank you,


Federico Costalonga
Federico Costalonga 2009.05.23 21:26  

Very good introduction to Jurik, it opens a new world of indicators! ;)

Thank you to share it for free!


MQL4 Comments
MQL4 Comments 2014.01.22 20:47  

Great indicator, I am using it, but there is a problem, if I want to retreat the x2ma to add arrow at the end of trend (with an iCustom) this way :

MA[i] = iCustom(NULL,0,"X2MA",Smooth_Mode1, Length1,Phase1,Smooth_Mode2, Length2,Phase2,Input_Price_Customs,0,i );

If then, i switch OFF the platform, end then I switch ON the plateform, the indicator x2ma included in the iCustom ... fade away.

To add comments, please log in or register