I have a couple of questions. First, how do I do computations on added data series? For example, in this sample I'm adding the VIX and VIX9D indices as additional data types
OnStateChange()
{
if (State == State.SetDefaults)
{
...
AddPlot(Brushes.White, "VIX9DtoVIXDiff");
}
...
else if (State == State.Configure)
{
AddDataSeries("^VIX9D", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
AddDataSeries("^VIX", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
}
OnBarUpdate()
{
...
VIX9DtoVIXDiff[0] = current bar ^VIX9D minus current bar ^VIX
}
To keep things simple, assume the main instrument is also a daily bar. I understand and am familiar with BarsInProgress etc., just looking for the syntax for accessing the data for the added series. Should it be simply using Closes[1][0] and Closes[2][0], or do I need something more elaborate like using BarsArray[] in some form or another?
Second question, how do I add data series using the current BarsPeriodType, i.e. what is the syntax? For instance if I switch to an hourly chart I would want VIX and VIX9D to automatically be in the same format and not as daily types.
Thanks.
Comment