ScrewTurn

Active Trader Strategies API Community ChartStyles Community Commissions Community Components Community Indicators Community Providers Community Visualizers Knowledge Base Misc Optimizers PosSizers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos
RSS

Navigation







Quick Search
»
Advanced Search »

PoweredBy

Syntax

public double Correlation(double[] x, double[] y, int n)

Parameter Description

x Array of double values (first data series)
y Array of double values (second data series)
n Lookback period

Description

Calculates Pearson Correlation. Uses code from ALGLIB project.

Example

The following example demonstrates how well correlated were CMO and RSI:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; // Correlation here

namespace WealthLab.Strategies { public class CorrelationDemo : WealthScript { protected override void Execute() { // How well correlated were CMO and RSI?

int n = Bars.Count; double[] x = new double[n]; double[] y = new double[n]; RSI rsi = RSI.Series( Close, 20 ); CMO cmo = CMO.Series( Close, 20 ); for(int bar = 0; bar < Bars.Count; bar++) { x[bar] = rsi[bar]; y[bar] = cmo[bar]; } Calculate calc = new Calculate(this); // pass WealthScript DrawLabel( PricePane, "Correlation: " + calc.Correlation( x, y, n ) ); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki version 3.0.2.509. Some of the icons created by FamFamFam.