adinchi:
...
- Please edit your post and use SRC button when you post code.
- You probably have to read how Orders, deals and positions work with MT5.
- There is only one position, resulting of your 2 orders, with the SL/TP from the second order. So when SL or TP is hit, all your position is closed.
- Please edit your post and use SRC button when you post code.
- You probably have to read how Orders, deals and positions work with MT5.
- There is only one position, resulting of your 2 orders, with the SL/TP from the second order. So when SL or TP is hit, all your position is closed.
Hi angevoyageur,
I have red your link. this obvious is the case - it is only one position in the end with TP from the second order. that is why I decided to use different Magic number for these two orders - I thought this is one of the convenience of magic number. But it do not works. Any advice, how to resolve this issue?
best regards!
Hi angevoyageur,
I have red your link. this obvious is the case - it is only one position in the end with TP from the second order. that is why I decided to use different Magic number for these two orders - I thought this is one of the convenience of magic number. But it do not works. Any advice, how to resolve this issue?
best regards!
You don't have to use SL/TP, as this close all your position. You have 2 choices (at least) :
- Use pending orders to simulate your SL/TP for both trades, So for your 2 trades, you have to enter 4 pending orders. The advantage is that it's manage at server side, the disadvantage is that you have to cancel 1 pending order when the other is hit (for example SL pending order if TP pending order is hit).
- Manage your trades internally with the EA. Advantage is that you can do all you want but with inconvenient of more complexity. Disadvantage is less security if you loss your connection to server.
Magic Number can be used to identify the deals/orders/positions of your EA, but it's not intended to manage trades.
P.S: I edited your first post. Another time use the SRC button when you post code.

- 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 colleagues
I got confused with the purpose of magic number when make order.
I wanted to open two orders at certain time - one of them with little (close to market) take profit and the other with much larger.
here is sammple code:
In the tester these orders are executed at the same time. here is a copy from the Journal:
2008.05.29 00:00:00 sell limit 20.00 SPX500 at 1390.5 sl: 1405.5 tp: 1375.5 (1390.5 / 1390.7 / 1390.5)
2008.05.29 00:00:00 sell limit 20.00 SPX500 at 1390.5 sl: 1405.5 tp: 890.5 (1390.5 / 1390.7 / 1390.5)
and also:
2008.05.29 00:00:40 order [#2 sell limit 20.00 SPX500 at 1390.5] triggered
2008.05.29 00:00:40 deal #2 sell 20.00 SPX500 at 1390.5 done (based on order #2)
2008.05.29 00:00:40 deal performed [#2 sell 20.00 SPX500 at 1390.5]
and the same message for the other order....
and here comes the PROBLEM:
soon after, the mentioned 15 point take profit level of one of the orders is hit. But instead of closing only half of the position what happens is that both position are closed at the mentioned 15 point take profit level, even that half of it was programmed for 500 point take profit.
here is Journal:
2008.06.03 00:00:40 deal performed [#4 buy 40.00 SPX500 at 1375.5]
2008.06.03 00:00:40 deal #4 buy 40.00 SPX500 at 1375.5 done (based on order #4)
2008.06.03 00:00:40 take profit triggered sell 40.00 SPX500 1390.5 sl: 1405.5 tp: 1375.5 [#4 buy 40.00 SPX500 at 1375.5]
why two orders , with different magic's are closed altogether at the take profit level of one of them?
could anybody help with this issue? what I do wrong?
thank's !
sincerely yours