The longer you keep a car the less it depreciates. Only ever bought one new car - great car but I always regretted the money I spent (inherited money to be fair) as I watched it depreciate in value.
I have always tried (not succeeding in some cases) to work on a depreciation of £1,000 a year. The previous owner of my Lexus LS 400 paid £48,000 and sold it after 17 years - that is a depreciation of over £2,800 a year (not including inflation!).
Look at how much 2 and 3 year-old cars go down in value. If they are worth 50% of their new value after 3 years you are doing very well. Trade-in values are quite low - next time you get a trade-in value turn it around and say to yourself, "Would I buy my car for that price?" The answer would nearly always be YES - at that price it is a bargain!
It is a gamble buying any car (even new!). I have come to the conclusion, the less you spend the less you have lost if it goes pear-shaped. Also the more I spend the greater are my expectations of the vehicle. Buying an "old" Lexus has, once again, brought a big smile to my face. The car is not perfect but for the money it is fantastic!
When to sell? I would keep it as long as possible until it goes badly wrong or you get fed-up with it.