help needed
- "return value of 'OrderModify' should be checked"
- OrderSelect and OrderModify Error
- return value of 'OrderModify' should be checked error
if (Bid>takeprofit2-20*Point&&Bid<takeprofit2+20*Point&&o==0) { for(int i=OrdersTotal()-1;i>=0;i--) { for(int j=i;j>=0;j--) { if(OrderSelect(i, SELECT_BY_POS)) { o=2; ticket=OrderTicket(); openprice=OrderOpenPrice(); takeprofit=OrderTakeProfit(); OrderModify(ticket,openprice,openprice+2*spread,takeprofit,0,Red);
https://www.mql5.com/en/forum/139592
and
https://docs.mql4.com/en/trading/ordermodify
Returned value (OrderModify)
If the function succeeds, it returns true, otherwise false.
You aren't checking the return value of OrderModify in your last line of code. That is why you are get the warning.
To put it another way, MT4 wants you to check if the OrderModify function returns true or false rather than just blindly running it.
MT4 is now more strict and alerts you to this bad style as a warning (not an error).
if(OrderModify(ticket,openprice,openprice+2*spread,takeprofit,0,Red)) {/*do something*/} else {/*do something else*/}
is it new?
is it new?
yes
it doesn't modify. why? no error.
Use Print() so that it produce output in case it doesn't modify.
I used Print() and it returns nothing.
if(Bid>takeprofit2-20*Point && Bid<takeprofit2+20*Point && o==0) { Print("1"); for(int i=OrdersTotal()-1;i>=0;i--) { for(int j=i;j>=0;j--) { if(OrderSelect(i,SELECT_BY_POS)) { Print("2"); o=2; ticket=OrderTicket(); openprice=OrderOpenPrice(); takeprofit=OrderTakeProfit(); if(OrderModify(ticket,openprice,openprice+2*spread,takeprofit,0,Red)) Print("3"); } } } }"o" is changed to 0 when all positions are closed.
takeprofit2 is at least 40-50 pips from OpenPrice(). and it gets there, but doesn't enter. it doesn't return "1".
what more can I do?