How does one create an "if closed" statement?

 

I want to insert new instructions in my EA. I want to tell it at a certain point that if a close happened, then it shd carry out following instructions. Below is how I want to do it but I do not know if it is correct.

if ( CLOSELONG(Symbol()) )

{

//instructions here...

//instructions here...

}

Please say if this is correct

 
Not knowing what the function CLOSELONG() does, as long as it is a boolean function, then it should work as expected.
 
dafiriscott:

I want to insert new instructions in my EA. I want to tell it at a certain point that if a close happened, then it shd carry out following instructions. Below is how I want to do it but I do not know if it is correct.

if ( CLOSELONG(Symbol()) )

You not really asking if it's correct, you're asking how to code CLOSELONG. Something like:
bool CloseLong(string s=""){
   static int nOpen;
   int nPrev = nOpen; nOpen = MyOrdersTotal(OP_BUY);
   return(nOpen < nPrev);
}
int      MyOrdersTotal(int op=EMPTY, int ePool=MODE_TRADES){
   if(ePool == MODE_TRADES)     int    iPos = OrdersTotal()        - 1;
   else                                iPos = OrdersHistoryTotal() - 1;
   for(int nOrders=0; iPos >= 0; iPos--) if(
      MySelect(iPos, SELECT_BY_POS, ePool)) if(
      op == EMPTY || op == OrderType()
   )  nOrders++;
   return(nOrders);
}
// int      magic_number_min, magic_number_max; // Import from OnInit
bool     MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES, string s=""){
   if(s=="")   s=Symbol();
   if(!OrderSelect(iWhat, eSelect, ePool) )  return (false);
   int mn = OrderMagicNumber();
   if(mn < magic_number_min   )  return (false);
   if(mn > magic_number_max   )  return (false);
   if(OrderSymbol() != s      )  return (false);
   if(ePool != MODE_HISTORY   )  return (true);
   return(OrderType() <= OP_SELL);  // Never select canceled orders.
   #define  OP_BALANCE  6           // https://www.mql5.com/en/forum/124726
   #define  OP_CREDIT   7           // https://www.mql5.com/en/forum/126192
}