Your code tries to delete every order
RefreshRates is the only code dependant on the if conditions
Put in some curly braces
void DeleteOrders() { for(int g=OrdersTotal()-1; g>=0; g--) { if(!OrderSelect(g,SELECT_BY_POS,MODE_TRADES)) continue; if(OrderSymbol()==Symbol() &&(OrderMagicNumber()==MagicNumber || OrderMagicNumber()==MagicNumber1 || OrderMagicNumber()==MagicNumber2) && (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP)) //Also tried (OrderType()>2) { RefreshRates(); if(!OrderDelete(OrderTicket())) Print("Deleting stop orders"," Ordertype:",OrderType()); } } }
Why do you need the RefreshRates anyway?
Your code tries to delete every order
RefreshRates is the only code dependant on the if conditions
Put in some curly braces
Why do you need the RefreshRates anyway?
Thank you GumRai. RefreshRates() removed. It doesn't seem to be giving the error as many times now, but it still pops up. This is what I get printed. It deletes the order and then gives errors:
2015.05.29 09:06:44.633 2015.01.05 13:23 OrderDelete error 4108 2015.05.29 09:06:44.633 2015.01.05 13:23 unknown ticket 22 for OrderDelete function 2015.05.29 09:06:44.633 2015.01.05 13:23 OrderDelete error 4108 2015.05.29 09:06:44.633 2015.01.05 13:23 unknown ticket 22 for OrderDelete function 2015.05.29 09:06:44.633 2015.01.05 13:23 OrderDelete error 4108 2015.05.29 09:06:44.633 2015.01.05 13:23 unknown ticket 22 for OrderDelete function 2015.05.29 09:06:44.633 2015.01.05 13:23 Deleting BUY_STOP Ordertype:1 2015.05.29 09:06:44.633 2015.01.05 13:23 delete #22 buy stop 0.50 EURUSD at 1.19429 sl: 1.19129 tp: 1.19814 ok
It had not entered the buy stop, why is it trying to delete a sell and returning OrderType():1? Also, may I ask for an understanding as to why the curly brackets addition?
Also, may I ask for an understanding as to why the curly brackets addition?
Because in your original code, there were no conditions for the order delete. It would try to delete every order.
The log items that you have posted do not come from the code that you have posted.
Please post the actual code that you have used.
Because in your original code, there were no conditions for the order delete. It would try to delete every order.
The log items that you have posted do not come from the code that you have posted.
Please post the actual code that you have used.
Aha! Rookie error indeed. Thank you! That is referring to another OrderDelete() in my code. Managed to fix the error. If you have a moment, is it possible to help me on this thread: https://forum.mql4.com/67798
Thanks!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys,
My OrderDelete() is attempting to delete incorrect orders, thus giving me errors. Below is the code:
It is trying to delete buy and sell orders. ie. OrderType()<3; however it needs to delete OrderType()>2.
Please help!