Help with Simple Code Programed Into An EA??

 
I want to have a variable that I can tell the EA to only put 1 Pending or 10 Pendings in at 1 time. I am talking about positions NOT Lots. Right now it puts 1 pending in But if the Current Price is at the High or Low it puts about 8 positions in. I want ONLY the number I program to be put in.

This EA puts pending orders in at the High and Low of the Hour it is programed for.

//+------------------------------------------------------------------+
//|                                             Observation Hour.mq4 |
//|                      Copyright © 2007, MetaQuotes Software Corp. |
//|                                        https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "https://www.metaquotes.net//"
 
 
extern string    basicheader="== Basic Settings ==";
extern double    TakeProfit=30;
extern double    Stoploss=15;
extern double    Lots=0.1;
extern string    sSoundFileName = "alert.wav";
 
extern string    stratheader="== Strategic Settings ==";
extern int       observationHour=00;         
                 // This value is the hour that the EA will look to for the highs and lows.
                 // This will have to be changed due to differing time zones.  
                 // The times that the EA will be provided with are the time zone of your broker, 
                 // not YOUR time zone where you live.                                             
                 // Pending orders will be placed on the first or second minute of the hour after 
                 // observation hour.
                 // It's default setting of 13 is in accordance with the strategy for time 
                 // zone GMT; pending orders will be placed at 14:00 or 14:01.  
                 // Example: If your broker is in EST time zone, the value would be 8.
                 
extern string    stopheader="== Advanced Stops ==";
extern double    TrailingStop=15;
extern bool      UseTrailingStop=false;
extern bool      UseTrailingStopOnlyProfit=false;
extern int       breakEvenAtProfit=0;
extern int       breakEvenShift=0;
extern int       SteppingStop=0;
 
extern string    mischeader="== Misc. Options ==";
extern string    shortName="Observation Hour";
extern int       magicNum=78751651;
 
 
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
 
   int allOrders=0, buyPending=0, sellPending=0;
   checkOrderStatus(allOrders,buyPending,sellPending);
   advancedStopManager(allOrders);
 
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
double highestHigh=0, lowestLow=1000;
int index=1;
 
// Determine the entry values for the upcoming set of orders
while (index != 13)
   {
      if (iHigh(NULL, 5, index)>highestHigh)
         highestHigh=iHigh(NULL, 5, index);
      if (iLow(NULL, 5, index)<lowestLow)
         lowestLow=iLow(NULL, 5, index);
      index++;
   }
 
   
   
   
// Place pending orders once the Observation Hour has passed
if (Hour()==observationHour+1 && (Minute()==1 || Minute()==0))
   {
      if (buyPending==0)
         sendBuyPending(highestHigh+0*Point);
      if (sellPending==0)
         sendSellPending(lowestLow-0*Point);
         PlaySound(sSoundFileName);
   }
 
   
 
 
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
   return(0);
  }
  
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
 
void regularTrailingStop() // Standard Version 1.6
{
   int cnt, total = OrdersTotal();
   
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
 
      if(OrderType()<=OP_SELL && orderBelongsToMe())
        {if(TrailingStop>0)  
           {if(OrderType()==OP_BUY)
              {if(OrderStopLoss()<Bid-Point*TrailingStop)
                 { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); 
                 }}}
            else
              {if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                 { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); 
                 }}}}
}
 
//+------------------------------------------------------------------+
 
void onlyProfitTrailingStop() // Standard Version 1.6
   {
   
   int cnt, total = OrdersTotal();
 
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
 
      if(OrderType()<=OP_SELL && orderBelongsToMe())
        {if(TrailingStop>0)  
           {if(OrderType()==OP_BUY)
              {if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {if(OrderStopLoss()<Bid-Point*TrailingStop)
                    { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green); 
                        }}}}
            else
              {if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
                    { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red); 
                        }}}}}}
   
//+------------------------------------------------------------------+
 
void closeSellOrder() // Standard Version 1.6
   {
   int cnt, total = OrdersTotal();
 
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_SELL && orderBelongsToMe())
           {OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE); 
             }}}
 
//+------------------------------------------------------------------+
 
void closeBuyOrder() // Standard Version 1.6
   {
   int cnt, total = OrdersTotal();
 
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if(OrderType()==OP_BUY && orderBelongsToMe())
           {OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE); 
             }}}
 
//+------------------------------------------------------------------+
 
