My experience is that if the market you are working in is expanding rapidly, then changing companies is the way to go. I quadrupled my salary in three years changing companies four times, OK, this was computer field trouble-shooting in the oilfield in the Far East, in the boom times of the 1970s (HP & DEC minis). These were US companies & I actually returned to one after leaving them, there were no hard feelings, they knew they were lucky to get me back.
Much later I had to re-enter the same business during a fairly static period, things weren't going down, they were just not expanding. I felt I was lucky to get the job I was offered & stuck with it for four years until I had a consultancy offer, which I took, the consultancy business in that field was expanding & starting to use personal computers... was a good move then.
My point is you have to look at what is happening in the market/business you have your core skill set in. If the new company needs you to bird-dog a project & that project sells but not that well, as last in you might be first out. Let alone if that project bombs.
Don't generalise & do your research.