[SOLVED] iCustom trouble

 

Hello,


I am trying to get the values from indicator attached with iCustom:


int barx = 0;

int Loops = 8;

   for(int x=0; x<=Loops; x++)

   {

   ObjectCreate("TEST" + (string)x, OBJ_LABEL, 0, 0, 0);

   ObjectSet("TEST" + (string)x, OBJPROP_CORNER, 3);

   ObjectSet("TEST" + (string)x, OBJPROP_XDISTANCE, 20);

   ObjectSet("TEST" + (string)x, OBJPROP_YDISTANCE, 300 - ((x+1)*20) );

   ObjectSetText("TEST" + (string)x, (string)x + " - " + (string)barx + " =   " + DoubleToStr(iCustom(NULL,0,"hull_average_x_2_-_ver_1_1_mtf","4 hours",0,50,"Weighted",100,"Weighted",false,false,true,true,"alert2.wav",false,false,"Hull Arrows",0.5,1.0,LimeGreen,Red,241,242,2,2,"Linear Interpolation",x, barx),5), 12, "Batang", White);
   
   }   



But ICustom doesn't return the correct values.


ICustom


The correct values should be 1.1398 and 1.1330 (yellow texts) but ICustom return wrong values 1.13193 and 1.13263 (2 white lines).

What am I missing?

Please help... 

Thanks.

 

Data Window also shows correct values (GREEN arrows) but ICustom returns wrong values (RED arrows).


Data_Window


Please help....

 
 ObjectSetText("TEST" + (string)x, (string)x + " - " + (string)barx + " =   " 
   + DoubleToStr(iCustom(NULL,0,"hull_average_x_2_-_ver_1_1_mtf",PERIOD_H4,0,50,PRICE_WEIGHTED,100,PRICE_WEIGHTED, x, barx),5), 12, "Batang", White);

You can omit the item "Turn alerts on?" and all the rest.

 

Hi,

So some input parameter to indicator is incorrect,try this below(some parameters are in enumerator value,so string input doesnt work):


ObjectSetText("TEST" + (string)x, (string)x + " - " + (string)barx + " =   " + DoubleToStr(iCustom(_Symbol,PERIOD_CURRENT,"hull_average_x_2_-_ver_1_1_mtf.ex4",PERIOD_H4,0,50,PRICE_WEIGHTED,100,PRICE_WEIGHTED,false,false,true,true,"alert2.wav",false,false,"Hull Arrows",0.5,1.0,clrLimeGreen,clrRed,241,242,2,2,1,x, barx),_Digits), 12, "Batang", White);
   

Regards.

 
Naguisa Unada:

You can omit the item "Turn alerts on?" and all the rest.

Thanks a lot Naguisa Unada for the guidance, now it works correctly.

But how to get values from CUSTOM time frame?

Trying with:

iCustom(NULL,0,"hull_average_x_2_-_ver_1_1_mtf","Custom Time Frame",17,10,PRICE_WEIGHTED,20,PRICE_WEIGHTED, x, barx)

doesn't work, ICustom returns wrong values.

Please help...

 
Mehrdad Jeddi:

Hi,

So some input parameter to indicator is incorrect,try this below(some parameters are in enumerator value,so string input doesnt work):

Regards.

Thanks a lot Mehrdad Jeddi for the guidance, now it works correctly.

But how to get values from CUSTOM time frame?

Trying with:

iCustom(_Symbol,PERIOD_CURRENT,"hull_average_x_2_-_ver_1_1_mtf.ex4","Custom Time Frame",17,10,PRICE_WEIGHTED,20,PRICE_WEIGHTED,false,false,true,true,"alert2.wav",false,false,"Hull Arrows",0.5,1.0,clrLimeGreen,clrRed,241,242,2,2,1,x, barx

doesn't work, ICustom returns wrong values.

Please help...

 

Also trying with:

iCustom(_Symbol,PERIOD_CURRENT,"hull_average_x_2_-_ver_1_1_mtf",10,17,10,PRICE_WEIGHTED,20,PRICE_WEIGHTED, x, barx)

doesn't work, ICustom still returns wrong values.

Please help...

 

Finally found out how to make works with custom time frame.

iCustom(_Symbol,PERIOD_CURRENT,"hull_average_x_2_-_ver_1_1_mtf",17,17,10,PRICE_WEIGHTED,20,PRICE_WEIGHTED, x, barx)

Thanks for all the help.

 

Hey,

I hope its ok if i use this thread, as i am having some trouble with iCustom aswell.


I am trying to use this indicator in an EA :   https://www.mql5.com/en/code/1488   I would like to generate buy/sell signals when the Indicator changes color. However to do so i would have to access a buffer of the indicator. I saw that in MT4 you can specify a "mode" or line index to so that icustom outputs a certain bufferindex. How would i go about acessing a buffer other than the one with index 0 in mt5?

Slope Direction Line
Slope Direction Line
  • www.mql5.com
Slope Direction Line is the trend indicator drawn on the basis of Moving Average. Trade decisions are taken according to the position of the indicator line in relation to price and its color change.
 

dodo3441:

... I would like to generate buy/sell signals when the Indicator changes color. However to do so i would have to access a buffer of the indicator. I saw that in MT4 you can specify a "mode" or line index to so that icustom outputs a certain bufferindex. How would i go about acessing a buffer other than the one with index 0 in mt5?

You can select the buffer index in CopyBuffer. Look here for a sample: https://www.mql5.com/en/docs/series/copybuffer

int  CopyBuffer(
   int       indicator_handle,     // indicator handle
   int       buffer_num,           // indicator buffer number
   int       start_pos,            // start position
   int       count,                // amount to copy
   double    buffer[]              // target array to copy
   );
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Counting of elements of copied data (indicator buffer with the index buffer_num) from the starting position is performed from the present to the past, i.e., starting position of 0 means the current bar (indicator value for the current bar). When copying the yet unknown amount of data, it is recommended to use a dynamic array as a buffer[]...
Reason: