Multiple trades Trailing

 
I use the code below to find breakeven of all the trades I have a point I close all of them at 0, my question is how can I trail?
string eq;
      string Sym[];
      double Equity[];
      double Lots[];
      double sum             = 0;
      string level0          = "";
      ArrayResize(Sym,0);
      ArrayResize(Equity,0);
      ArrayResize(Lots,0);
     
      for(int i = 0; i < OrdersTotal(); i++)
         {
              if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))continue;
              if(OrderMagicNumber() != Magic)continue;
              if(OrderType() != OP_BUY && OrderType() != OP_SELL) continue;
              
              bool found   = false;
              int size     = ArraySize(Sym);
              int pind     = 0;
              
              for(int k = 0; k < size; k++)
                 {
                   if(Sym[k] == OrderSymbol()) 
                      {
                           Equity[k] += OrderProfit() + OrderCommission() + OrderSwap();
                           if(OrderType() == OP_BUY) Lots[k] += OrderLots();
                           if(OrderType() == OP_SELL) Lots[k] -= OrderLots();
                           found = true;
                           pind  = k;
                           break;
                      }
                 }
             
              if (found) continue;
             
              int ind = ArraySize(Sym);
              ArrayResize(Sym, ind + 1);
              Sym[ind] = OrderSymbol();
              
              ArrayResize(Equity, ind + 1);
              Equity[ind] = OrderProfit() + OrderCommission() + OrderSwap();
              
              ArrayResize(Lots, ind + 1);
              if(OrderType() == OP_BUY)Lots[pind]  = OrderLots();
              if(OrderType() == OP_SELL)Lots[pind] = -OrderLots();
         }
      
      for(int i = 0; i < ArraySize(Sym); i++)
         {
           if(Lots[i] == 0)level0 = "Lock";
           else 
              {
                int    dig   = (int) MarketInfo(Sym[i],MODE_DIGITS);
                double point = MarketInfo(Sym[i],MODE_POINT);
                
                double COP   = Lots[i] * MarketInfo(Sym[i],MODE_TICKVALUE);
                double val   = MarketInfo(Sym[i],MODE_BID) - point * Equity[i] / COP;
                level0       = DoubleToStr(val, dig);
              }
           sum += Equity[i];
         }
 
After selecting the trade, just after this, you can check if the conditions are met to trail.
if(OrderType() != OP_BUY && OrderType() != OP_SELL) continue;
This is mql4, it should be in mql4 section below.
 
Thank-god Avwerosuoghene Odukudu #:
After selecting the trade, just after this, you can check if the conditions are met to trail. This is mql4, it should be in mql4 section below.

Okay, thanks for the reply. the code finds the break-even price if I can find the price level where all trades can be x  amount example the price level where all trades are $5