I need help with adding maximum trades per day to this EA ALONG WITH TRAILING STOP

 
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+

#property copyright "Copyright 2023, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#include <Trade\Trade.mqh>
CTrade trade;

static input long inpMagicnumber =54321;
input int inpBars=20; //bars for high/low
static input double inpLots=0.01;
input int inpStopLoss=200;
input int inpTakeProfit=0;


///GLOBAL VARIBLES
double high=0;
double low=0;
MqlTick currentTick, previousTick;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {

//set magicnumber
trade.SetExpertMagicNumber(inpMagicnumber);

   return(INIT_SUCCEEDED);
  }


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+11                                                                                                                                                                                                                                    11 11111111111111111111111111111111111111111111111111
void OnTick()
  {
  //Get tick
  previousTick=currentTick;
  if(!SymbolInfoTick(_Symbol,currentTick)){Print("fail to get currenttick");return;}
  
  ///count open positions
  int cntBuy, cntSell;
  if(!CountOpenPositions(cntBuy,cntSell)){return;}
  
  //check for buy position
  if(cntBuy==0 && high!=0 && previousTick.ask<high && currentTick.ask>=high){
  
  
  
  // calculte stoploss /take profit
  double sl=inpStopLoss==0?0:currentTick.bid-inpStopLoss*_Point;
  double tp=inpTakeProfit==0?0:currentTick.bid+inpTakeProfit*_Point;
  if(!NormalizePrice(sl)){return;}
  if(!NormalizePrice(tp)){return;}
  
  trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,inpLots,currentTick.ask,sl,tp,"highbreakout");
  
  }
  
  
  
  
  
  
  
//CALCULATE HIGH AND LOW
   high =iHigh(_Symbol,PERIOD_CURRENT,iHighest(_Symbol,PERIOD_CURRENT,MODE_HIGH,inpBars,0));
   low =iLow(_Symbol,PERIOD_CURRENT,iLowest(_Symbol,PERIOD_CURRENT,MODE_LOW,inpBars,0));
   DrawObjects();
}
void DrawObjects(){
 

datetime time =iTime(_Symbol,PERIOD_CURRENT,inpBars);

//RESISTANCE/HIGH LEVELS
ObjectDelete(NULL,"high");
ObjectCreate(NULL,"high",OBJ_TREND,0,time,high,TimeCurrent(),high);
ObjectSetInteger(NULL,"high",OBJPROP_WIDTH,2);
ObjectSetInteger(NULL,"high",OBJPROP_COLOR,clrBlack);

//SUPPORTS/LOW LEVELS
ObjectDelete(NULL,"low");
ObjectCreate(NULL,"low",OBJ_TREND,0,time,low,TimeCurrent(),low);
ObjectSetInteger(NULL,"low",OBJPROP_WIDTH,2);
ObjectSetInteger(NULL,"low",OBJPROP_COLOR,clrRed);

}

 bool CountOpenPositions(int &cntBuy,int &cntSell){
  
  cntBuy=0;
  cntSell=0;
  int total= PositionsTotal();
  for (int i=total-1; i>=0; i--){
  ulong ticket = PositionGetTicket(1);
  if(ticket<=0){Print("failed to get position ticket");return false;}
  if(!PositionSelectByTicket(ticket)){Print("failed to select position");return false;}
  long magic;
  if(!PositionGetInteger(POSITION_MAGIC,magic)){Print("failed to get position magicnumber");return false;}
  if(magic==inpMagicnumber){
  long type;
  if(!PositionGetInteger(POSITION_TYPE,type)){Print("failed to get position type");return false;}
  if(type==POSITION_TYPE_BUY){cntBuy++;}
  if(type==POSITION_TYPE_SELL){cntSell++;}
  }
  }
  return true;
  }
  
//Normalize price
bool NormalizePrice(double &price){
double tickSize=0;
if(!SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_SIZE,tickSize)){
Print("failed to get tick size");
}
return true;


price= NormalizeDouble(MathRound(price/tickSize)*tickSize,_Digits);
return true;

}