It finds different values when run in real time or Replay versus using F5 key.
The F5 behavior is the "correct" behavior. I believe.
The real time/replay does not include the last bar of the range properly.
What am I missing to correct this?
Thanks
==============
/ Check to make sure the end time is not earlier than the start time
if (EndHour < StartHour)
return;
//Do not calculate the high or low value when the ending time of the desired range is less than the current time of the bar being processed
if (ToTime(EndHour, EndMinute, 0) > ToTime(Time[0]))
return;
// If the stored date time date is not the same date as the bar time date, create a new DateTime object
if (startDateTime.Date != Time[0].Date)
{
startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);
endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);
}
// Calculate the number of bars ago for the start and end bars of the specified time range
int startBarsAgo = GetBar(startDateTime);
int endBarsAgo = GetBar(endDateTime);
// Now that we have the start end end bars ago values for the specified time range we can calculate the highest high for this range
double highestHigh = MAX(High, startBarsAgo - endBarsAgo)[endBarsAgo];
// Now that we have the start end end bars ago values for the specified time range we can calculate the lowest low for this range
double lowestLow = MIN(Low, startBarsAgo - endBarsAgo)[endBarsAgo];
// Set the plot values
HighestHigh.Set(highestHigh);
LowestLow.Set(lowestLow);
Comment