Is there something that I'm doing wrong?

Back to topics list To post a new topic, please log in or register
avatar
186
Yellowbeard 2016.03.22 22:30
 
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!

avatar
2017
gooly 2016.03.22 23:22 #
 

Make sure the symbols appear in the marketwatch.

Check SymbolSelect().

avatar
186
Yellowbeard 2016.03.22 23:31 #
 
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.
avatar
Moderator
3422
GumRai 2016.03.23 00:37 #
 
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

avatar
13006
WHRoeder 2016.03.23 01:31 #
 
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.
avatar
186
Yellowbeard 2016.03.23 01:37 #
 

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

Thank you, very much!

Back to topics list  

To add comments, please log in or register