What is the price of an ask order bought if a bid order is placed at a higher price? For example, if there exist two ask orders at $50 and $49, and I place a bid order at $50 of an amount larger than amount of the two ask orders, will I buy the $49 ask order at $49? Or will I pay $50 for both orders, losing $1 on the lower one?
2 Answers
When a new order is added to the order book, it will first be matched against already existing bids and offers. The older orders take precedence: you match them at what you saw on the order book. If there are multiple orders at the same price, they are prioritized oldest first.
In your specific example where you bid with a larger amount on an order book that has offers at $49 and $50, you would buy the offer at $49, then the offer at $50, and the remainder of your bid would be added to the order book for someone else to be matched with a sell order.
If you bid a higher price than a buy order, you will purchase that buy order at the ASK price, you won't pay more than they were asking for. Your order will fulfill all sell orders up to the amount and price you set your bid. This is known as a limit order.
If you requested to buy more coins than the $49 sell order, you would fulfill that order at $49 and then buy the rest at $50.
See also: How will Mt.Gox select matching orders if asking for a price that is higher than available prices