I've been trying to create a variable that is defined at all times but changes ocasionally and stays redefined throughout the entire backtest unless it's changed again. The problem is that either the variable needs to be set in initialize and cannot be changed later or needs to be set in handle data and will be reset every minute or day.
Basically, what I need is the following:
Define variable A
If event happens, define variable B
Replace A with B
or
Define variable A
If event happens, define variable B
If B is defined, use B instead of A
I feel like there's a simple solution I'm not seeing. Could anyone lend me a hand?
Thanks,
Aitor