Super simple example of EA and Technical Indicator... almost works what am I doing wrong

 

I am trying to understand how an EA gets data from a custom indicator. So I wrote a very simple example, but and I feel I understand it, but my EA says it get 16.1,0.0 but I am expecting 16.1,16.2.

Where am I going wrong?

Indicator code:

input int TestInput;
double test0[] = {0};
double test1[] = {0};

int OnInit()
{
    SetIndexBuffer(0, test0);
    SetIndexBuffer(1, test1);
    return(INIT_SUCCEEDED);
}

int start() // incoming tick
{
   Print("start indicator input ", TestInput);
   test0[0] = 16.1;
   test1[0] = 16.2;
   return(0);
}
The 0 is buffer 0 and 1 is buffer 1, which contain 16.1 and 16.2.


And the EA:

void OnTick()
{
   int shift = 0;
   double test0 = iCustom(NULL, PERIOD_M5, "SimpleIndicator", 23,  0, shift);  
   double test1 = iCustom(NULL, PERIOD_M5, "SimpleIndicator", 24,  1, shift);
   Print("Simple says ", NormalizeDouble(test0, 2), ",", NormalizeDouble(test1, 2));
}

What's wrong with this?

Thanks

 
gerryha: Where am I going wrong?

You haven't stated how many buffers your indicator has.

 
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
William Roeder:

You haven't stated how many buffers your indicator has.

There are two - see in the code? Are you saying there is some kind of declaration required to declare how many buffers there are?
 
gerryha:

Seriously, where is this MT4 section? If I got to mql4.com it just redirects me to mql5, can you provide a link?

Click on forum at the top of the page, you will see a list of all the sections and the most recent posts.

This topic is in the correct section now.

Keith Watford:
Topics concerning MT4 and MQL4 have their own section.
In future please post in the correct section.
I have moved your topic to the MQL4 and Metatrader 4 section.
 
gerryha:
There are two - see in the code? Are you saying there is some kind of declaration required to declare how many buffers there are?

I see! I added the following line at the top and now it works.


#property indicator_buffers 2