Search code examples
indicatormetatrader4mql4

MQL4 Indicator passing signal to EA


the problem is, I want to open order when my indicator gives signal. How can I do that?

I have been trying to do with iCustom() but it is not satisfying.

I tried to use GlobalVariableSet() in indicator and GlobalVariableGet() method in EA but it is not properly worked.

Please help.


Solution

  • The syntax is:

    double  iCustom(
       string       symbol,           // symbol
       int          timeframe,        // timeframe
       string       name,             // path/name of the custom indicator compiled program
       ...                            // custom indicator input parameters (if necessary)
       int          mode,             // line index
       int          shift             // shift
       );
    

    Here is the example using custom Alligator indicator (which should be available by default as Alligator.mq4 in MT platform).

    double Alligator[3];
    Alligator[0] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 0, 0);
    Alligator[1] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 1, 0);
    Alligator[2] = iCustom(NULL, 0, "Alligator", 13, 8, 8, 5, 5, 3, 2, 0);
    

    where 13, 8, 8, 5, 5, 3 are corresponding input parameters of custom Alligator as defined in indicator it-self:

    //---- input parameters
    input int InpJawsPeriod=13; // Jaws Period
    input int InpJawsShift=8;   // Jaws Shift
    input int InpTeethPeriod=8; // Teeth Period
    input int InpTeethShift=5;  // Teeth Shift
    input int InpLipsPeriod=5;  // Lips Period
    input int InpLipsShift=3;   // Lips Shift
    

    and mode is the corresponding line index as defined in the indicator by:

    SetIndexBuffer(0, ExtBlueBuffer);
    SetIndexBuffer(1, ExtRedBuffer);
    SetIndexBuffer(2, ExtLimeBuffer);