Comment(iOpen) shows value of "0.0" - Is my script too fast? Or my PC / internet connection too slow?

To add comments, please log in or register
kiikek
30
kiikek  

Hi everyone,

I'm new to coding and have encountered a problem.
I wrote this script and compiled it with no problems.


void OnStart()
  {


Comment(iOpen("EURAUD",PERIOD_W1,5));
  }


I then open a new random chart, say AUDJPY. And then I drop the script on to the chart.
But the number being displayed is simply "0.0". See for yourself, I posted a screenshot:


Comment(iOpen("EURAUD",PERIOD_W1,5)); gives me 0.0 ?


A few seconds later, I close this chart. Open a new one and drop the very same script onto the chart again.
This time, it shows me a value, and a correct one at that. See screenshot:

the same script..on a new chart..after waiting a few seconds


Is there an explanation for this?
Could it be my computer being very slow? And it had to wait for a few seconds first before it was able to "pull" this piece of information from the broker? And then, when it already had this piece of info and I tried to retrieve it again, it was able to simply pull it from the history center table (F2)?

Because my computer, a notebook from 2007, is indeed super slow (I needed 387ms just to compile this simple script).

Please help, I need to know why this is happening.

William Roeder
20248
William Roeder  
kiikek: I need to know why this is happening.
On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing prices.
          Download history in MQL4 EA - MQL4 and MetaTrader 4 - MQL4 programming forum
To add comments, please log in or register