# Pair Trading Lab Helpdesk & Forum

## Pair Trading => Models, Algorithms & Approaches => Topic started by: marc-antony foreman on October 13, 2021, 06:04:27 am

Title: Standard deviation
Post by: marc-antony foreman on October 13, 2021, 06:04:27 am
Hello, does the standard deviation moving average match the  moving average of the ratio?

For example if I select EMA for the ratio, does the standard deviation use the EMA as well or does it use SMA for that caclulation.

Thanks
Title: Re: Standard deviation
Post by: admin on October 13, 2021, 06:19:14 am
From the documentation of ratio model:

* we trade pair of stocks A, B, having price series A(t), B(t)
* we need to calculate ratio time series R(t) = A(t) / B(t)
* let's apply moving average of type T with period Pm on R(t) to get time series M(t)
* let's apply standard deviation with period Ps on R(t) to get time series S(t)
* now we can create Z-score series Z(t) as Z(t) = (R(t) - M(t)) / S(t), this time series can give us z-score to signal trading
* decision directly (in reality we have two Z-scores: Z-scoreask and Z-scorebid as they are calculated using different prices, but for the sake of simplicity let's now pretend we don't pay bid-ask spread and we have just one Z-score)

About your question about the MA type - nope we always use SMA for underlying MA calculation in stddev.