Download MetaTrader 5

Closing Multiple orders in an EA

To add comments, please log in or register
Millions of traders download codes from MQL5 library. Share your app with them!
zecomengineer
122
zecomengineer 2014.01.28 12:35 
Please, my coding experience is limited. How do I close 5 or more open orders in an EA once they are all in profit? Is it possible for me to call a script from an EA? If yes, how? thank you.
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.01.28 12:54  
zecomengineer:
Please, my coding experience is limited. How do I close 5 or more open orders in an EA once they are all in profit? Is it possible for me to call a script from an EA? If yes, how? thank you.
Just get the EA to close them one by one.
whroeder1
14519
whroeder1 2014.01.28 13:23  
zecomengineer
122
zecomengineer 2014.01.28 13:53  
RaptorUK:
Just get the EA to close them one by one.



Yes, thank you, I thought of that; except, that the trades will be opened incrementally, that is, the first trade will be opened, when it is comfortably in profit, second trade will be opened and so on until we have five trades opened. Once the fifth trade is in profit, then all five trades are to be closed! Can any one help me with the codes to close the trades only when the fifth trade is in profit?
Simon Gniadkowski
Moderator
18001
Simon Gniadkowski 2014.01.28 13:55  
zecomengineer:


Yes, thank you, I thought of that; except, that the trades will be opened incrementally, that is, the first trade will be opened, when it is comfortably in profit, second trade will be opened and so on until we have five trades opened. Once the fifth trade is in profit, then all five trades are to be closed! Can any one help me with the codes to close the trades only when the fifth trade is in profit?
Loop through them one by one, when they all have OrderProfit() > 0 close them . . .
zecomengineer
122
zecomengineer 2014.01.28 14:10  
Okay, RaptorUK, I will do that and get back with the result. Thank you all
To add comments, please log in or register