Discussion of article "MQL5 Cookbook: Getting properties of an open hedge position"

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
209861
MetaQuotes Software Corp.  

New article MQL5 Cookbook: Getting properties of an open hedge position has been published:

MetaTrader 5 is a multi-asset platform. Moreover, it supports different position management systems. Such opportunities provide significantly expanded options for the implementation and formalization of trading ideas. In this article, we discuss methods of handling and accounting of position properties in the hedging mode. The article features a derived class, as well as examples showing how to get and process the properties of a hedge position.

One of the recently added MetaTrader 5 terminal features is the possibility to open bi-directional orders. This order accounting system is called hedging. Support for this order system enables an easy transfer of trading algorithms from MetaTrader 4 to the fifth platform version, while taking the advantage of the advanced MetaTrader 5 functionality. For more details about the hedging options in MetaTrader 5, please read the article "MetaTrader 5 features hedging position accounting system".

In this article, we will discuss the properties of the aggregate position, which is the object of the hedging system.

Hedge position properties panel

Fig.4 Hedge position properties panel

Author: Denis Kirichenko

dingo34
42
dingo34  

Hi,

When I downloaded the zip file and extracted it and opened them up in the editor, when I then compiled them they came back with heaps of errors.


Is there anything I can use?


Cheers

Denis Kirichenko
12637
Denis Kirichenko  

If you follow my way there will be no errors. The way is simple. Open you MetaEditor and:

1) create a subfolder "Hedge" in the folder "Shared Projects";

2) place the source files into the subfolder.


ME Navigator

Then you may compile HedgePropertiesEA.mq5 (an expert advisor) and  Test_hedge_properties.mq5 (a script). Once the compilation successfully finishes you will find the executables in the terminal navigator.


MT5 Navigator

francisalmeida
128
francisalmeida  

Hi Denis,

I would like to start by thanking you for this amazing library, it makes life very easy for novice users like myself. I am not a professional programmer, but just about manage to understand, tweak and debug some code a bit. 

I am using your sample code from "Test_Hedge_Properties" as a function in an EA that I am testing, and found that after closing all (2) positions, when I call the function

"Update_Hedge_Info", after 1st ticket is closed, the variable that counts the number of positions, "hdg_number_of_pos_total" updates from (2) to (1).

However, after the second ticket closes, the variable still shows (1), it does not update to (0).

I am not sure if I have coded it right, but your kind input and expertise will be greatly appreciated.

I am attaching the EA and screenshot. 

Thank you and regards.

To add comments, please log in or register