Hi,
My EA uses grid trading. The problem I'm trying to solve is when AE sets TPs it is no more in control in which order those orders are being closed by a broker.
I'm pretty sure there's a way to force those orders to close in a reverse order to one in which they were opened (seen such EA in Strategy Tester).
Btw, I've already tried to OrderModify orders in the desired order (while setting TP) but no luck.
Could anyone help?Your question just raises much more questions in my mind (why do you set TPs, if the positions shouldn't be closed when reaching the TP, but in a certain order?, And what has the OrderModify to do with the order of your deals?)
Anyhow: If you really want to treat them in an certain order, then save the received tickets in a list or array, so you can handle them later on in the order you want.
Your question just raises much more questions in my mind (why do you set TPs, if the positions shouldn't be closed when reaching the TP, but in a certain order?, And what has the OrderModify to do with the order of your deals?)
Anyhow: If you really want to treat them in an certain order, then save the received tickets in a list or array, so you can handle them later on in the order you want.
Thanks for your reply.
It doesn't really matter TP or SL (it uses SL as well when trailing). The desired EA operation is as follows:
- open order 1
- open order 2
- at some point in time set their TPs (or SLs, it depends)
- trading server will close both orders when price reaches TP value
- I need to somehow force the trading server to close "order 2" before "order 1".
I've seen such a behaviour from an EA (not mine, have no source code).
Maybe someone knows how to accomplish the task?
Thanks for your reply.
It doesn't really matter TP or SL (it uses SL as well when trailing). The desired EA operation is as follows:
- open order 1
- open order 2
- at some point in time set their TPs (or SLs, it depends)
- trading server will close both orders when price reaches TP value
- I need to somehow force the trading server to close "order 2" before "order 1".
I've seen such a behaviour from an EA (not mine, have no source code).
Maybe someone knows how to accomplish the task?
I can't imagine that an EA could do that - If you set SL or TP, it is a deal with the (CFD/Forex) broker, that he sells/buys the given value when the price reaches your limit (SL/TP) - On a e.g. stock-exchange it's even more complicated, because there you need also a counterpart that buys your sell (or vice versa).
So how how should a Client-EA have influence to the broker's deals?
The only thing i could imagine is to TRY it via setting the SL/TP - values different, so that the price will reach the SL/TP of the 2nd deal earlier that than the one of the 1st order. But that's also not guaranteed (just think of high volumes after e.g. the NFPs).
-
Go through the open order list in reverse order and close them. What's the problem?
-
Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
No free help (2017)Or pay someone. Top of every page is the link Freelance.
Hiring to write script - General - MQL5 programming forum (2018)We're not going to code it for you (although it could happen if you are lucky or the problem is interesting).
No free help (2017)
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
My EA uses grid trading. The problem I'm trying to solve is when AE sets TPs it is no more in control in which order those orders are being closed by a broker.
I'm pretty sure there's a way to force those orders to close in a reverse order to one in which they were opened (seen such EA in Strategy Tester).
Btw, I've already tried to OrderModify orders in the desired order (while setting TP) but no luck.
Could anyone help?