Hi PTL Team,

I'm trying to come up with a matlab script to visualize my PTL residual model positions.

So my aim is to create the same zscore graph as you did on the backtesting result page (residual model -> Z-Score graph).

I have no problem with the OLS and to create the residual chart (for the whole timerange) of both stocks - as seen on the Orthogonal Residuals and Analysis of Residuals graphs on the analysis page.

But when i'm following the steps of the wiki page model description, I don't see how to apply the floating window and how to "calculate the regression for each day" ?

When I iterate through on the two stock time series, A(t) and B(t) and calculate a regression on each day (for the past or next period of 'P' days), then I will end up with T-P number of residual time series (all of them have P length) .

How do you process this result into one final residual time series ?

Can you please explain that part of the model description a bit more in detail?

thank you !