A question for someone smarter than me. I have a function that is supposed to close all trades, active or pending orders. It works on some brokers I'm trading with, but not on InstaFX. On IFX it only closes the pending orders and I cannot figure it out why. So the opened orders are not closed.
The printed log returns this: ## Close all trades true = no error, trade conditions not changed ##
if(OrderSymbol()==Symbol() && (OrderMagicNumber()==Magic || OrderComment()==Comment))A BUY position is closed at BID price, not Ask, reverse for sell.
if(OrderType()==OP_BUY) Printing=OrderClose(OrderTicket(),OrderLots(),Ask,100); // not working on IFX
Instead use OrderClosePrice() it will be Ask/Bid and you don't need to care about it :
if(OrderType()==OP_BUY || OrderType()==OP_SELL) Printing=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),100);
Your "Printing" variable is not set correctly, it's a bool or an integer ? If an order is not close/delete, it should be reported and not return "no error".
It only close if Magic or Comment matched, is it the case ?
A BUY position is closed at BID price, not Ask, reverse for sell.
Instead use OrderClosePrice() it will be Ask/Bid and you don't need to care about it :
Your "Printing" variable is not set correctly, it's a bool or an integer ? If an order is not close/delete, it should be reported and not return "no error".
Correct. I thought to use both Magic and Comment just to make sure the EA will stay on the same chart :) Although I realize only one of them would have been enough, probably.
I've made the modification you suggested and waiting now on an open trade to see what happens.
The Printing is a bool. I'm not sure what you mean by 'reported', so is it ok, you think? Or can you give me a link to the documentation?
Thanks a lot for your help.
Correct. I thought to use both Magic and Comment just to make sure the EA will stay on the same chart :) Although I realize only one of them would have been enough, probably.
I've made the modification you suggested and waiting now on an open trade to see what happens.
The Printing is a bool. I'm not sure what you mean by 'reported', so is it ok, you think? Or can you give me a link to the documentation?
Thanks a lot for your help.
Sorry wrong English...If an order is not close/delete, it should be logged : "error 1234...." ...
Oh, I see. So Printing should be 'int' just so that the EA can identify the error type by its number, right?

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
A question for someone smarter than me. I have a function that is supposed to close all trades, active or pending orders. It works on some brokers I'm trading with, but not on InstaFX. On IFX it only closes the pending orders and I cannot figure it out why. So the opened orders are not closed.
The printed log returns this: ## Close all trades true = no error, trade conditions not changed ##