Hi, I am totally new to Quantopian and also new to coding (aside from Fortran 20 years ago).
I am trying to replicate a timing signal that I have been using in Vectorvest using the DPO.
Here is what I coded inside a scheduled function.
The reference security will be to time the market, and I will put trades using context.security.
I was struggling getting the right value for the lookback period for the security.
As such, what if I want a DPO of 11 days, the lookback period will have a value of 6.5. How does it work with the array of prices... ??
Thank you
DPO_period = 20
Lookback_period = ((DPO_period/2) + 1)
DPO_price = data.history(reference_security, 'price', DPO_period,'1d')
SMA_DPO = DPO_price.mean()
Lookback_price = data.history(reference_security, 'price', Lookback_period,'1d')
DPO = (Lookback_price[(-Lookback_period)] - SMA_DPO)
log.info(DPO)
record(DPO = DPO)
For some reason, I cannot get the same DPO values as other software.