Need help!

 

////this is only use in instaforex, because its spreed is 0/////// 


extern int takeprofit=0;
extern int stoplost=5;
extern double initiallot=1.0;
extern int magic.number=19802;
extern int trailpoint=10;
extern int averagelot=15;

double buylot;
double totallost;
int barcount;

int init()
  {
   barcount=iBars(Symbol(),60);
   return;
  }
  

void start()
  {
   if(checkopen()==0 && TimeMinute(Time[0])!=59 && barcount!=iBars(Symbol(),60))
     {
      if(iOpen(Symbol(),60,1)<iClose(Symbol(),60,1) && Ask>=iClose(Symbol(),60,1)+3*Point)
        { 
         OrderSend(Symbol(),OP_BUY,initiallot,Ask,3,Ask-stoplost*Point,takeprofit,"",magic.number);
        }
      if(iOpen(Symbol(),60,1)>iClose(Symbol(),60,1) && Ask<=iClose(Symbol(),60,1)-3*Point)
        {
         OrderSend(Symbol(),OP_SELL,initiallot,Ask,3,Bid+stoplost*Point,takeprofit,"",magic.number);
        }
     }
   closeatlastmin();
  }


void closeatlastmin()
  {
   if(TimeMinute(Time[0])==59)
     {
      int l;
      for(l=0;l<=OrdersTotal()+1;l++)
        {
         if(OrderSelect(l,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==magic.number)
           {
            OrderClose(OrderTicket(),OrderLots(),Ask,3);
           }
        }
     }
  }
       
int checkopen()
  {
   int i;
   for(i=0;i<=OrdersTotal()+1;i++)
     { 
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
        { 
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic.number)
           {
            return(1);
           }
        }
     }
   return(0);
  }

  

This EA is run in period M1 to trade every hour. The whole ideal it that if price lower or higher the closing price the place an order. But when I run this EA in GBPUSD, M1, from 2011.11.03 to 2011.11.18, and check the results one by one and found that it missed few hours, like the 11th, 13th,16th hour in 2011.11.03. I have no idea how this happen. Could somebody help me? Appreciate your time and helps!!

 
Pain:

and found that it missed few hours, like the 11th, 13th,16th hour in 2011.11.03. I have no idea how this happen.

Have you checked an M1 chart or the History Centre to make sure that you have M1 data for that date and time ?
 
RaptorUK:
Have you checked an M1 chart or the History Centre to make sure that you have M1 data for that date and time ?

I checked it, and they do have all data for that day.
 
OK, add a few Print statements to print out key variables/function return values involved in your decision taking, run the days where you think trades should be taken, watch the variables and find out where the problem is.
 
RaptorUK:
OK, add a few Print statements to print out key variables/function return values involved in your decision taking, run the days where you think trades should be taken, watch the variables and find out where the problem is.

thanks so much!! I find out why.
 
Pain:

thanks so much!! I find out why.
Well done :-)