How to check if there is any current trades on bar[0]?

 

Hi, I'm currently facing a problem editing my EA. I managed to get the EA to open a new trade every single candle, using:

int start() 

     { 

     CurrTime= Time[0];
     if(CurrTime!= PrevTime) // Time has changed
      {
      OpenOrder();
      PrevTime = CurrTime; // Time reset.
      }
      
      return(0);         
     
   }
But now I'm unsure of how to write a code that reopens the trade that has previously TP-ed. Basically I'm looking for the EA to check if it's a new bar, if it is then OpenOrder, but if it's not then check if there is any Open Trades, If there is no open trade, OpenOrder again. So that I'm always buying/selling once previous trade criteria TP/SL. 

 
You can get the count from an OrderSelect loop.
Reason: