So I thought it might be useful to work through an example, to try to make the mechanics clear. I'll try to do this is stages so that others can jump in along the way, if they want to.
Start with some weekly data for an ETF triplet analyzed in Ernie Chan's book:
`tickers = {"EWA", "EWC", "IGE"};
period = "Week";
nperiods = 52*15;
finaldate = DatePlus[Today, {-1, "BusinessDay"}];`
After downloading the weekly close prices for the three ETFs we divide the data into 14 years of in-sample data and 1 year out of sample:
stockdata =
FinancialData[#,
"Close", {DatePlus[finaldate, {-nperiods, period}], finaldate,
period}, "DateList"] & /@ tickers;
stockprices = stockdata[[All, All, 2]];
isprices = Take[stockprices, All, 52*14];
osprices = Drop[stockprices, 0, 52*14];
We then apply Amanda's JohansenTest function:
JT = JohansenTest[isprices, 2, 1]
We find evidence of up to three cointegrating vectors at the 95% confidence level:

Let's take a look at the vector coefficients (laid out in rows, in Amanda's function):

We now calculate the in-sample and out-of-sample portfolio values using the first cointegrating vector:
isportprice = (JT[[2, 1]]*100).isprices;
osportprice = (JT[[2, 1]]*100).osprices;
The portfolio does indeed appear to be stationary, in-sample, and this is confirmed by the unit root test, which rejects the null hypothesis of a unit root:
ListLinePlot[isportprice]

UnitRootTest[isportprice]
0.000232746
Unfortunately (and this is typically the case) the same is not true for the out of sample period:
ListLinePlot[osportprice]

UnitRootTest[osportprice]
0.121912
We fail to reject the null hypothesis of unit root in the portfolio process, out of sample.
I'll press pause here before we go on to the next stage, which is Kalman Filtering.