Persist data/object between timeframe/input changes?

 

Hi,

I have a process that only occurs once and when it does, it dispatches notifications in the usual "standard" ways (email, push etc).

However, if I change time-frame/input-vars, as the triggering situation is "recalculated", my EA will re-send notifications. I would like to retain the knowledge of the original notification occurrences between these "sessions" and wonder what is the best way to do this? 

I've thought that I could use a variable in my EA that points to an object that could hold knowledge of these notifications and not "delete" it in the OnDeinit event handler. However, I don't know whether this is both; a) good practice, and b) will cause a memory leak? I imagine that b) is unlikely as the whole EA would be unloaded after leaving such an object pointer "dangling".

I'd appreciate any thoughts on the best approach to this?

Cheers!

--G

 
  1. Variables can't leak, memory is reclaimed when the EA is removed from the chart (removed, compile, chart close, terminal close.) Don't new objects, that would be. Indicators are reloaded on chart changes, EAs aren't.
  2. Define a global/static variable bool isInitialLoad=true; do one time initialization and set it to false. All other global/static variables will retain their values.
  3. If the symbol changes, you probably do want to reinit completely.
 
whroeder1:
  1. Variables can't leak, memory is reclaimed when the EA is removed from the chart (removed, compile, chart close, terminal close.) Don't new objects, that would be. Indicators are reloaded on chart changes, EAs aren't.
  2. Define a global/static variable bool isInitialLoad=true; do one time initialization and set it to false. All other global/static variables will retain their values.
  3. If the symbol changes, you probably do want to reinit completely.

Hey @whroeder1 - many thanks for your answer and clarification! Just what I needed to know :)

Cheers,

--G



Reason: