I need an indicator, which looks like one in enclosed image - there is a red/yellow/green zone. The zones are just bunch of horizontal lines.
Values of the lines are computed parameters passed to the indicator.
I tried to create new Line objects during Initialize(). This approach works, however the lines are fixed - if I'm changing values of parameters, it seems Initialize() is not called, the lin values remain, but are not relevant anymore.
Therefore I tried to using DrawHorizontalLine() in OnBarUpdate() . I tried to ensure it's done only once e.g.
if (CurrentBar == 5)
{
for (i=y1 to y2)
{
strL = "Line" + i.ToString() ;
// Add(new Line(new Pen(Color.Red,3), i, strL));
DrawHorizontalLine(strL, true, i, Color.Red, DashStyle.Solid , 4) ;
}
for (i=y3 to y4)
{
strL = "Line" + i.ToString() ;
// Add(new Line(new Pen(Color.Yellow,3), i, strL));
DrawHorizontalLine(strL, true, i, Color.Yellow, DashStyle.Solid , 4) ;
}
for (i=y5 to y6)
{
strL = "Line" + i.ToString() ;
// Add(new Line(new Pen(Color.Green,3), i, strL));
DrawHorizontalLine(strL, true, i, Color.Green, DashStyle.Solid , 4) ;
}
This time NinjaTrader enters indefinite loop with 100% CPU utilization.
}
It seems, it's possible to use DrawRegion() , but I understand that in order to achieve the effect as in attached image, I should create 3 dummy data series and feed them with constant values in every bar. This approach seems to be resource consuming and I suspect there will be the same problem as described above with horizontal line, because I need to ensure DrawRegion is called only once in a particular bar.
Did I misunderstand something ? Any other solution ? Thanks.
Comment