I tried to do it in OnBarUpdate.
Works well only for DrawHorizontalLine(). DrawLine draws nothing.
#region Variables
// Wizard generated variables
private int barsBack = 5; // Default setting for BarsBack
private int barsForw = 0; // Default setting for BarsForw
// User defined variables (add any user defined variables below)
private double nextOpenHigh = 0;
private double nextOpenLow = 0;
private bool isRangeDerivate = false;
private bool rangeDerivateChecked = false;
#endregion
protected override void OnBarUpdate()
{
if (false == rangeDerivateChecked)
{
if (ChartControl == null || ChartControl.Bars == null || ChartControl.Bars.Length == 0)
return;
if (Data.BarsType.GetInstance(ChartControl.Bars[0].Period.Id).BuiltFrom == Data.PeriodType.Tick && ChartControl.Bars[0].Period.ToString().IndexOf("Range") >= 0)
isRangeDerivate = true;
rangeDerivateChecked = true;
}
if(false == isRangeDerivate) return;
// Cenu open zjistime jako low + hodnota RB v ticich + 1 tick navic nebo analogicky pro high
nextOpenHigh = Low[0] + (Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize) + ((Displacement+1) * Bars.Instrument.MasterInstrument.TickSize);
nextOpenLow = High[0] - (Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize) - ((Displacement+1) * Bars.Instrument.MasterInstrument.TickSize);
int actualRange = (int) Math.Round(Math.Max(Close[0] - Low[0], High[0] - Close[0]) / Bars.Instrument.MasterInstrument.TickSize);
int rangeCount = Bars.Period.Value - actualRange;
// THIS DOESN'T WORK AT ALL, BUT IS DESIRED TO. I need only short line near last bar, not across all display
// DrawLine("highOpen",barsBack,nextOpenHigh,barsForw,nextOpenHigh,Color.Green,DashStyle.Solid,1);
// DrawLine("lowOpen",barsBack,nextOpenLow,barsForw,nextOpenLow,Color.Red,DashStyle.Dash,1);
//THIS WORKS WELL, BUT DRAW LINE ACROSS ALL DISPLAY.
DrawHorizontalLine("highOpen",nextOpenHigh,Color.Green,DashStyle.Dot,1);
DrawHorizontalLine("lowOpen",nextOpenLow,Color.Red,DashStyle.Dash,1);
}
Thanks a lot.

Comment