When the factory warranty on my old X3 was close to expiration, I did shop around for extended warranty and found that the extended warranties are either too expensive (2.5k-3.5k for 2 years) or don't provide enough covergae (too many fine prints) and chose to put that money aside for any repairs. Basically, I bought the warranty from myself. The warranty related repairs for the two years (or 28k miles) were under 1000k. I spent another $750 for the last 18 months or 20k miles bringing the total repair cost to about $1750. Sold the car at 99,500 miles. Note that if you decide to buy warranty then you need to keep buying the warranty every 2-3 years and the total money spent on warrant will soon adds up. be aware that the wear and tear related repairs aren't covered by extended warranties. Some dealers offer different service warranties at a rip-off price.
For luxury cars, if you drive more than 10k miles, leasing would be a better choice. My friend who drives a volvo spent 4k on transmission at 120k miles and another 2k on some other repairs and now he is not willing to trade-in his volvo due to as he already "invested" money in. Luxury cars can soon turn into a money pit after 100k miles.
If you really want to buy extended warranty for peace of mind, then wait towards 3-5k miles short of the expiration of factory warranty period/mileage. The big advantage of the delayed purchase is the time value of money. The other benefit is that for some reason 3-4 years down the road, if you changed your mind to trade-in your car for another, you will not lose the money paid to the warranty. (Transferable warranties will not add significant value when you sell). Good luck.