What is wrong with my EA ? - page 2

 
Marco vd Heijden:
Volume can become very large and you declared it a double where it needs to be long type.

Hello Marco,

I did not code the indicator myself. I took it from forex factory. It might become a problem but at the moment, I am struggling with iCustom not reading the correct values from the indicator. You think this could be reason for iCustom to NOT read the values properly ?

 
if it's working ICustom should read the value correctly the indicator is full of bugs.
 
Marco vd Heijden:
if it's working ICustom should read the value correctly the indicator is full of bugs.

tick volume stays around max 10,00,000 - 30,00,000 on monthly chart. Double in MQL can hold up til 1.7976931348623158e+308 values so it should be able to handle it. To me what's confusing is that we are able to see these values from data window for Climax high, Climax low.

I found this article which says that Indicatorcounted() func does not work in EA so I changed the indicator now but still no luck:

https://www.mql5.com/en/articles/1456

Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure
Transferring an Indicator Code into an Expert Advisor Code. Indicator Structure
  • 2007.09.25
  • Nikolay Kositsin
  • www.mql5.com
This article dwells on the ways of transferring an indicator code into an Expert Advisor Code and on writing Expert Advisors with no calling to custom indicators, and with the whole program code for the calculation of necessary indicator values inside the Expert Advisor. This article gives a general scheme of an indicator structure, emulation of indicator buffers in an Expert Advisor and substitution of the function IndicatorCounted(). The article is intended for readers, already having experience of programming in MQL4 language.
 
I dosn't even compile properly i just wonder how you use it.
 
Marco vd Heijden:
I dosn't even compile properly i just wonder how you use it.

vol.mq4 is the indicator (MQL4/indicators)

vpa.mq4 is the ea (MQL4/scripts)

IncludeExample.mqh(MQL4/include)

Please check it. It should work properly.

Files:
vol.mq4  6 kb
vpa.mq4  5 kb
 

Hello All,

Anyone ? I have uploaded all the files. You can test it yourself. Any kind of help will be appreciated.

Please do not come up with that 'you have to read the documentation'. I understand that you are trying to help but please be more specific and I can follow that direction.

 

It works if iCustom() is explicitly cast from double to long.

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   long up=(long)iCustom(NULL,0,"Better Volume",0,1);
   long down=(long)iCustom(NULL,0,"Better Volume",4,1);
   static datetime prevTime;
   if(prevTime!=Time[0])
     {
      printf("up[1]=%.0f down[1]=%.0f",up,down);
      prevTime=Time[0];
     }
  }

Files:
 
s9919:

 so it should be able to handle it.

Yet it does not.

There is no should in coding it needs to be precise.

 
pipPod:

It works if iCustom() is explicitly cast from double to long.

hello pipPod:

Great. A gazillion thanks man. You made my day.

can't Thank you enough :)

Cheers.

 
Marco vd Heijden:

Yet it does not.

There is no should in coding it needs to be precise.

Yeah you were right. pipPod pointed out the problem. Thanks a lot for your help.
Reason: