I was wondering if anyone can help me with a small issue, I have an EA that closes basket of trades once a certain profit is reached. For example this past week there was a basket of 27 open buys/sells that took 7 seconds to close, in the mean time price had moved 2-3 pips and
it ended up as a losing basket. Is there any way that all the open trades can be closed all at one time ?? My programmer does not have a solution, but he did add some code to close the biggest lot size trades first, which helps somewhat but still does not solve the issue. Part of my requirement document clearly stated that "all baskets must be closed at a profit".
Do not close at market price. Use TP and SL insteadGet a VPS closer to the broker server so the latency will be reduced
The demo is already running on a VPS, and there is a basket TP, cant use pending orders if thats what you meant. There has to be a way to close all open trades at once, like as cript of something.
I agree; closing with SL or TP is much faster than closing each order sequentially
The TP and SL are pending orders effectively. Use them if you want faster trade closing results. Using a script is the same as closing with an EA. Another option is adding more pìps to the trigger price. If you are using MT5 there is an option for asynchronous Ordersend but this imposes a higher risk of leaving one or more trades opened because the EA does not wait for server confirmation.
If you are having such troubles with a demo account, using a live account will be worse.
My suggestion is: getting a VPS with latency under 20ms to the broker server and using TP/SL.
There doesn't "has to be a way" at all. You have to close one after one and that can take minutes during news.
Interesting. I dont know much about basket trading. Perhaps a solution is setting TP or SL of all orders at 1pip or STOPLEVEL when profit target is reached
1) They will not close that the same time, 2) the basket will close at a different profit level than OP wants.
An alternative, this comment about creating worker EAs to distribute the closing tasks: https://www.mql5.com/en/forum/345217#comment_17071083
Still no. Used to be only one trade context (146) was enlarged to 8 (Build 600) but OP has 27 open orders. That will quicken but still not make it "at once"
Thanks for the feedback guys, first of all its an MT4 and not an MT5 EA. When I say basket profit I mean on one pair, because I dont trade multiple pairs. A previous version of this same logic with another programmer, who BTW could not get the missing trade bug fixed and therefore failed. We had a parameter where you would set it to 1-2 pips, so when the Min Basket Profit was hit price would have to move an additional 1-2 pips more in the same direction of course, and every damn basket closed out in profit after that.
I was assuming that there was some sort of script or piece of code that could close all trades in a few MS, or all at once but you guys are telling me differently.