This code is read on every tick, but I use a simple boolean flag to get it to only be printed once per range bar (on the first tick of the next range bar, the lines are removed).
if(FirstTickOfBar)
{
if(drawingProjectedEndPoints && BarsPeriod.Id == PeriodType.Range)
{
{
RemoveDrawObject(string.Format("high_{0}", CurrentBar-1));
RemoveDrawObject(string.Format("low_{0}", CurrentBar-1));
drawingProjectedEndPoints = false;
}
}
}
if(Bars.Period.Id == PeriodType.Range)
{
double currentRange = High[0] - Low[0];
if(currentRange == ((Bars.Period.Value*Instrument.MasterInstrument.TickSize) - Instrument.MasterInstrument.TickSize))
{
if(!drawingProjectedEndPoints)
{
DrawHorizontalLine(string.Format("high_{0}", CurrentBar), true, High[0] + 2*Instrument.MasterInstrument.TickSize, Color.FromKnownColor(KnownColor.DarkGoldenrod), DashStyle.Dot, 2);
DrawHorizontalLine(string.Format("low_{0}", CurrentBar), true, Low[0] - 2*Instrument.MasterInstrument.TickSize, Color.FromKnownColor(KnownColor.DarkGoldenrod), DashStyle.Dot, 2);
drawingProjectedEndPoints = true;
}
}
}

Comment