Correlation
<< Click to Display Table of Contents >> Correlation |
Correlation(int period, string correlationSeries)
string correlationSeies(ISeries<double> input, int period, string correlationSeies)
double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.
input |
Indicator source data (?) |
period |
Number of bars used in the calculation |
correlationSeries |
The data series to compare to |
// The correlation data series must be added to OnStateChange() as this indicator runs off the correlation data series data
// Checks the bars in progress and prints the current correlation to the SPY double value = Correlation(20, "SPY")[0]; } |
Note: If the correlation series does not plot during a time the input series plots, a value of zero would plot in the above example. You may consider ignroing zero values. |
You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.