Is there something that I'm doing wrong?

 
It's been a while since I've been back to coding, but the following code doesn't seem  to return the values I'm looking for, just zeros.
        double vDO=iOpen("NZDUSD",1440,0);       // Daily Open
        double vDC=iClose("NZDUSD",1440,0);      // Daily Close     
        
        Alert("vDO =  ",vDO,"    vDC =  ",vDC);  

No matter where I place the code within an EA or indicator, I just get zeros.  Can I not assign a value of iOpen or iClose to a variable anymore?


Thanks!

 

Make sure the symbols appear in the marketwatch.

Check SymbolSelect().

 
I've never had a problem before using this code this way.
Alert("Current bar for USDCHF H1: ",iTime("USDCHF",PERIOD_H1,0),", ",  iOpen("USDCHF",PERIOD_H1,0),", ",
                                      iHigh("USDCHF",PERIOD_H1,0),", ",  iLow("USDCHF",PERIOD_H1,0),", ",
                                      iClose("USDCHF",PERIOD_H1,0),", ", iVolume("USDCHF",PERIOD_H1,0));
The above code works.  Not sure why the previous code doesn't.  I can usually add this code anywhere within an EA or indicator.  Inside loops or outside.  But no matter where I place it now, even with different brokers, I get nothing but zeros.
 
Yellowbeard:
It's been a while since I've been back to coding, but the following code doesn't seem  to return the values I'm looking for, just zeros.
        double vDO=iOpen("NZDUSD",1440,0);       // Daily Open
        double vDC=iClose("NZDUSD",1440,0);      // Daily Close     
        
        Alert("vDO =  ",vDO,"    vDC =  ",vDC); 

No matter where I place the code within an EA or indicator, I just get zeros.  Can I not assign a value of iOpen or iClose to a variable anymore?


Thanks!

Is there a symbol called "NZDUSD" with the brokers that you have used?

The code should work if there is

 
If your chart isn't exactly "EURUSD" then it can't work. Broker's use a variety of naming patterns: EURUSD, EURUSDm, EURUSDi, "EURUSD.", "EURUSD..", "EUR.USD", "EUR/USD", "EURUSD.stp", EURUSDct, "EURUSD.G", "EURUSD+", and EURUSDpro at least. Don't hard code things; just use the predefined _Symbol.
 

Ah!  My broker uses NZDUSDpro.  That did the trick!  Never dawned on me.

Thank you, very much!

Reason: