I anticipated there would be many answers to this already, but couldn't find any. I am aware of this question: How is stock price determined?, and I think I can deduce the answer from it, but I am very unsure, so I prefer a direct answer.
Let me best give an example. Recently, I noticed a sharp decline in the (last) price of the stock S. I placed a limit order for 10 stocks with a limit EUR 51,74. I got them on the next day at the opening for exactly EUR 51,50.
So, my question is: How does the price at which I buy really come about. Is it the cheapest selling price (ask) compliant with me order (meaning sellers always loose), is it the mean between my limit and the ask? Is it something entirely different?
Conversely, if I sell the stock with a limit order at EUR 55,00, does it mean I will only get 55,00, although there are people bidding EUR 56,00?
If it depends on the location, answers for XETRA are most appreciated.
EDIT
I think, that the suggested duplicate covers me, but I would like to be certain I understand correctly.
1)I got the stock for EUR 51,50, merely because the sellers ask predated my bid.
2)If the sellers ask of, say. EUR 51,50 had come after my bid, he would have gotten the full 51,74.
EDIT
I try to provide any information desired. Because I saw the comments, I add the following. I apologize, should it be irrelevant. I am (obviously) a newbie.
I ordered on one day shortly after 17:30 using XETRA. I chose the validity option "today" and the option "continuous trade". I was not aware of the stop of trading after 17:30.
The system (German) said that my order was received and would be presented ("vorgetragen") on the next day. Then, on the next day in the morning I got the stock for EUR51,50.