Close all trades at once

To add comments, please log in or register
George
245
George  

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". 

Fernando Morales
3804
Fernando Morales  
George:

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 instead
Get a VPS closer to the broker server so the latency will be reduced

George
245
George  
Fernando Morales:

Do not close at market price. Use TP and SL instead
Get 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.

Jean Francois Le Bas
1247
Jean Francois Le Bas  
Fernando Morales:

Do not close at market price. Use TP and SL instead
Get a VPS closer to the broker server so the latency will be reduced

I agree; closing with SL or TP is much faster than closing each order sequentially

Fernando Morales
3804
Fernando Morales  
George:

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.

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.

William Roeder
22447
William Roeder  
  1. George: There has to be a way to close all open trades at once,

    There doesn't "has to be a way" at all. You have to close one after one and that can take minutes during news.

  2. George: my requirement document clearly stated that "all baskets must be closed at a profit". 
    Irrevalent; the world doesn't revolve around you.

  3. People, OP is trading a basket of different pairs. There is no SL/TP for a basket; only for individual orders.
Fernando Morales
3804
Fernando Morales  
William Roeder:
  1. There doesn't "has to be a way" at all. You have to close one after one and that can take minutes during news.

  2. Irrevalent; the world doesn't revolve around you.

  3. People, OP is trading a basket of different pairs. There is no SL/TP for a basket; only for individual orders.

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

William Roeder
22447
William Roeder  
Fernando Morales: 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.

Fernando Morales
3804
Fernando Morales  
William Roeder:

1) They will not close that the same time, 2) the basket will close at a different profit level than OP wants.

Make sense.

An alternative, this comment about creating worker EAs to distribute the closing tasks: https://www.mql5.com/en/forum/345217#comment_17071083 

How to Send Orders Asynchronously With MQL4?
How to Send Orders Asynchronously With MQL4?
  • 2020.06.25
  • www.mql5.com
There is no way to get to the point...
William Roeder
22447
William Roeder  
Fernando Morales: 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"

George
245
George  

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. 

To add comments, please log in or register