Download MetaTrader 5

unable to fetch data from another chart

To add comments, please log in or register
Desmond Ong
Desmond Ong  
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);
                        if (AllowBuyOrder) {
                              o1-c1>0*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
Alain Verleyen  
If data are not available iOpen and iClose will return 0, you have to check for errors, and read the documentation.
iOpen - MQL4 Documentation
iOpen - MQL4 Documentation
To add comments, please log in or register