Download MetaTrader 5

OrderOpen and OrderClose. Please help

To add comments, please log in or register
One billion tasks have already been executed with MQL5 Cloud Network. Test trading robots even faster!
orangutangas1 2014.10.24 14:24 

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()
      CheckForOpen();   // start working
     CheckForClose();  // otherwise, close positions

Thank you 

Carl Schreiber
Carl Schreiber 2014.10.24 15:11  

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.

orangutangas1 2014.10.24 17:03  

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 

Carl Schreiber
Carl Schreiber 2014.10.24 17:08  
To identify different orders with different strategies you can use either the ticket number from the broker or your own magic number.
orangutangas1 2014.10.24 17:11  
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
SYED NAUFAL GADDAFI 2014.10.25 01:48  
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.
To add comments, please log in or register