Volcanbleu:
I would like to know if somebody has a smart way to close partially a position
|
|
I am new on this forum and on MT4. I am programing an EA with MT4 for the forex market and I would like to know if somebody has a smart way to close partially a position otherway than closing all and open a smaller one.
Also,is there afunction in MT4 to get the current strategy profit of the EA runing ?
To perform a partial close - open new position in reverse direction with a smaller lot, then call OrderCloseBy. For example, if you have 1 lot in buy, you can open 0.4 lot in sell and then call OrderCloseBy passing tickets of thess two orders to it. As a result you'll get 0.6 lot in buy.
If your strategy is marked by specific magic number, you should traverse account history for this magic, and so you can accumulate the strategy profit from profits of all matching orders. I'm sure you can find ready-made functions in the code base.
To perform a partial close - open new position in reverse direction with a smaller lot, then call OrderCloseBy. For example, if you have 1 lot in buy, you can open 0.4 lot in sell and then call OrderCloseBy passing tickets of thess two orders to it. As a result you'll get 0.6 lot in buy.
If your strategy is marked by specific magic number, you should traverse account history for this magic, and so you can accumulate the strategy profit from profits of all matching orders. I'm sure you can find ready-made functions in the code base.
Why not simply OrderClose() with requested volume ?
Thank you very much Stanislas for your advice for closing the position. I will try that.
Hi Stanislas,
I tried your partial closing system and it seems to work fine... thanks again..
I tried your partial closing system and it seems to work fine... thanks again..
- 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 everybody,
I am new on this forum and on MT4. I am programing an EA with MT4 for the forex market and I would like to know if somebody has a smart way to close partially a position otherway than closing all and open a smaller one.
Also,is there afunction in MT4 to get the current strategy profit of the EA runing ?
Thanks for your help