iCustom indicator values are blank

I am not sure what’s going on at all and could use help. I am building an EA based off a custom indicator. I know the indicator is getting called properly now because it’s displaying on the chart. However, I am getting no values.

Here’s the code I’m using:

double stuff = iCustom(NULL,0,"MyIndicator","",50,true,true,true,17,12,7,false,10,1);

if(stuff > 0) { 
printf("Indicator result: ",stuff," - Order to buy");
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}

I even tried this:

printf("PipFinite: ",DoubleToStr(stuff)," - Order to buy");

I even tried this:

printf("PipFinite: ",DoubleToStr(stuff)," - Order to buy");

Still empty.

And this:

double stuff = iCustom(NULL,0,"MyIndicator","",50,true,true,true,17,12,7,false,0,1);

if(stuff > 0) { 
printf("Indicator result: ",stuff," - Order to buy");
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,0,0,"",MAGICMA,0,Red);
return;
}

I noticed in the readme for the indicator, that it has 12 buffers, and I’m looking for # 10. Am I doing something wrong? Why am I not getting any values?

Thanks.

Hi !

  1. iCustom returns the handle of a specified custom indicator,please check : https://www.mql5.com/en/docs/indicators/icustom

  2. To get the value from a buffer,you need to use CopyBuffer,please check : https://www.mql5.com/en/docs/series/copybuffer

You need to do something like this:

double Value[];
int indicator_handler = iCustom(NULL,0,"MyIndicator","",50,true,true,true,17,12,7,false,10,1);

if(indicator_handler != INVALID_HANDLER) // CHECKING IF THE CASE OF FAILURE TO LOAD INDICATOR
{
CopyBuffer(indicator_handler,9,0,1,Value); // COPYING THE VALUE FROM THE BUFFER TO ARRAY

if(Value[0] > 0) // CHECK IF THE LAST VALUE IS > 0,SO BUY
{
// buy
}
}

You’re using the printf function wrong. If you want to print params they way your are passing them you need to use the Print function instead.

It depends if your code is MQL4 or MQL5. iCustom application is different in each of them. But don’t forget that numbering buffers starts from 0. If you are looking for the tenth buffer you have to use 9 as index.

double stuff = iCustom(NULL,0,"MyIndicator","",50,true,true,true,17,12,7,false,10,1);

If there are n items, their positions are [0 … n-1]. You want the tenth buffer, but looking at the eleventh.

You should encapsulate your iCustom calls to make your code self-documenting.
Detailed explanation of iCustom - MQL4 and MetaTrader 4 - MQL4 programming forum