I am trying to plot the 10 period SMA on a 50 tick chart along with the 10 period SMA for 150 tick bars on the same chart. I would like to see two SMA lines on the 50 tick chart. One line representing a 50 tick SMA and the other line representing the 150 tick SMA. I plan on adding more to this indicator once it is working so I need to create a multi-time frame indicator.
Here is my code which DOES plot the first dataseries correctly on the 50 tick chart. But the second dataseries (BarsInProgress == 1), does not plot.
I get a CS0103 error on the last line of code below:
"The name 'Plot1' does not exist in the current context"
Thanks in Advance for your help!
protectedoverridevoid Initialize()
{ // CHART TIME FRAME IS 50 TICKS
// ADD SECOND TIMEFRAME
Add(PeriodType.Tick, 150);
// ADD PLOTS FOR SMA LINES
Add(new Plot(Color.FromKnownColor(KnownColor.Yellow), PlotStyle.Line, "Plot0"));
Add(new Plot(Color.FromKnownColor(KnownColor.Magenta), PlotStyle.Line, "Plot1"));
CalculateOnBarClose = true;
Overlay = true;
}
protectedoverridevoid OnBarUpdate()
{
// Checks to ensure all Bars objects contain enough bars before beginning
if (CurrentBars[0] <= BarsRequired || CurrentBars[1] <= BarsRequired || CurrentBars[2] <= BarsRequired)
return;
// Checks if OnBarUpdate() is called from an update on the chart's 50 tick dataseries
if (BarsInProgress == 0)
{
double val_SMA = SMA(Close, r)[0];
Plot0.Set(SMA(Close, 10)[0]);
}
// Checks if OnBarUpdate() is called from an update on the second set of Bars (150 TICK)
if (BarsInProgress == 1)
{
double val_SMA = SMA(Close, r)[0];
Plot1.Set(SMA(Close, 10)[0]);
}
}
Comment