Multi line Indicator cant fetch values at bar0

Isho777
11
Isho777  

hello, 

I have a multiline separate indicator with 4 line graphs and I want to print the latest value from line index 2 from TDI indicator

I tried this  

                //Expert advisor
double buff[];  //buffer array
int h;          //handle for icustom chart  

int OnInit()
{
      h = iCustom(_Symbol,PERIOD_CURRENT,"TDI");   //indicator name
      CopyBuffer(h,2,0,100,buff);      //to copy 100 values from line index 2 
      
      Print("Sample..",buff[0]);       //To Print the latest value at bar0

      return(INIT_SUCCEEDED);
 }

There is no error from handler h

But CopyBuffer() throws error 4806 which says  "the requested data was not found",

but it prints line index 0 values instead 

I assumed that the second argument in copybuffer refers  to  line index 2 from which im copying values.

I also tried mq4 style to copy from line 2

h = iCustom(_Symbol,PERIOD_CURRENT,"TDI", 2, 0);

which cannot load the custom chart handler (throws error).

So in MQL5  how do I specify line index 2 from custom  chart?


Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
CopyBuffer - Timeseries and Indicators Access - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5