Building Strategies with Custom Indicators

In the prior essay we walked through the method of converting a personalized index to an iCustom be the mandatory before all else step before it may be set up in a specialist adviser. We identified that the 6 distinct parameters of an iCustom feature, paying special interest to the previous three: Indicator Parameters, Mode, and Shift. We used the case of switching an intricate customized index, the NonLagMA_7.1, in an iCustom index feature, and also we walked through the deductive discovery procedure for finding its Indicator Parameters and Mode. Within this article we’ll go on to utilize the illustration of this NonLagMA_7.1, and also learn more about different methods for weaving the iCustom fuction in to different expert advisers.

If you’re not knowledgeable about the 6 parameters of this iCustom feature, I advise you to go back and browse the article Preparing a Custom Indicator for Strategy Deployment: Converting it in a iCustom Function.

If You’ve forgotten or haven’t seen exactly what a NonLagMA Customized index Seems like, Here’s a screenshot:

Before, when talking the detective job at discovering the exact manner parameter (lines/signals) of this iCustom feature, I described the info table emphasized in red supplies the visual cues. We cautioned that the NonLagMA could be your before all else style (style =0) represented with the line , Up is your next style (mode =1) represented by the blue line, and Dn will be the 3rd mode (style = 2) represented by the redline. Perhaps not represented this may be your fourth style of Trend (style = 3), however it’s represented at the code it self, with the logic being if fad == 1, fashion is upward, if fad = -1, fashion is downward.

Now that which you about Recognize the four manners of this NonLagMA habit index, you are able to conceive partially three Kinds of expert advisors Depending on Different manners:

  1. EA which is employed together the MA lineup it self (Mode=0), like in a cross over.
  2. EA which is employed together the Up Blue Line (Mode=1) along with Dn Red Line (Mode=two ), shooting buys once the NonLagMA turns blue and carrying sells as it turns reddish.
  3. EA which is employed together the Trend signal (Mode=3), purchase when fashion is upward, sell when fashion is down.

All 3 EAs will discuss equal extern factors down from:

extern int Price = 0;
extern int Length = 150;
Extern int Displace = 0; //DispLace or Shift
Extern dual PctFilter = 0; //Dynamic filter in Cartoon
Extern int Color = 1; //Switch of Color style (1-color)
Extern int ColorBarBack = 1; //Bar rear for color style
Extern dual Deviation = 0; //Up/down deviation
Extern int AlertMode = 0; //Sound Alert switch (0-off,1-forth )
Extern int WarningMode = 0; //Sound Warning switch(0-off,1-forth )
Extern int Shift # 1;

I moved across the practice of detecting the above mentioned indicator parameters while in the former article, however I shall see. The simplest method was to paste and copy the extern factors from the index sourcecode to the expert adviser, after which to populate the iCustom function index with the above mentioned identifiers, permitting them to fall AFTER the next parameter (the index name) and then BEFORE the previous two parameters (the manner and alter ).

Thus, You’d Be switching your iCustom index from the:

double ma = iCustom (NULL,0,”NonLagMA_v7.1,0,0,Shift);

to this:

double ma = iCustom (NULL, 0, “NonLagMA_v7.1”,Price,Length,Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, 0,Shift).

Note: While this particular indicator has 9 indicator parameters, it should be pointed out that the most important one is the Length. Just like the moving average, changing the length changes the fundamental structure of the NonLagMA. The other parameters can be left at the default value of 0.

NonLagMA EA #1: Working with the MA line signal (mode = 0)

NonLagMA Crossover
Intent //Buy: when close crosses over NonLagMA
//Sell: when close crosses under NonLagMA
Indicator
Calling
double macurrent = iCustom(NULL, 0, “NonLagMA_v7.1”,Price,Length,Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, 0,Shift).

double maprevious = iCustom(NULL, 0, “NonLagMA_v7.1”,Price,FastLen,Displace, PctFilter, Color, ColorBarBack, Deviation, AlertMode, WarningMode, 0,Shift 1).

double close_current = iClose (NULL,0,Shift);
double close_previous = iClose (NULL,0,Shift 1);

BuyCond if (close_current >= macurrent && close_previous