void breakEvenManager() // Standard Version 1.6
 
   {
   
   for(int cnt=0;cnt<OrdersTotal();cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
 
      if(OrderType()<=OP_SELL && orderBelongsToMe())
        {if(breakEvenAtProfit>0)  
           {if(OrderType()==OP_BUY)
              {if(Bid-OrderOpenPrice()>=Point*breakEvenAtProfit)
                 {if(OrderStopLoss()!=OrderOpenPrice() + breakEvenShift*Point)
                    { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+ breakEvenShift*Point,OrderTakeProfit(),0,Green); 
                        }}}}
             else
              {if((OrderOpenPrice()-Ask)>(Point*breakEvenAtProfit))
                 {if(OrderStopLoss()!=OrderOpenPrice() - breakEvenShift*Point)
                    { OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()- breakEvenShift*Point,OrderTakeProfit(),0,Red); 
                        }}}}}}
   
//+------------------------------------------------------------------+
 
 // Standard Version 1.6
void checkOrderStatus(int& allOrders,int& buyPending, int& sellPending)
{
   for(int cnt=OrdersTotal();cnt>=0;cnt--)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
      if( orderBelongsToMe() )
        {  
        if (OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT)
            {buyPending++; allOrders++;}
         else if (OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT)
            {sellPending++; allOrders++;}
 
        }
     }
}
 
//+------------------------------------------------------------------+
 
void advancedStopManager(int allOrders) // Standard Version 1.6
{
   if (UseTrailingStopOnlyProfit && UseTrailingStop)
      {Print("Both Trailing Stops are enabled.  Defaulting to Regular TS.");}
    
   if (allOrders >= 1)
   {
      if (SteppingStop>0)
         steppingStopManager();
      if (breakEvenAtProfit>0)
         breakEvenManager();
      if (UseTrailingStop)
          regularTrailingStop();
      else if (UseTrailingStopOnlyProfit)
          onlyProfitTrailingStop();
    }
}
 
//+------------------------------------------------------------------+
 
void steppingStopManager() // Standard Version 1.6
{
 
   int cnt, total = OrdersTotal();
   
   for(cnt=0;cnt<total;cnt++)
     {
      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
 
      if(OrderType()<=OP_SELL && orderBelongsToMe())
        {if(SteppingStop>0)  
           {if(OrderType()==OP_BUY)
              {if(OrderStopLoss()<Bid-Point*SteppingStop)
                 { OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*SteppingStop,OrderTakeProfit(),0,Green); 
                 }}}
            else
              {if((OrderStopLoss()>(Ask+Point*SteppingStop)) || (OrderStopLoss()==0))
                 { OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*SteppingStop,OrderTakeProfit(),0,Red); 
                 }}}}
 
}
 
//+------------------------------------------------------------------+
 
bool orderBelongsToMe() // Standard Version 1.6
{
if (
    OrderSymbol()==Symbol() && 
    OrderMagicNumber()==magicNum && 
    OrderComment()==shortName + " " + Period()
    )
   return (true);
else
   return (false);
}
 
//+------------------------------------------------------------------+
 
void sendBuyPending(double entryPrice) // Standard Version 1.6
{
   double Stopvalue=0, TPvalue=0;
   int ticket, oType;
   string typeName;
 
   if (Stoploss>0)   {Stopvalue = entryPrice-Stoploss*Point;}
   if (TakeProfit>0) {TPvalue = entryPrice+TakeProfit*Point;}
 
   if (entryPrice>Ask) { oType=OP_BUYSTOP; typeName="BUYSTOP"; }
   if (entryPrice<Ask) { oType=OP_BUYLIMIT; typeName="BUYLIMIT"; }
 
   ticket=OrderSend(Symbol(),oType,Lots,entryPrice,3,Stopvalue,TPvalue,shortName + " " + Period(),magicNum,0,Green);
   if(ticket>0)
     {if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print(shortName + " " + typeName + " order at ",OrderOpenPrice()); }
   else 
     {Print("Error opening " + typeName + " order : ",GetLastError());}
}
 
//+------------------------------------------------------------------+
 
void sendSellPending(double entryPrice) // Standard Version 1.6
{
   double Stopvalue=0, TPvalue=0;
   int ticket, oType;
   string typeName;
 
   if (Stoploss>0)   {Stopvalue = entryPrice+Stoploss*Point;}
   if (TakeProfit>0) {TPvalue = entryPrice-TakeProfit*Point;}
 
   if (entryPrice<Bid) { oType=OP_SELLSTOP; typeName="SELLSTOP"; }
   if (entryPrice>Bid) { oType=OP_SELLLIMIT; typeName="SELLLIMIT"; }
 
   ticket=OrderSend(Symbol(),oType,Lots,entryPrice,3,Stopvalue,TPvalue,shortName + " " + Period(),magicNum,0,Green);
   if(ticket>0)
     {if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print(shortName + " " + typeName + " order at ",OrderOpenPrice()); }
   else 
     {Print("Error opening " + typeName + " order : ",GetLastError());}
}
 
//+------------------------------------------------------------------+
 
 
 
//+------------------------------------------------------------------+
Reason: