Trouble with bars

 

Hi everyone,

My very small EA is not counting the bars properly..... I thought that if I'm in a 5' chart window, it would do it, but it does not.
So because I'm new at this, I'm trying with something very small, just delivering buy stops and sell stops at 20 pips from the last bar high and low.
It does compiles fine, however the EA is sending many orders per bar, not just 1 and 1.
What is the problem with it?

//+------------------------------------------------------------------+
//|                                                    First try.mq4 |
//|                                                            Pablo |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Pablo"
#property link      ""
 
//---- input parameters
 
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
  
   int    TicketPendingOrderLong, TicketPendingOrderShort;
   double point;
   point=MarketInfo(Symbol(),MODE_POINT);
 
 
 
     {
      TicketPendingOrderLong=OrderSend(Symbol(),OP_BUYSTOP,1.0,High[1]+20*Point,5,High[1]-10*Point,High[1]+50*Point,"Long pending order",16384,0,Green);
      if(TicketPendingOrderLong<=0) Print("Error = ",GetLastError());
      TicketPendingOrderShort=OrderSend(Symbol(),OP_SELLSTOP,1.0,Low[1]-20*Point,5,Low[1]+10*Point,Low[1]-50*Point,"Short pending order",16384,0,Green);
      if(TicketPendingOrderShort<=0) Print("Error = ",GetLastError());
      return(0);
      }
 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+