is this correct implementation of iCustom in mql5

 

I am trying to read the buffer value of an mt5 indicator , which has 4 buffers and 2 input parameters 


and this is how i am using it in iCustom :

iCustom(NULL,0,"LTD by KDMfx",inp1,inp2,
indbuffer ,candshift);

where inp1 and inp2 are the 2 input parameters of the "LTD by KDMfx" indicators , and indbuffer is the buffer of the indicator i want to read , and the candshift is the candle id of the shift in candle.

is this the wrong implementation of the iCustom in mql5? because i am getting value "10" no matter what cadle shift or what indbuffer i use 

 

OK, I bet you are receiving the handle to the indicator and think its the value you are retrieving.

But it is only a guess, since you do not show the full code around the function-call iCustom(...);

it works like this:

double values[];

int handle = iCustom(...);

CopyBuffer(handle, ..., values);

 
Dominik Egert:

OK, I bet you are receiving the handle to the indicator and think its the value you are retrieving.

But it is only a guess, since you do not show the full code around the function-call iCustom(...);

Here is the full code :

#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
int inp1=5;
int inp2=300;
int indbuffer=3;
int candshift=15;
int OnInit()
  {
   EventSetMillisecondTimer(1);
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
   EventKillTimer();
   
  }
void OnTick()
  {  
  }
 
void OnTimer()
  {
      if(iCustom(NULL,0,"LTD by KDMfx",inp1,inp2,indbuffer ,candshift));
     {
      Print("asd");
     }
  }

actually this is my first time working with mt5 or mql5 , and i am trying to see how the iCustom works , or if its the same in mql5 as mql4 , thats why i just used these 2 lines to print the buffer value.

 
Dominik Egert:

OK, I bet you are receiving the handle to the indicator and think its the value you are retrieving.

But it is only a guess, since you do not show the full code around the function-call iCustom(...);

it works like this:

so we give the indicator buffer to read in the iCustom or inside of the handle ?

 
Arad_1 :


You are making a gross mistake: in MQL5 you create a handle AT EVERY TICK (in your case, every N-seconds).

Remember: in MQL5, the indicator handle MUST be created ONCE and it must be done in OnInit ().

 
Just place the editor cursor on iCustom and press F1 then study the example - it tells you everything you need.