- Need a delete function for initial expert loading only.
- Unknown ticket 1 for OrderModify function + OrderModify error 4108
- MQL4 Help moving stop loss
You need to handle errors in the correct manner, in some circumstances you cannot simply keep trying . . . you should read the Documentation regarding the various errors and take action accordingly.
Trading Errors: https://docs.mql4.com/trading/errors
Dear RaptorUK:
Thank you for your prompt respond. It seems that my question is not clear. I need to know a way that if an error occurs, ANY ERROR, the EA tries to modify the open trade. That is if modification is not successful for any reason or error, the EA must go back and do the modification again. Please understand I do not care what type error I get, all I need is to trigger the EA to do the process of modification again.
Thank you in advance.
Dear RaptorUK:
Thank you for your prompt respond. It seems that my question is not clear. I need to know a way that if an error occurs, ANY ERROR, the EA tries to modify the open trade. That is if modification is not successful for any reason or error, the EA must go back and do the modification again. Please understand I do not care what type error I get, all I need is to trigger the EA to do the process of modification again.
I understood your question . . . but the point is that you MUST care what the error is . . . for example, error 132, the market is closed . . . you cannot simply retry the OrderModify and hope it will work, or error 4, server is busy . . . you need to wait several minutes before retrying, on the other hand error 135 price changed, you can do a refresh rates and retry immediately.
Dear Rapto:
This is exactly my point. As you said, if for example, I get error 135, I must do a refresh and retry again. Here comes my question: How can I ask EA to retry again if, for example, error 135 occurs?
Dear Rapto:
This is exactly my point. As you said, if for example, I get error 135, I must do a refresh and retry again. Here comes my question: How can I ask EA to retry again if, for example, error 135 occurs?
Just repeat the OrderModify.
Dear Rapto:
Thank you for your quick respond. Unfortunately, either my question is not clear or you have difficulty understanding me. You just said "Just repeat the OrderModify.", this is fine, but, how can I repeat the OrderModify. What code or conditions should I use to repeat the OrderModify?
Thank you for your quick respond. Unfortunately, either my question is not clear or you have difficulty understanding me. You just said "Just repeat the OrderModify.", this is fine, but, how can I repeat the OrderModify. What code or conditions should I use to repeat the OrderModify?
I understand, but I'm not going to write your code for you . . .
You need to check the return value from OrderModify to see if it has failed, if it has failed you need to read the last error, if the error is such that you can repeat the OrderModify immediately then you can do so, you use the same OrderModify as you did before . . . you are simply repeating the same OrderModify. If you need to wait then you will need to wait . . . then you can repeat the OrderModify.
Dear Rapto:
Thank you for your quick respond. Unfortunately, either my question is not clear or you have difficulty understanding me. You just said "Just repeat the OrderModify.", this is fine, but, how can I repeat the OrderModify. What code or conditions should I use to repeat the OrderModify?
use
while(/*some error is returned*/) { //modify the order }
if(OrdersTotal()>0)This makes the EA incompatible with every other including itself on other charts and manual trading.
int count = 0; for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == Magic.Number // my magic number && OrderSymbol() == chart.symbol // and my pair. ){ count++; } if (count > 0) ..
Dear BHC and WHRoeder:
Thank you very much for your help. Finally, you guys understood what I was asking.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use