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
It seems that the ea already has the function of retry to open an order "NumberOfTries", but still can't make it work properly.
I just want to make this ea opens the order at the moment it should, and if can't open then retry immediately, without having to wait until next iteration.
I've changed two "breaks" functions and add errors to continue the loop. Is this correct?.
From this:
To this:
It seems that the ea already has the function of retry to open an order "NumberOfTries", but still can't make it work properly.
I just want to make this ea opens the order at the moment it should, and if can't open then retry immediately, without having to wait until next iteration.
I've changed two "breaks" functions and add errors to continue the loop. Is this correct?.
aF1 did you consider making a separate function for error handling ? I think you should read the Book and study the example of an error handling function you will see the author deals with error 0. Which in fact is not a real error. GetLastError() will return zero when there was no error, in other words zero is GetLastError's way of saying everything is fine. You are having an issue with it because you are calling GetLastError() even if the OrderSend() works.
Also ask yourseslf do you really need to get the ticket number and put it in the variable ticket ? Or do you just want to do the OrderSend(), and then move on unless there was an error ?
or,
So if a valid ticket is returned it will have a number > zero and therfore GetLastError() is not called when there was no error.
Also study the example of an open orders function and understand how the author passes errors from that function to the error handling function for processing, also look at how he puts the OrderSend() in a while loop so the order can retry after the error handling function attempts to remedy the problem.
You will probably end up with many many orders that you didn't want . . .
Yes, that's true.
I did call RefreshRates() after sleep(), and between server calls I guess not. Let me try.
...do you really need to get the ticket number and put it in the variable ticket ? Or do you just want to do the OrderSend(), and then move on unless there was an error ?
Hi SDC, thanks for your time.
I just want to Open the order, but if for any reason (error) the order didn't open, then immediately try again, until opens, then break. That's it.
Hi SDC, thanks for your time.
I just want to Open the order, but if for any reason (error) the order didn't open, then immediately try again, until opens, then break. That's it.
If you really want to know the proper way to handle these errors . . . it tells you here: Trading errors for error 138 do this:
The requested price has become out of date or bid and ask prices have been mixed up. The data can be refreshed without any delay using the RefreshRates function and make a retry. If the error does not disappear, all attempts to trade must be stopped, the program logic must be changed.
af1:
Hi SDC, thanks for your time.
I just want to Open the order, but if for any reason (error) the order didn't open, then immediately try again, until opens, then break. That's it.
Just put it in a while loop. You can put a counter in there to limit the amount of retries.. prevents forever looping, and in your error handling do like Raptor just said, refresh rates for 138, do other things for other errors like it shows in the book.
Ok, at this moment I'm lost. I've been trying some changes in the code, but this is what I've seen so far:
Or in other words, let's forget all the errors. I just would like the ea open the order as fast as possible, if there is an error, then retry immediately at the next tick.