Problem: Here is the strange bit. If I roll the chart forward (to the right) where the diamond is off past the left edge and press f5 the panel displays fine. The panel displays correctly. If I scroll the chart back (to the left) to the point where the diamond is displayed on the chart the plot in the entire panel disappears (except my vertical line) even the part that was displayed correctly. I didn't press f5 just rolled the chart using the thumb bar. I have Print statements in my code for debug purposes so my code was not executed again according to the output window after the initial display or the scroll back.
I would say it is a bug in my code but can't see how if the chart displays correctly and only when I scroll back (left) to the reset point the panel plot disappears. This one has me scratching my head. It is repeatable and does it every time.
Here is a code snippet:
private string resetName = "reset";
Add(new Plot(new Pen(Color.Green, 2), PlotStyle.Bar, "Value"));
Add(new Line(Color.Indigo, 0, "Zero line"));
// Only do this for the chart time frame not any added time frames
if (BarsInProgress == 0)
{
// Does a diamond draw object of the requested name exist on the chart and only do this once
if (DrawObjects[resetName] != null && DrawObjects[resetName].DrawType == DrawType.Diamond && !ResetDone)
{
ResetBars = 0;
// Get the diamond attributes
IDiamond Diamond = (IDiamond)DrawObjects[resetName];
// If you found it
if (Diamond != null)
{
Find out the bar number to perform the reset at
ResetBars = Diamond.BarsAgo;
// Get the color of the drawn diamond to use for the same color of the vertical line
DiamondColor = Diamond.Color;
}
// If you have a reset bar and that was drawn on the current bar or lower and you have not reset the counters before
if (ResetBars >= 0 && Times[BarsInProgress][0] >= Time[ResetBars] && !ResetDone)
{
// Reset the counters
Print("1.6 reset Processed " + Time [0] + " " + Times[BarsInProgress][0]);
// Don't do this code again (only once per f5 or initial display)
ResetDone = true;
// Debug code
Print("1.7 reset done " + Times[BarsInProgress][0] + " ResetBars " + ResetBars + " CurrentBar " + CurrentBar + " --------------------------------");
// Reset counters code here
}
// Draw a vertical on the chart of the same color as the diamond to show a reset was performed here
DrawVerticalLine(resetName + "_vl", 0, DiamondColor, DashStyle.Solid, 1);
}
I set the only plot using:
Values[0].Set(PlotValue);
Happy to send screen shorts.
Comment