Hello,
I will try to keep it short. I noticed a weird thing with one of my EA's and perhaps you can give me some insight about it.
I have an EA running on an Oanda demo account (MetaTrader 4). The EA is loaded into various different pairs at the same time. The EA is completely automatic and should never require manual intervention by the user. Also, it is the only EA running on that MetaTrader instance/account. Anytime it opens a trade, it does with a custom comment and also with magic number 123454 (this is hardcoded in the two OrderSend calls that there are). This magic number is used to check whether the trade must be managed by the EA or not.
Sometimes (I think I've only seen it two or three times in perhaps 8 months), I get a trade that has no comment, and whose magic number is 0. I know that the broker can sometimes modify the comment of a trade (for example, when partially closing an open position). However, I don't know where this ghost trade is coming from.
I currently have one of those, and by checking some custom logs of the EA, I noticed the following: At the exact same time (down to the second) the "real" trade was opened, the EA triggered a log message that only gets called when the OrderSend function returns -1 (failed to send the order). More precisely, it reported that it was trying to open an order with the same size than the one that was opened, and it returned with the error 136 (off quotes).
Googling a bit, I found this post https://www.mql5.com/en/forum/115719 , in which a user named dRONCHIKUS mentions:
"From the documentation section:
ERR_OFF_QUOTES 136 No quotes. The broker has not supplied with prices or refused, for any reason (for example, no prices at the session start, unconfirmed prices, fast market). After 5-second (or more) delay, it is necessary to refresh data using the RefreshRates function and make a retry."
However, this message dates from 2009, so I don't know if this still applies. Also, I don't seem to be able to find that in the documentation anywhere. In my EA, the retries happen every second, so this could be related. However, I would like to be sure before touching anything that this is indeed the cause.
Despite this, I think that the trade must be coming from something like a desynchronization problem because of the account being demo, or something like that...
Could you please help me?
Best regards,
G.A.
![Off Quotes Error in MT4 Off Quotes Error in MT4](/i/community/logo_mql5_small.png)
Off Quotes Error in MT4
- 2009.03.21
- www.mql5.com
I've written an expert for MT4 that is giving ERR_OFF_QUOTES errors trying to modify an existing order...
- Off Quotes Error in MT4
- Trailing stop does not work in a fast markt- I need Help
- Seeking [Off quotes] Error Explaination
- If you are using Predefined Variables to open/modify orders, you must use RefreshRates between Sleep and server calls. Unless you do, your retries will never work.
- Either your second call is not using the MN, or some other EA is doing it.
- Why use two orders? Open one and do a partial close.
Hello whroeder1,
Thanks for the answer. I noticed a few places in which I was perhaps using outdated data as you mention in point 1, so I added RefreshRates calls in those places. However, I don't think that could be the cause of the problem. I will thoroughly go over the code again to be sure. What I'm completely sure is that no other EA could have opened that order, and that all the OrderSend calls use the same magic number/comment.
About the two orders, I think I wasn't very clear in the first post. The case is that at the time the ghost trade was opened, read from the Trade tab of MT4, let's say 18:20:34 and 0.40 lots, also a message was written to a custom log file stating: "18:20:34 ERROR: Error opening an order of 0.40 lots. Error code: 136" (well, I don't know it it was written at the same time, but the timestamp written is the same, so I suppose so). So that particular error probably comes from a requote which I wasn't taking into account because of not calling RefreshRates (fixed already). However, after a few retries, the EA will wait for the next bar to try again and it seems it opened the trade OK at the next bar - 0.40 lots.
Anyway, I will work on improving the log capabilities of the EA, and also will come back here when I find something (hopefully!).
Thank you again.
Best regards,
G.A.
Thanks for the answer. I noticed a few places in which I was perhaps using outdated data as you mention in point 1, so I added RefreshRates calls in those places. However, I don't think that could be the cause of the problem. I will thoroughly go over the code again to be sure. What I'm completely sure is that no other EA could have opened that order, and that all the OrderSend calls use the same magic number/comment.
About the two orders, I think I wasn't very clear in the first post. The case is that at the time the ghost trade was opened, read from the Trade tab of MT4, let's say 18:20:34 and 0.40 lots, also a message was written to a custom log file stating: "18:20:34 ERROR: Error opening an order of 0.40 lots. Error code: 136" (well, I don't know it it was written at the same time, but the timestamp written is the same, so I suppose so). So that particular error probably comes from a requote which I wasn't taking into account because of not calling RefreshRates (fixed already). However, after a few retries, the EA will wait for the next bar to try again and it seems it opened the trade OK at the next bar - 0.40 lots.
Anyway, I will work on improving the log capabilities of the EA, and also will come back here when I find something (hopefully!).
Thank you again.
Best regards,
G.A.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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