I see, so if closed the whole chart window for example, yes the variable is back to 0. I believe what you're looking for is probably storing the value into a GlobalVariable, which stays stored in MetaTrader for a certain amount of time. So even if the chart window closed and EA shutdown, etc, it will remain the same. There is a block in FXDreema called Terminal Variables, which does this under the Output section.
Unfortunately, I'm not super knowledgeable on the topic but it's what you're probably looking for. You'll likely need to utilize the OnDeinit and OnInit function with your global variable. I can look into it when I have some more time unless you figure it out or someone else can help out!