After reviewing the implementation. I found that the Zscore it is calculated here: method getZScore in PairTradingModelRatio.java

But, I cannot return the same results as on the backtest. Please, correct me if I understood bad on the calculation of the zscore:

1. Calculate the min and max ratios from closing ASK and BID prices of the current date for both symbols. To do this, it is used MultiRatio class

2. Calculate historial ratio using closing historical data (not bid or ask) and do: stock1 close price / stock2 close prince

3. Calculate current EMA with 21 periods using historical Ratio calculated on previous step

4. Calculate STD DEV with 21 periods using historical Ratio calculated on step 2

5. Calculate zscoremin: (minratio - EMA of step 3) / STD DEV of step 4

Calculate zscoremax: (maxratio - EMA of step 3) / STD DEV of step 4

6. Finally, calculate the mean of zscoremin and zscoremax: (zscoremin + zscoremax) / 2 and this is the final zscore which appear on the trade log

What am I doing wrong?

Many thanks in advance,

Best Regards.