Memory Question

 

Is it possible to retain a variable double in memory, that is calculated inside an EA, that will stay in memory when a computer is restarted?

Thanks for any help... couldn't find the answer in Documentation or by Search....

I'm thinking GlobalVariableSet() may do it...can anyone confirm this?

 
William Russin:

Is it possible to retain a variable double in memory, that is calculated inside an EA, that will stay in memory when a computer is restarted?

Thanks for any help... couldn't find the answer in Documentation or by Search....

I'm thinking GlobalVariableSet() may do it...can anyone confirm this?

Yes, the Global Terminal Variables is the answer!

EDIT: Just remember to flush them regularly using GlobalVariablesFlush() to prevent loss of data in case of a application or computer crash.

 
Thanks Fernando !!!  I appreciate your help !!!
 

I've never used  GlobalVariablesFlush() before...but it seems like a great plan.  Does each GlobalVariableSet() that I create need to be "Flushed" after I set them? or does one GlobalVariableFlush() save them all?  The documentation seems to be ok using it once to save all...

Not sure how that can be tested without having a crash LOL

 
William Russin:

I've never used  GlobalVariablesFlush() before...but it seems like a great plan.  Does each GlobalVariableSet() that I create need to be "Flushed" after I set them? or does one GlobalVariableFlush() save them all?  The documentation seems to be ok using it once to save all...

Not sure how that can be tested without having a crash LOL

It flushes any and all pending data. In my own code, I use it every time I update a block of global terminal variables, but also for individual updates when necessary.

Reason: