Problem getting rates

 

Hey,

I have a script that runs in a loop.

In the loop the script uses RefreshRates and then MarketInfo.

If the my conditions are met I try to OrderSend with the rates returned by MarketInfo.

The loop runs forever in the start method.

Very (very very) often I see that I did not get my desired price (Either by slippage or by getting a ERR_REQUOTE 138 "requote" error message).

I do not understand this. Am I missing something?

How is it possible that the computer can't get the rates he wants but if a user manually creates an order he usually get it.

Thanks.

 
MosheElisha:

Hey,

I have a script that runs in a loop.

In the loop the script uses RefreshRates and then MarketInfo.

If the my conditions are met I try to OrderSend with the rates returned by MarketInfo.

The loop runs forever in the start method.

Very (very very) often I see that I did not get my desired price (Either by slippage or by getting a ERR_REQUOTE 138 "requote" error message).

I do not understand this. Am I missing something?

How is it possible that the computer can't get the rates he wants but if a user manually creates an order he usually get it.

Thanks.

No, you're not missing anything, you have to make yourself a custom execution function, that loops an OrderSend until possible errors are rooted out. Bear in mind that it has to loop for ERR_REQUOTE, for example, but exit loop for ERR_NOT_ENOUGH_MONEY. However, this is not the worst thing about MarketInfo. The worst thing is that the feed may go off quotes from the broker and you won't know until hitting the order, because there is no MarketInfo(...,MODE_ONLINE), so if you make calculations on multiple quotes, you may get an off quotes at one feed right after some trades have been already launched on other symbols.

P.S. Manual traders are not exempt from MarketInfo's faults. Most likely, the manual order interface from MetaTrader would simply refuse execution and update quotes on the screen.

 
TheEconomist wrote >>

No, you're not missing anything, you have to make yourself a custom execution function, that loops an OrderSend until possible errors are rooted out. Bear in mind that it has to loop for ERR_REQUOTE, for example, but exit loop for ERR_NOT_ENOUGH_MONEY. However, this is not the worst thing about MarketInfo. The worst thing is that the feed may go off quotes from the broker and you won't know until hitting the order, because there is no MarketInfo(...,MODE_ONLINE), so if you make calculations on multiple quotes, you may get an off quotes at one feed right after some trades have been already launched on other symbols.

P.S. Manual traders are not exempt from MarketInfo's faults. Most likely, the manual order interface from MetaTrader would simply refuse execution and update quotes on the screen.

Hey,

Thanks for the reply.

I do have a loop that loops over ERR_REQUOTE and tries again but the price that I eventually get is not the price I did my calculations with.

Do you know of a way to improve the percentage of success to get the desired price?