I have a strang problem with plotting. I created an indicator, wich 'digitaly' plots values (a MACD with standard Deviation). When the MacdLine is over the StdDev of Macdline, there should be a green plot. Under the -StdDev it should be red and between, it shoukld be gray. So far - so good.
This Indicator runs in a 1 min Chart an calculates the values of this indicator in a 3min chart. This works fine. But if I add a second series (5min), the plot of the 5min will be fine and the plot of the 3 min has random gaps..... (see picture)
Here is my code:
protected override void Initialize()
{
MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
Add(PeriodType.Minute, 3); // BarsArray[1] = 3min
Add(PeriodType.Minute, 5); // BarsArray[2] = 5min
Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Dot, "Up3min"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Down3min"));
Add(new Plot(Color.FromKnownColor(KnownColor.ControlDark), PlotStyle.Dot, "Neutral3Min"));
Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Dot, "Up5min"));
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Down5min"));
Add(new Plot(Color.FromKnownColor(KnownColor.ControlDark), PlotStyle.Dot, "Neutral5Min"));
Overlay = false;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if(CurrentBars[2] < 19) return;
if(MacdBBSimple(BarsArray[1], Length, Length, 1,Length * 2).MacdLine[0] > MacdBBSimple(BarsArray[1], Length,Length, 1,Length * 2).UpperBand[0])
Up3min.Set(-3);
else if(MacdBBSimple(BarsArray[1],Length, Length, 1,Length * 2).MacdLine[0] < MacdBBSimple(BarsArray[1],Length, Length, 1,Length * 2).LowerBand[0])
Down3min.Set(-3);
else
Neutral3Min.Set(-3);
if(MacdBBSimple(BarsArray[2], Length, Length, 1,Length * 2).MacdLine[0] > MacdBBSimple(BarsArray[2], Length,Length, 1,Length * 2).UpperBand[0])
Up3min.Set(-5);
else if(MacdBBSimple(BarsArray[2],Length, Length, 1,Length * 2).MacdLine[0] < MacdBBSimple(BarsArray[2],Length, Length, 1,Length * 2).LowerBand[0])
Down3min.Set(-5);
else
Neutral3Min.Set(-5);
}
Jens

Comment