protected override void OnBarUpdate()
        {
            // 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);
                snrRanges.Add(snrRange);
                snrRange = null;
            }

            // Calculate the number of bars ago for the start and end bars of the specified time range
            int startBarsAgo = Bars.GetBar(startDateTime);
            int endBarsAgo   = Bars.GetBar(endDateTime);

            /* Now that we have the start and end bars ago values for the specified time range we can calculate the highest high for this range
             *
             * Note: We add 1 to the period range for MAX and MIN to compensate for the difference between "period" logic and "bars ago" logic.
             * "Period" logic means exactly how many bars you want to check including the current bar.
             * "Bars ago" logic means how many bars we are going to go backwards. The current bar is not counted because on that bar we aren't going back any bars so it would be "bars ago = 0" */
            double highestHigh = MAX(High, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

            // Now that we have the start and end bars ago values for the specified time range we can calculate the lowest low for this range
            double lowestLow = MIN(Low, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

            // Set the plot values
            HighestHigh[0] = highestHigh;
            LowestLow[0]   = lowestLow;

            if (snrRange == null)
            {
                SupportResistanceLine rstLine = new SupportResistanceLine();
                rstLine.NewSupportResistanceLine(startBarsAgo, endBarsAgo, SupportResistanceType.Resistance, HighestHigh[0]);
                SupportResistanceLine sptLine = new SupportResistanceLine();
                sptLine.NewSupportResistanceLine(startBarsAgo, endBarsAgo, SupportResistanceType.Support, LowestLow[0]);
                snrRange = NewSupportResistanceRange(rstLine, sptLine);
            }
        }
        public SupportResistanceRange <SupportResistanceLine> NewSupportResistanceRange(SupportResistanceLine rstLine, SupportResistanceLine sptLine)
        {
            SupportResistanceRange <SupportResistanceLine> snrRange = new SupportResistanceRange <SupportResistanceLine>();

            snrRange.Resistance = rstLine;
            snrRange.Support    = sptLine;
            return(snrRange);
        }