I posted a cointegration indicator ("CADF") in the Elite Downloads area. It plots the output statistic of an Augmented Dickey Fuller cointegrating regression of 2 instruments. It's a C# translation of MATLAB code developed by James P. LeSage and posted at Econometrics Toolbox for MATLAB (. I used some mathematical routines from ALGLIB (ALGLIB () which are included, and wrote a lot of helper routines to accomplish the MATLAB functions. Even if you're not interested in cointegration, you might find it useful as an example programming with quantitative methods for NinjaTrader.
I haven't seen a cointegration indicator for a trading platform posted publicly before, only MATLAB or R code. So I thought I would be the first. I posted it for futures.io (formerly BMT) Elite members only, please don't share or distribute.
This version is made using primarily static routines, which call "new" frequently. This works fine for indicators or normal strategies, but it can fall apart by filling up memory if you try to run an extensive optimization on it. The alternative is to implement the internal routines as classes which can be instantiated once and pre-allocate their storage once at the start. I've done that for strategies, and it helps optimizer performance quite a bit, but ALGLIB uses "new" in some places so I haven't been able to get rid of all uses of "new".
I also posted the latest ALGLIB 3.5.0 library, packaged as a NinjaTrader "indicator", in the MATLAB downloads area. But it's not needed for CADF, the required ALGLIB routines are included.