Why do orders get opened at different price than the actual Bid/Ask?

 
Print (MarketInfo(_Symbol,MODE_BID));
OrderSend(_Symbol,OP_SELL,0.01,MarketInfo(_Symbol,MODE_BID),0,0,0,NULL,0,0,clrNONE);

Notice how, upon utilizing the code above, in the Experts tab you will see that there is sometimes a discrepancy between the MarketInfo(_Symbol,MODE_BID) and the actual price at which the orders are opened. Does not happen all the time. Why is this? Is this because of the lag? Any ideas?

 

That is called slippage. You can only open at the current market price.

  1. You have network delays (usually MS range,) but if you loose connection just before the send, it will take 30+ seconds for the timeout, reconnect, resend.
  2. Then you sit in the server queue, while it processes all older requests. Then it must check your account and free margin and if that passes, the current market value is the price you get. Normally only a fraction of a second, during news releases, this can take minutes and the market move continuously.
 
whroeder1:

That is called slippage. You can only open at the current market price.

  1. You have network delays (usually MS range,) but if you loose connection just before the send, it will take 30+ seconds for the timeout, reconnect, resend.
  2. Then you sit in the server queue, while it processes all older requests. Then it must check your account and free margin and if that passes, the current market value is the price you get. Normally only a fraction of a second, during news releases, this can take minutes and the market move continuously.

Good to know. "Fill ins".