Hi there,
I'm trying to create an indicator, imagine EMA (It's not exactly that, but it serves to explain).
To calculate it I can put:
EMA_{t+1} = (1-a)*EMA_t + a*Close_{t+1}
I can use context variable to store the previous value of EMA.
In code, could be:
context.ema = (1-a) * context.ema + a * data[symbol].price_close
However, arises the following question, that is how to compute context.ema for the first trading day. A natural solution should be calculate the average price in the N previous days (N=int(1/a) for instance), and this should be inside the initialize function. But I can't access to history function inside the initialize function, there is any way to overcome this?
Thank you.