
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi,
I'm working on a netting account.
As far as I understand: by reversing an existing position the position will be closed and a new one will be opened with a new id and the contrarian type (buy --> sell or sell --> buy).
Am I correct here?
But I have difficulties to access to the newly opened position. How can I get the position id?
To demonstrate my problem I have written a small EA. Running this EA in the strategy tester allows me to open a new position, to increase it or to reverse it.
Additionally the EA print the correct position id. At least I hope. But it does not :-(
Please see the following EA
By pressing the Buy or the Sell button you can open and modify the (single) position:
If you press "Buy 2" you buy 2 lots and get the following output:
That is completely understandable for me: The position variable of the MqlTradeTransaction has the value 2 and the Position_Id of the deal as well.
But if I do a reverse operation now by pressing the button "Sell 3" in order to sell 3 lots I get the following output:
You see: the trans.position variable and the deal.position_id have the id of the old position which has been closed. These entries remain for all further operations.
Question: how can I access the newly opened position 3? Here you see position 3, indeed open:
Can you help me please?
Matthias