Suppose your task is to plot ROC - or any other indicator - of
all the symbols from a DataSet in one single pane. For example, you have
IBM, AAPL, INTC in a DataSet, and you would like to plot ROC for each one of them on top of each other.
With Wealth-Lab .NET, it's easily possible. Here's a short code snippet:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
Random r = new Random();
private Color RandomColor()
{
Color randomColor = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255));
return randomColor;
}
protected override void Execute()
{
string clickedSym = Bars.Symbol;
List rocList = new List();
foreach( string ds in DataSetSymbols )
{
//if( ds != clickedSym )
rocList.Add( ROC.Series( GetExternalSymbol(
DataSetSymbolsDataSetSymbols.IndexOf(ds), true ).Close, 10 ) );
}
HideVolume();
ChartPane rocPane = CreatePane( 100, true, true );
foreach( DataSeries ds in rocList )
PlotSeries( rocPane, rocListrocList.IndexOf(ds), RandomColor(), LineStyle.Solid, 1 );
}
}
}
Highlights:- You need to loop over the DataSet's symbols (see: DataSetSymbols)
- Add each symbol's ROC (or another indicator) to the List of DataSeries created before (see: rocList)
- Then, you loop by that List and plot each series
- Look up the helpful List.IndexOf method in MSDN
- RandomColor is self-descriptive