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");

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.

 
satsui:

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:


I even tried this:

Still empty.

And this:

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 that :
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
}
}


Documentation on MQL5: Technical Indicators / iCustom
Documentation on MQL5: Technical Indicators / iCustom
  • www.mql5.com
[in]  The name of the custom indicator, with path relative to the root directory of indicators (MQL5/Indicators/). If an indicator is located in a subdirectory, for example, in MQL5/Indicators/ [in] input-parameters of a custom indicator, separated by commas. Type and order of parameters must match. If there is no parameters specified, then...
 
satsui:

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:


I even tried this:

Still empty.

And this:

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.

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. 

 
satsui:

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:


I even tried this:

Still empty.

And this:

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.

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.
 
satsui: 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?
  1. Why did you post your MT4 question in the Root / MT5 EA section instead of the MQL4 section, (bottom of the Root page?)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
    Next time post in the correct place. The moderators will likely move this thread there soon.

  2. 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.

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