well, i just need to close all hedge order buy and sell with the same lot size,
the problem is a lot of order on my system, so when i use close all order function (not closeby function) it is bad on live forward test, mean all order is not closing all order on the only one order close price.
Have you look into this ?
https://sites.google.com/site/marketformula/mql4-trading-functions/mql4-orderclose-ordercloseby-orderdelete-ordermodify-ordersend
It is not clear exactly what you are trying to do
To be honest, I have never used OrderCloseBy in my coding.
Note, in your code, you try to close the trades after every orderselect with the symbol, whether you have found the relevant trades or not . So you will get errors.
This is not tested, but may be of use. You should still add checking for errors.
void closeby1() { int OrderID=0,OrderIDopposite=0; for(int total=OrdersTotal()-1; total>=0; total--) { if(OrderSelect(total,SELECT_BY_POS,MODE_TRADES)) { if(OrderSymbol()==Symbol()) { if(OrderComment()=="buy1_comment" || OrderComment()=="buy2_comment") { OrderID=OrderTicket(); } if(OrderComment()=="sell1_comment" || OrderComment()=="sell2_comment") { OrderIDopposite=OrderTicket(); } if(OrderID>0 && OrderIDopposite>0) { if(OrderCloseBy(OrderID,OrderIDopposite,Black)) { OrderID=0; OrderIDopposite=0; } } } } } }
It is not clear exactly what you are trying to do
To be honest, I have never used OrderCloseBy in my coding.
Note, in your code, you try to close the trades after every orderselect with the symbol, whether you have found the relevant trades or not . So you will get errors.
This is not tested, but may be of use. You should still add checking for errors.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can someone help me to correct this code