How to make sure the PositionClosePartial() method is executed correctly?

 

Hi guys

My question is which return code are expected after executing ResultRetcode() method When the PositionClosePartial(...) method had been run before that .

as mentioned in the MQL5 document successful completion of the PositionClosePartial(...) method does not always mean a successful execution of a trading operation. after executing  PositionClosePartial(...) we should call the ResultRetcode() method to check the result of a trade request (Return Codes of the Trade Server).

I think ,  checking of  "TRADE_RETCODE_PLACED" or "TRADE_RETCODE_DONE" return values are enough. what do you think?


Thanks for your answer in advance.


                        EA_Trade.PositionClosePartial(PosTicket,PartialExitVolume,ULONG_MAX);
                        int RetCode = EA_Trade.ResultRetcode();
                        if(RetCode==TRADE_RETCODE_DONE || RetCode== TRADE_RETCODE_PLACED) //Request is completed or order placed)
Files:
1.jpg  125 kb
 
I checked it out with the strategy tester, PositionClosePartial function returns "10009" or TRADE_RETCODE_DONE value if the function completed successfully.
 

I have a problem where PositionClosePartial returns false but the retcode is 10009. I don't see how that should be possible. The return of false seems correct since the position does not get partially closed.

I tried to trace where this happens in the function, and where it returns false is near the start where it does

/--- check stopped

   if(IsStopped(__FUNCTION__))

      return(false);

I don't know why it would be stopped. I am running the backtest, nothing is stopped. 

Thanks to anyone who has seen this and knows what is causing it.

 

An update in case anyone sees this one.

I found out to my surprise that my broker only services Forex for customers outside the US. This could explain why I am getting some odd results from the EA.

I can't be sure. But on one other error I was getting it was because of this.

It seems US Forex brokers who allow US customers only support MT4. I will have to try to get a copy from one of them. Or else go back to futures.

Reason: