Log in to see Cloud of Tags

Wealth-Lab Wiki

Correlation: Indicator Documentation

Syntax


DataSeries CorrelationXL( DataSeries x, DataSeries y, int period )
DataSeries Correlation( DataSeries x, DataSeries y, int period )

public static double Value( int bar, DataSeries x, DataSeries y, int period )

Parameter Description

xFirst DataSeries
ySecond DataSeries
periodLookback period used to calculate correlation between the series

Description

Returns Pearson's Correlation Coefficient between the two specified data series, x and y. Specify the quantity of data to analyze in the Lookback parameter (period).

The first series coded by Michael Bytnar and is used to match Excel's output, the other one coded by Steve Salemy returns Pearson Correlation function using a Community.Components function.

References:
Pearson Correlation - a Community.Components function

Example

This code plots both implementations of the Pearson Correlation formula taking correlation of RSI and CMO for example:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { int Period = 99; CMO cmo = CMO.Series(Close,20); RSI rsi = RSI.Series(Close,20); DataSeries c1 = CorrelationXL.Series( cmo, rsi, Period ); DataSeries c2 = Correlation.Series( cmo, rsi, Period ); HideVolume(); ChartPane c = CreatePane( 50, false, true ); ChartPane c_ = CreatePane( 50, false, true ); PlotSeries (c, c1, Color.Black, WealthLab.LineStyle.Solid, 3); PlotSeries (c_, c2, Color.Blue, WealthLab.LineStyle.Solid, 3); } } }

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. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.