Hi there,
I understand that things work a little different in MT5...
Here is my understanding: An order results in a deal. A deal effects the net position. StopLoss (SL) and TakeProfit (TP) are on position level.
What I need is that, as in MT4, I can set SL and TP based on deal level. Having an open position, when I add to the position, I need the two separte "operations" to be managed individually.
I can do this by opening Stop and Limit orders, which reflect the individual SL and TP and delete the second pending order once the first one has been filled. I have created a small library for myself, which does exactly that (which I am willing to share).
I am just wondering, whether this is not an issue that everyone of us has. I would assume that this is an already solved issue. However searching articles and code base, I did not find much.
What I did find are the following two related promiding articles, which provide a framework for individual trade management incl. hedging:
However, considering the limited number of comments and the date of the articles it feels as if this is not the common way how to deal with this challenge.
So my question to you is:
If you write an EA which is supposed to handle SL and TP individually per order/deal, how do you go about it?
Do you use an existing framework and if you do, which one?
Thanks,
Matt
the two-step operation isn't a strict requirement. (my assumption was as your after reading that old-dated articles :| )
so send your orders in one or two steps (as your brokers permits so).
My eplaination must have been incomplete. Therefore, I retry by using following scenario.
Scenario:
Trade 1:
Trade 2:
As with MT5 (with netting) SL and TP are on the position, I can only have one SL and one TP, which goes for the entire position. Therefore, the requirement decribed is not easily fulfilled in MT5.
Current Solution:
- for the first trade: 1 market order at 1.15500, a SellLimit at 1.16000 as TP and a SellStop at 1.15000 as SL.
- for the second trade: 1 market order at 1.15700, a SellLimit at 1.16200 as TP and a SellStop at 1.15200 as SL.
- for the first trade: Once either the SellLimit at 1.16000 or the SellStop at 1.15000 is hit, I delete the other one. (same goes for the second trade with its respective levels)
My eplaination must have been incomplete. Therefore, I retry by using following scenario.
Scenario:
Trade 1:
Trade 2:
As with MT5 (with netting) SL and TP are on the position, I can only have one SL and one TP, which goes for the entire position. Therefore, the requirement decribed is not easily fulfilled in MT5.
Current Solution:
- for the first trade: 1 market order at 1.15500, a SellLimit at 1.16000 as TP and a SellStop at 1.15000 as SL.
- for the second trade: 1 market order at 1.15700, a SellLimit at 1.16200 as TP and a SellStop at 1.15200 as SL.
- for the first trade: Once either the SellLimit at 1.16000 or the SellStop at 1.15000 is hit, I delete the other one. (same goes for the second trade with its respective levels)
I know exactly what you are asking for and to the best of my knowledge there is no open-source framework for linking stop-orders, limit-orders, and resulting positions to individual deals. Just off the top of my head... you could try opening the pending orders using the deal ticket number as the pending order magic number in order to create a link that would persist across terminals.
My eplaination must have been incomplete. Therefore, I retry by using following scenario.
Scenario:
Trade 1:
Trade 2:
As with MT5 (with netting) SL and TP are on the position, I can only have one SL and one TP, which goes for the entire position. Therefore, the requirement decribed is not easily fulfilled in MT5.
Current Solution:
- for the first trade: 1 market order at 1.15500, a SellLimit at 1.16000 as TP and a SellStop at 1.15000 as SL.
- for the second trade: 1 market order at 1.15700, a SellLimit at 1.16200 as TP and a SellStop at 1.15200 as SL.
- for the first trade: Once either the SellLimit at 1.16000 or the SellStop at 1.15000 is hit, I delete the other one. (same goes for the second trade with its respective levels)
An hedging account is really a must for what you want. Did you talk to FxPro ? I have heard you can have an hedging account if you request one, you should ask to their support.
Otherwise there is an old library to manage "virtual" trade on a netting account.
- 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 there,
I understand that things work a little different in MT5...
Here is my understanding: An order results in a deal. A deal effects the net position. StopLoss (SL) and TakeProfit (TP) are on position level.
What I need is that, as in MT4, I can set SL and TP based on deal level. Having an open position, when I add to the position, I need the two separte "operations" to be managed individually.
I can do this by opening Stop and Limit orders, which reflect the individual SL and TP and delete the second pending order once the first one has been filled. I have created a small library for myself, which does exactly that (which I am willing to share).
I am just wondering, whether this is not an issue that everyone of us has. I would assume that this is an already solved issue. However searching articles and code base, I did not find much.
What I did find are the following two related promiding articles, which provide a framework for individual trade management incl. hedging:
However, considering the limited number of comments and the date of the articles it feels as if this is not the common way how to deal with this challenge.
So my question to you is:
If you write an EA which is supposed to handle SL and TP individually per order/deal, how do you go about it?
Do you use an existing framework and if you do, which one?
Thanks,
Matt