In your example, BuyStop just keeps its value when the 'if' condition is not true.
In a programming language, variables do not "change to 0" by themselves. When you define a variable, it gets an initial value. It is normally 0 if you have not defined it otherwise. The variable keeps this value until you explicitly set it to something else. So when you defined your variable just before that 'if' line, it stays 0 of course when the 'if' condition is not true.