I am looking at the CurrentDayOHL indicator. Even though I might have 90 days of data on my chart I would like to only process data from yesterday and today.
Basically I want lines indicating the high and low of the prior day and today. This built in indicator has a stair step appearance for every low on the chart which is distracting.
Appreciate any help on this.
Thanks.
public class CurrentDayOHL : Indicator
{
private DateTime currentDate = Core.Globals.MinDate;
private double currentOpen = double.MinValue;
private double currentHigh = double.MinValue;
private double currentLow = double.MaxValue;
private DateTime lastDate = Core.Globals.MinDate;
private Data.SessionIterator sessionIterator;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionCurrentDayOHL;
Name = NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameCurrentDayOHL;
IsAutoScale = false;
DrawOnPricePanel = false;
IsOverlay = true;
IsSuspendedWhileInactive = true;
ShowLow = true;
ShowHigh = true;
ShowOpen = true;
BarsRequiredToPlot = 0;
AddPlot(new Stroke(Brushes.Goldenrod, DashStyleHelper.Dash, 2), PlotStyle.Square, NinjaTrader.Custom.Resource.CurrentDayOHLOpen);
AddPlot(new Stroke(Brushes.SeaGreen, DashStyleHelper.Dash, 2), PlotStyle.Square, NinjaTrader.Custom.Resource.CurrentDayOHLHigh);
AddPlot(new Stroke(Brushes.Red, DashStyleHelper.Dash, 2), PlotStyle.Square, NinjaTrader.Custom.Resource.CurrentDayOHLLow);
}
else if (State == State.Configure)
{
currentDate = Core.Globals.MinDate;
currentOpen = double.MinValue;
currentHigh = double.MinValue;
currentLow = double.MaxValue;
lastDate = Core.Globals.MinDate;
}
else if (State == State.DataLoaded)
{
sessionIterator = new SessionIterator(Bars);
}
else if (State == State.Historical)
{
if (!Bars.BarsType.IsIntraday)
{
Draw.TextFixed(this, "NinjaScriptInfo", Custom.Resource.CurrentDayOHLError, TextPosition.BottomRight);
Log(Custom.Resource.CurrentDayOHLError, LogLevel.Error);
}
}
}
protected override void OnBarUpdate()
{
if (!Bars.BarsType.IsIntraday) return;
lastDate = currentDate;
currentDate = sessionIterator.GetTradingDay(Time[0]);
if (lastDate != currentDate || currentOpen == double.MinValue)
{
currentOpen = Open[0];
currentHigh = High[0];
currentLow = Low[0];
}
currentHigh = Math.Max(currentHigh, High[0]);
currentLow = Math.Min(currentLow, Low[0]);
if (ShowOpen)
CurrentOpen[0] = currentOpen;
if (ShowHigh)
CurrentHigh[0] = currentHigh;
if (ShowLow)
CurrentLow[0] = currentLow;
}

Comment