Applying various trading styles (hedging...) with MT5

 

In this topic, we have some discussion about which of MT4 or MT5 is better to apply various trading style. My opinion is : None - Both. You can apply similar trading styles but differently. What is highlighted by tonny, is that in MT5 you can't hedge and, as an example, challenges me to "open two equal sized trades of different direction in same pair on mt5".

So, I accepted the challenge. Obviously, if you open 2 equals sized trades on the same pair on MT5, both are immediately closed. But I guess, on real live, you don't simply open trades for pleasure to open. Therefore I take a more realistic situation :

Open 2 trades at some price, if price goes in one direction for 5 pips, close the other trade, remaining trade will have a target of 20 pips.

Here what this give with MT4 :

TicketOpen TimeTypeSizeItem PriceS / LT / PClose Time PriceCommissionTaxesSwapProfit
318960042013.04.10 23:16sell1.00eurusd1.307001.307501.305002013.04.11 03:391.305000.000.000.00200.00
318960192013.04.10 23:16buy1.00eurusd1.307101.306601.309102013.04.10 23:441.306600.000.000.00-50.00

Spread was 0.9 pips.

How can I try to do this with MT5 ?

I don't even open trades on same price in both direction. When the price reach 1.3070, I used pending orders to do same things as SL and TP do for MT4. So I open 4 pending orders:

Open Time Order Symbol Type Volume Price S / L T / P Time State
2013.04.10 20:10100285571EURUSDbuy stop1.00 / 1.001.30750

2013.04.11 09:00canceled
2013.04.10 20:12100285572EURUSDbuy limit1.00 / 1.001.30500

2013.04.11 03:39filled
2013.04.10 20:13100285573EURUSDsell limit1.00 / 0.001.30910

2013.04.11 02:04canceled
2013.04.10 20:28100285574EURUSDsell stop1.00 / 1.001.30660

2013.04.10 23:44filled

For the SL & TP of the sell order : 1 buy stop and 1 buy limit. For the SL & tp of the buy order : 1 sell stop and 1 sell limit. If the sell limit if reach I cancel the sell stop (or reverse). If the buy limit is reach I cancel the buy stop (or reverse).

These result in the following deals :

Time Deal Symbol Type Direction Volume Price Order Commission Swap Profit Balance
2013.04.10 23:44100063550EURUSDsellin1.001.306571002855740.000.000.00100 000.00
2013.04.11 03:39100063552EURUSDbuyout1.001.304951002855720.001.47162.00100 163.47

The result is a little different due to some difference in open/close price, but the trades are very similar.

 
angevoyageur:

In this topic, we have some discussion about which of MT4 or MT5 is better to apply various trading style. My opinion is : None - Both. You can apply similar trading styles but differently. What is highlighted by tonny, is that in MT5 you can't hedge and, as an example, challenges me to "open two equal sized trades of different direction in same pair on mt5".

So, I accepted the challenge. Obviously, if you open 2 equals sized trades on the same pair on MT5, both are immediately closed. But I guess, on real live, you don't simply open trades for pleasure to open. Therefore I take a more realistic situation :

Open 2 trades at some price, if price goes in one direction for 5 pips, close the other trade, remaining trade will have a target of 20 pips.

How can I try to do this with MT5 ?

I don't even open trades on same price in both direction. When the price reach 1.3070, I used pending orders to do same things as SL and TP do for MT4. So I open 4 pending orders.


Your thinking is on right track. This is almost the good solution, but one important step is missing. You MUST open the positions regardless whether they will offset each other or not. The reason is that in real life you cannot know when an EA will open position. Therefore can be situation when only one will open and close position before other opens as well, and in this case you need the position opened to achieve the hoped profit. Sometimes another EA will open another position which can be either same direction or opposite. If the opening is the same size but opposite then the total position will be zero, as you described. But it still does not mean that the story is over. So, the EA has to be able to record and track all necessary details of its active position, including open price, position size, SL order & price, etc. Basically the EA calculates everything based on internally stored values and does not use the information which can be obtained about the current position from the terminal.

As a consequence, of course, the P/L figures in the history tab are useless. However in Excel or another spreadsheet manager it is easy to calculate them manually by comparing the price of the position opening and the stop loss/take profit order.

