OrderOpen and OrderClose. Please help

 

So there is a problem. I open an order, and while order close parameters do not trigger, EA does not open another order. If i put orderclose lines in the same text as orderopen, i get  all orders closed at the same date when back test ends. If i put more than 0 in calculate current orders function, then if there are only one order opened EA waits while another opens and then closes them together at  the same point. How to avoid that and get proper orderclose function whenever it triggers and in the same time orderopen function works and looks for possible entry?

  

int start()
  {
//----
 
  
     
  if(CalculateCurrentOrders(Symbol())==0)
      CheckForOpen();   // start working
  
    
   else
     CheckForClose();  // otherwise, close positions
  
 }

Thank you 

 

This is not enough code to understand your problem!

But I suggest you to use the example EA in your expert folder for: 1) when to open 2) when to close and 3) how to close your positions: Moving Average.mq4  and  MACD Sample.mq4.

 

What extra code is necessary?

If there are no open positions, function goes to CheckForOpen, where it is looking for Overbought/Oversold RSI. If criterias matches, position is opened.

On next bar as the position is opened  and CalculateCurrentOrders>0 function goes to Checkfor Close if it matches closing criterias.  So the problem is how  to have multiple opened positions( which are closed each separately if criteria of closing for them matches) and not  only 1 at the time 

 
To identify different orders with different strategies you can use either the ticket number from the broker or your own magic number.
 
ok clear, need to do with ticket number something, magic is not working as it is given for an particular pair of EA, and i have few EAs running on the same platform
 
Magic will work if you do checks properly. I have many ea running on the same terminal and have no problem in opening / closing specific pair.
Reason: