Help with a recurring OrderClose function error

 

Hello, 

I was wondering if anyone can shed light on the following error:

 

Would appreciate suggestions on how to fix it.

There is plenty of margin available and the lot size I used is  0.03 

Much appreciated,

Thanks,

 
Brian:

Hello, 

I was wondering if anyone can shed light on the following error:

 

Would appreciate suggestions on how to fix it.

There is plenty of margin available and the lot size I used is  0.03 

Much appreciated,

Thanks,

You'll need to show your code, or at least the relevant parts.
 
honest_knave:
You'll need to show your code, or at least the relevant parts.

Hi Honest_Knave

I'm not sure what the relevant parts are and the EA is rather long.

Can I perhaps  message you and attach the EA or would you rather I try paste some of the code here?

Just to add to my earlier message. Despite the error, the EA does fill the order later but it's normally a good 10 to 30 minutes later and obviously at the wrong price 

Regards,

 
Brian:

Hello, 

I was wondering if anyone can shed light on the following error:

 

Would appreciate suggestions on how to fix it.

There is plenty of margin available and the lot size I used is  0.03 

Much appreciated,

Thanks,

You have either to use OrderLots() to close a full position or

to normalize your lot size this way :

      double lotStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
      lots=MathRound(lots/lotStep)*lotStep;
 
Alain Verleyen:

You have either to use OrderLots() to close a full position or

to normalize your lot size this way :

      double lotStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
      lots=MathRound(lots/lotStep)*lotStep;

Perhaps add the check

    double lotStep=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
    lots=MathRound(lots/lotStep)*lotStep;

    if(lots>OrderLots())
       lots=OrderLots();
.
 

Thank you all for your contributions.

Greatly appreciated

Reason: