I want to write a function to closeallorders based on a variable parameters input of Symbol and MagicNo
eg
CloseAllOrders() - close every orders
CloseAllOrders(Symbol()) - close orders that are Symbol()
CloseAllOrders(MagicNo) - close orders that has MagicNo
CloseAllOrders(Symbol(),MagicNo) - close orders that are Symbol() and has MagicNo
How do you handle variable parameters input in MQL4?
thks in advance for any assistance/ideas into this
It is not possible to do it in MQL4, the next version MQL5 can do it.
CloseAllOrders() - close every orders
CloseAllOrders(Symbol()) - close orders that are Symbol()
CloseAllOrders(MagicNo) - close orders that has MagicNo -- xxxxx
CloseAllOrders(Symbol(),MagicNo) - close orders that are Symbol() and has MagicNo
.
.
With this protoype you can, except the third one.
void CloseAllOrders( string symbol = "", int magic = -1){
.. set the logic in the function to observe the parameter passed

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to write a function to closeallorders based on a variable parameters input of Symbol and MagicNo
eg
CloseAllOrders() - close every orders
CloseAllOrders(Symbol()) - close orders that are Symbol()
CloseAllOrders(MagicNo) - close orders that has MagicNo
CloseAllOrders(Symbol(),MagicNo) - close orders that are Symbol() and has MagicNo
How do you handle variable parameters input in MQL4?
thks in advance for any assistance/ideas into this