problem resolved now i get another error
double CloseAllTrades() { for (int i=OrdersTotal(); i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS)==true) if (OrderSymbol() ==Symbol()) { OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red); } } }
the error is '}' - not all control paths return a value Morphius.mq4 43 1
Use the </> button to insert your code.
- >
-
You declared your function returns a double. What are you returning before the last brace?
-
OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Red);
You assume the order is a buy; code fails on sell orders. Use OrderClosePrice() and be direction independent.
Your double CloseAllTrades() should be a void… or at least a bool…. OrderClose() is a Boolean function… you can return the result of that… bool result = OrderClose(………).. and before last } return(result)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I get an error ['CloseAllTrades' - function declarations are allowed on global, namespace or class scope only Morphius.mq4 37 8]
what is that ?