The PPO values don't look correct to me which means I'm likely doing something wrong - I'm new here.

The code attached runs a standard 12, 26, 9 PPO against SPY through yesterday, April 16.  QC is returning a PPO of 1.46 and a PPO signal value of 4.09.   My calculations in the attched code returns PPO of -0.4565 and a PPO signal of -0.7408.  StockCharts generally agrees with PPO = -0.449  and signal = -0.734.

Any input would be appreciated.  The relevant output in the attached backtest is in the log file.

As a secondary question, what would be the best way to handle the conversions necessary for my math.  After an hour or so of trying I converted everything over to floats, but suspect there is a better way.

Thanks,