When you place a limit order the engine will try to match it against existing orders. If it can be executed it will.
Specifically, it will be executed
at the price of those existing orders, right?
Just to clarify, is a bid a buy or sell offer?
Yes it will be executed against the BEST POSSIBLE existing order. If it can't then your order joins the order book and the next order placed may execute against it.
A bid = price willing to pay (someone is looking to BUY BTC at that price).
An ask = price wanted to receive ( someone is looking to SELL BTC at that price).
When MtGox shows a bid/ask of $99/$101 it means:
of all the buy orders ALREADY on the books the best (highest) price is $99.
of all the sell orders ALREADY on the books the best (lowest) price is $101.
So if you wanted to SELL it would match against the BIDS.
If you place a market order you would get a price of $99 (assuming the depth at $99 was larger than your order)
If you placed a limit order to sell @ $102 there would be no match, no execution however your order would be added to the order book. There are other "cheaper" asks ahead of yours.
If you placed a limit order to sell @ $100 there would be no match, no execution however your order would be added to the order book. Your order becomes the new "best" ASK and the spread becomes $99/$100
If you placed a limit order to sell @ $1 then it would match against the BID of $99. Execution price would be $99 (assuming the depth at $99 was larger than your order)*
* Remember a limit order simply means give me a price no WORSE than $x. That is why the limit of $1 executes at a price much higher.