Download MetaTrader 5

unable to fetch data from another chart

To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
Desmond Ong
817
Desmond Ong 2015.07.23 17:48 
hi, anyone have idea why this part of my code don't work ? the only way for it to work is to cancel the part where o1-c1>0 point. is it because i could not fetch data from EURUSD?
        if (newBar) {   
                if (!tradeExists) {
                        
                        double o1,h1,l1,c1;
                        double o2,h2,l2,c2;
                        
                        o1 = iOpen("EURUSD", PERIOD_M15, 1);
                        h1 = iHigh("EURUSD", PERIOD_M15, 1);
                        l1 = iLow("EURUSD", PERIOD_M15, 1);
                        c1 = iClose("EURUSD", PERIOD_M15, 1);
                        
                        o2 = iOpen(Symbol(), TimeFrame, 1);
                        h2 = iHigh(Symbol(), TimeFrame, 1);
                        l2 = iLow(Symbol(), TimeFrame, 1);
                        c2 = iClose(Symbol(), TimeFrame, 1);
                        
                                                
                        //Buy
                        if (AllowBuyOrder) {
                           if(
                              o1-c1>0*Point &&
                              o2-c2>30*Point  
                           
                              ){
                              double sl = o2-SLBuffer*pip;
                                   double tp = o2;
                                   int ticket = MyOrderSend(Symbol(), OP_BUY, Lot, Ask, 99, sl, tp, WindowExpertName(), MagicNumber1, 0, clrBlue);
                                }
                        }
Alain Verleyen
Moderator
30739
Alain Verleyen 2015.07.23 18:15  
If data are not available iOpen and iClose will return 0, you have to check for errors, and read the documentation.
iOpen - MQL4 Documentation
  • docs.mql4.com
iOpen - MQL4 Documentation
To add comments, please log in or register