I have finalised this system only few weeks ago, I call it virtual position management. Up to this date it looks like working fine. At the beginning, I believed it would be much more complicated than the normal procedure, but now I can say it is quite straightforward.

One twist in the coding can be if somebody would like to use asynchronous order sending when the order number should be got through the OnTradeTransaction event. At this stage I cannot see benefit of sending market order with this method, because you have to wait either using OrderSendAsync (then in OnTradeTransaction) or OrderSend for feedback from the broker server to get the order number (or possible other outcomes, reqoute, rejection, etc.). In case of pending orders it might be worth the additional effort to implement.
 
NyemaSanya:
Your thinking is on right track. This is almost the good solution, but one important feature is missing. You MUST open the positions regardless whether they will offset each other. The reason is that in real life you cannot know when an EA will open position. Therefore can be situation when only one will open and close position before other opens as well, and in this case you need the position opened to achieve the hoped profit. Sometimes another EA will open another position which can be either same direction or opposite. If the opening is the same size but opposite then the position will be zero, as you described. But it still does not mean that the story is over. So, the EA has to be able to record and track all necessary details of the active position, including open price, position size, SL order & price, etc. Basically the EA calculates everything based on internally stored values and does not use the information which can be obtained about the current position from the terminal.

As a consequence, of course, the P/L figures in the history tab are useless. However in Excel or another spreadsheet manager it is easy to calculate them manually by comparing the price of the position opening and the stop loss order.

I have finalised this system only few weeks ago, I call it virtual position management. Up to this date it looks like working fine. At the beginning, I believed it would be much more complicated than the normal procedure, but now I can say it is quite straightforward.

One twist in the coding can be if somebody would like to use asynchronous order sending when the order number should be got through the OnTradeTransaction event. At this stage I cannot see benefit of sending market order with this method, because you have to wait either using OrderSendAsync (then in OnTradeTransaction) or OrderSend for feedback from the broker server to get the order number (or possible other outcomes, reqoute, rejection, etc.). In case of pending orders it might be worth the additional effort to implement.
I did not speak about an EA but about manual trading. Obviously with an EA you can do what you want, more or less easily. By the way, thanks for your contribution.
 
angevoyageur:
I did not speak about an EA but about manual trading. Obviously with an EA you can do what you want, more or less easily. By the way, thanks for your contribution.
There is no obstacle to follow the same logic in manual trading. You can record on paper all details as the EA would do. It is a bit clumsy, but possible :-)
 
you can use this too to get in both way.
 
Ok can you now do the same without using pending orders or other inconvenient ways? Lets assume you want to manage 100 trades of the same pair made up of different stops and direction will you sit with pen and paper to manage calculate all that then open all those pending orders? Bs
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 
tonny:
Ok can you now do the same without using pending orders or other inconvenient ways? Lets assume you want to manage 100 trades of the same pair made up of different stops and direction will you sit with pen and paper to manage calculate all that then open all those pending orders? Bs

What are you tying to show ? Obviously MT4 and MT5 are very different in order management. Obviously it's easy to open a lot of order with different stops in MT4. Obviously you have to use pending orders in MT5 for manual trading of different orders. And what ? If you don't like that use MT4, no problem with that. Please don't continue to argue about that.

If you have some positive comment on how to work with MT5 (or even MT4), go on, otherwise I already warned you I'm not going to tolerate your spamming posts. This forum is already filled with your posts about "MT5 do not permit hedging ...". This is my last warning.



 
Sometimes one might want to run many different EAs or strategies on one account and want to monitor everything in one place. And for your info you are the one who restarted this topic and put my name up there so that people know its me you are targeting.
 
tonny:
Sometimes one might want to run many different EAs or strategies on one account and want to monitor everything in one place. And for your info you are the one who restarted this topic and put my name up there so that people know its me you are targeting.
I don't target anyone. Do you have something constructive to say ? It would be a big change.
 

a little off topic

able to close individual deal instead of the whole position?

 
doshur:

a little off topic

able to close individual deal instead of the whole position?

Take an opposite deal with same volume.