If the cointegration test is purely part of the backtest then I suggest you use the RCom connection to push your data in to R, calculate the statistics in there (Google for "Chan cointegration price R" for R source code), then get your results out. I had that up and running in one day.