Download MetaTrader 5
To add comments, please log in or register
Are you a good trader? Become a signals provider and make even more money!
Paul
529
Paul 2016.03.22 21: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!

Carl Schreiber
5938
Carl Schreiber 2016.03.22 22:22  

Make sure the symbols appear in the marketwatch.

Check SymbolSelect().

Paul
529
Paul 2016.03.22 22: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.
Keith Watford
Moderator
7896
Keith Watford 2016.03.22 23: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

whroeder1
13602
whroeder1 2016.03.23 00: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.
Paul
529
Paul 2016.03.23 00:37  

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

Thank you, very much!

/
To add comments, please log in or register