Problem Understanding How iCustom Retrieves Data

 

I am using the iCustom function to work with the BW ZoneTrader indicator. I do not fully understand the functionality of iCustom to return data. To access the indicataor I am using these lines:

ztHandle=iCustom(NULL,0,"examples\\bw-zonetrade"); 

ArraySetAsSeries(ZonetradeVal,true);

CopyBuffer(ztHandle,4,0,4,ZonetradeVal) 

All above works without error. No problems. However, when running the EA the Journal shows that:

"Not all data of ExtACHandle is calculated (619 bars). Error 4806." and,

"Not all data of ExtAOHandle is calculated (619 bars). Error 4806." 

I also find that the value of ZonetradeVal[x] is always 0. No data is being provided. After playing with it for awhile I found that by commenting out the "return(0)" lines that the program would then return data. However, it does not seem to be fully accurate. When comparing the results returned within my EA it does not match what the indicator shows on the Chart.

Can anyone explain to me why iCustom is not returning data from the indicator?

Why do I get some (but not accurate) data when the "return(0)" lines are commented?

What am I doing wrong? Or is it not possible to retrieve data using iCustom from the BW Zonetrade indicator when using the Strategy Tester?

All help would be appreciated in understanding this.  

Thanks! 

Here is a snippet below directly from BWZoneTrader:

//--- check for bars count

   if(rates_total<DATA_LIMIT)

      return(0);// not enough bars for calculation

//--- not all data may be calculated

   int calculated=BarsCalculated(ExtACHandle);

   if(calculated<rates_total)

     {

      Print("Not all data of ExtACHandle is calculated (",calculated,"bars ). Error",GetLastError());

      return(0); // If I "comment out" this line then the program continues and provides data

     }

   calculated=BarsCalculated(ExtAOHandle);

   if(calculated<rates_total)

     {

      Print("Not all data of ExtAOHandle is calculated (",calculated,"bars ). Error",GetLastError());

      return(0); // If I "comment out" this line then the program continues and provides data

     }

//--- we can copy not all data

   int to_copy;

   if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;

   else

     {

      to_copy=rates_total-prev_calculated;

      if(prev_calculated>0) to_copy++;

     }

Program continues to process data, but only when lines commented above, otherwise it returns only "0" for all values.

Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
Technical Indicators / iCustom - Documentation on MQL5
 

See Note for a CopyXXX() function:

Note

When requesting data from the indicator, if requested timeseries are not yet built or they need to be downloaded from the server, the function will immediately return -1, but the process of downloading/building will be initiated.

When requesting data from an Expert Advisor or script, downloading from the server will be initiated, if  the terminal does not have these data locally, or building of a required timeseries will start, if data can be built from the local history but they are not ready yet. The function will return the amount of data that will be ready by the moment of timeout expiration.


 
Rosh:

See Note for a CopyXXX() function:


Thanks, Rosh. After reading all info I still do not know how to properly retrieve the data using this iCustom indicator. As I understand it, the BWZonetrade indicator is written to allow the additional data to be retrieved after the initial call:   int calculated=BarsCalculated(ExtACHandle);  When debugging I see that "calculated" is always one less than "rates_total", so it: returns(0).

However, the program (on the next call) does not continue on to the next lines (shown below) to retrieve the missing data:

//--- we can copy not all data

   int to_copy;

   if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total;

   else

     {

      to_copy=rates_total-prev_calculated;

      if(prev_calculated>0) to_copy++;

     } 

The above is never called. The data returned by the indicator is always 0. Even after reading what you referred me to I do not know what to do to retrieve the indicator's values.

 Any additional help? What should I do?

Thanks. 

Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
Technical Indicators / iCustom - Documentation on MQL5