PositionClosePartial returns false but has retCode 10009

 

I want to use PositionClosePartial to cut my position in half when it gets to a scalp profit.

But the  PositionClosePartial call always returns false. It does not change the volume.

When I check the retCode it is 10009 which I believe means success. Something is not right.

I added a few debug statements to trade.mqh to see where it is returning "false"; It is the IsHedging check right at the start of the function. I don't know what that is.

The EA is not stopped. I don't know why it is doing this.

Has anyone seen this before?

I can post a small generic EA that shows it doing this. It would be interesting to know if it has the error for anyone else or is just me.

Documentation on MQL5: Python Integration / order_calc_margin
Documentation on MQL5: Python Integration / order_calc_margin
  • www.mql5.com
order_calc_margin - Python Integration - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

Seems you have a netting account ?

For some unknown reason this function only works with an hedging account. For a netting account just Buy or Sell the requested volume to close in opposite direction of your position.

 

I must have replied the wrong way as I do not see my comment...

Thanks so much for your response and advice. I never heard of this kind of hedging and netting before. I have not tried any Forex before.

But then I found out that AMP Futures does not allow US residents to trade Forex. SO I was trying to get my EA to work with Futures.

This may be why they have my account as netting.

I will certainly try your suggestion, thanks

Reason: