# WealthScript Techniques | Relative Performance Chart

Modified on 2010/03/14 17:15 by Eugene — Categorized as: Knowledge Base

## Problem

"I would like to chart relative performance of 2-10 instruments starting at Data range definition (at 0%). The chart should have relative vertical axis (to see relative increase/decrease)."

## Solution

```
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;namespace WealthLab.Strategies
{
public class MyStrategy : WealthScript
{
// Plots the percent change of the charted symbol and the benchmark symbols in a new pane
public void PlotBenchMarkPct(string[] bmSymbols, Color[] colors, DateTime fromDate)
{
int bar = Bars.ConvertDateToBar(fromDate, false);
SetBackgroundColor(bar, Color.Pink);
ChartPane cp = CreatePane(60, true, true);
DrawLabel(cp, "Percent Change since " + fromDate.ToShortDateString(), Color.Navy);
int c = 0;
foreach (string sym in bmSymbols)
{
Bars bmBars = GetExternalSymbol(sym, true);
double refPrice = bmBars.Close[bar];
DataSeries dsPctChange = 100 * (bmBars.Close/refPrice - 1);
dsPctChange.Description = sym;
PlotSeries(cp, dsPctChange, colors[c], WealthLab.LineStyle.Solid, 2);
c++;
}

}
protected override void Execute()
{
// Show the percent change from a list of symbols from a specified date (1/1/2006)
string[] benchMarkSymbols = {Bars.Symbol, "MSFT", ".DJI", ".SPX"};
Color[] colors = {Color.Black, Color.Blue, Color.Red, Color.Green};
PlotBenchMarkPct(benchMarkSymbols, colors, new DateTime(2006, 1, 1));
}
}
}
```

## Another solution

```
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<DataSeries> rocList = new List<DataSeries>();

int StartBar = Math.Max( Bars.Count - 260, 0 );

foreach( string ds in DataSetSymbols )
{
DataSeries extClose = GetExternalSymbol( DataSetSymbols[DataSetSymbols.IndexOf(ds)], true ).Close;
rocList.Add( ( extClose - (extClose>>StartBar) ) / (extClose>>StartBar) * 100.0 );

}			HideVolume();
ChartPane rocPane = CreatePane( 100, true, true );
foreach( DataSeries ds in rocList )
PlotSeries( rocPane, rocList[rocList.IndexOf(ds)], RandomColor(), LineStyle.Solid, 1 );
}
}
}
```