Trades open once

 

I want to hedge my trades multiple times instead of once. For example If price opens at buy 1.12345 & sell at 1.12295, how do I hedge my trades at that price multiple times? 

int MagicNumber=87897;
int BuyTrade=0;
int SellTrade=0;
int Direction=2;
int Hedge=0;
double Filter=0;
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
int CountTrades()
 {
  int Count=0;
  for(int a=OrdersTotal()-1;a>=0;a--)
   {
    if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
    if(OrderType()==OP_BUY||OrderType()==OP_SELL)
    Count++;
   }
  return(Count);
 } 
 
double Pips()
 {
  double PipPoint=0;
  double Digit=MarketInfo(Symbol(),MODE_DIGITS);
  if(Digit==1||Digit==3||Digit==5){PipPoint=Point*10;}
  return(PipPoint);
 }
 
void Buy()
 {
   if(Ask-OrderOpenPrice()>5*Pips())
   {
    BuyTrade=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"2023",MagicNumber,0,clrBlue);
   }
 
   else if(OrderOpenPrice()-Bid>5*Pips())
   {
    int BuyHedge2=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,0,0,"2023",MagicNumber,0,clrRed);
   }

 }

void Sell()
 {
   if(OrderOpenPrice()-Bid>5*Pips())
   {
    SellTrade=OrderSend(Symbol(),OP_SELL,0.01,Bid,0,0,0,"2023",MagicNumber,0,clrRed);
   }
   
   else if(Ask-OrderOpenPrice()>5*Pips())
   {
    int SellHedge2=OrderSend(Symbol(),OP_BUY,0.01,Ask,0,0,0,"2023",MagicNumber,0,clrBlue);
   }
   
 }   

void OnTick()
 {
  if(CountTrades()<2){Buy();}

  
  if(CountTrades()<2){Sell();}
}

 


 

 

sorted!!!!!

int CountTrades2()
 {
  int Count=0;
  bool BuyNow=true;
  bool SellNow=true;
  
  for(int b=OrdersTotal()-1;b>=0;b--)
  {
   if(OrderSelect(b,SELECT_BY_POS,MODE_TRADES))
   if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
   {
    if(OrderType()==OP_BUY)BuyNow=true;
    else if(OrderType()==OP_SELL)SellNow=true;
   }

  }
  return(Count);
 } 
int HedgeNow()
 {
  int Now=0;

  for(int o=0;o<OrdersTotal();o++)
   {
    if(OrderSelect(o,SELECT_BY_POS,MODE_TRADES))
    if(OrderSymbol()==Symbol()&&OrderMagicNumber()==MagicNumber)
    {
     if(OrderType()==OP_BUY)BuyNow=0;
     else if(OrderType()==OP_SELL)BuyNow=0;
    }
   } 
  
  return(Now);
 } 
if(!HedgeNow()&&Ask-OrderOpenPrice()>5*Pips())
  {
   //Buy
  }