Hello guys,
I have an expert advisor running in the market from an hedge account of Icmarkets. I am struggling with a situation which I can not solve, despite the research I have already made online:
During an open position, at some point I move my stop loss to break-even and try to partially close a certain amount of volume, using PositionClosePartial operation. Well, sometimes it works properly but in most of the cases, it closes the entire position... It makes no sense. At least, either it should always work or not at all.
Moreover, the weirdest thing is when I backtest all theses trades in the strategy tester, all of the trades are correctly closed partially, as written in the EA.
Here is my code:
Note: Usually the position volume is 0.03 or 0.04 and the SYMBOL_VOLUME_MIN = 0.01.
Many thanks in advance :)
ulong PositionTicket = PositionGetTicket(i);
This line should be the first in your loop, because all the PositionGetInteger(), PositionGetDouble() dpend on it. Your magic number could be wrong as you set before selecting the position.
Where is your position symbol selected ? Unless you only have position on _Symbol (current chart) this will lead to problems as you are using SymbolInfoDouble() inside your loop.
Where is your error checking code ?
Please post the log files (not a screenshot), from Experts and Journal when the problem happened.
This line should be the first in your loop, because all the PositionGetInteger(), PositionGetDouble() dpend on it. Your magic number could be wrong as you set before selecting the position.
Where is your position symbol selected ? Unless you only have position on _Symbol (current chart) this will lead to problems as you are using SymbolInfoDouble() inside your loop.
Where is your error checking code ?
Please post the log files (not a screenshot), from Experts and Journal when the problem happened.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello guys,
I have an expert advisor running in the market from an hedge account of Icmarkets. I am struggling with a situation which I can not solve, despite the research I have already made online:
During an open position, at some point I move my stop loss to break-even and try to partially close a certain amount of volume, using PositionClosePartial operation. Well, sometimes it works properly but in most of the cases, it closes the entire position... It makes no sense. At least, either it should always work or not at all.
Moreover, the weirdest thing is when I backtest all theses trades in the strategy tester, all of the trades are correctly closed partially, as written in the EA.
Here is my code:
Note: Usually the position volume is 0.03 or 0.04 and the SYMBOL_VOLUME_MIN = 0.01.
Many thanks in advance :)