public int ScoreNumberLineSlave(OpeningRangeCloses openingRangeClose, bool isClosingRangeComparison, int potentialScore, params NumberLineEvents[] scenario)
        {
            if (scenario.Count() != currentNumberLineEvents.Count ||
                isClosingRangeComparison && openingRangeClose != currentOpeningRangeClose ||
                !isClosingRangeComparison && openingRangeClose == currentOpeningRangeClose)
            {
                return(0);
            }
            else
            {
                for (int i = 0; i < scenario.Count(); i++)
                {
                    if (scenario[i] != currentNumberLineEvents[i])
                    {
                        return(0);
                    }
                }
            }

            return(potentialScore);
        }
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 0)
            {
                if (currentDate != sessionIterator.GetTradingDay(Time[0]))
                {
                    opening      = Open[0];
                    openingHigh  = High[0];
                    openingLow   = Low[0];
                    currentAUp   = openingHigh + (setACValues ? aSeries[0] : (TickSize * this.ATicks));
                    currentADown = openingLow - (setACValues ? aSeries[0] : (TickSize * this.ATicks));
                    currentCUp   = openingHigh + (setACValues ? cSeries[0] : (TickSize * this.CTicks));
                    currentCDown = openingLow - (setACValues ? cSeries[0] : (TickSize * this.CTicks));

                    MyOpen[0]   = opening;
                    OpenHigh[0] = openingHigh;
                    OpenLow[0]  = openingLow;
                    AUp[0]      = currentAUp;
                    ADown[0]    = currentADown;
                    CUp[0]      = currentCUp;
                    CDown[0]    = currentCDown;

                    currentDate      = sessionIterator.GetTradingDay(Time[0]);
                    aUpBreachedBar   = 0;
                    aUpSuccessBar    = 0;
                    aDownBreachedBar = 0;
                    aDownSuccessBar  = 0;
                    cUpBreachedBar   = 0;
                    cUpSuccessBar    = 0;
                    cDownBreachedBar = 0;
                    cDownSuccessBar  = 0;

                    MyOpen[0] = Open[0];

                    #region Pivot
                    priorDayHigh  = currentHigh;
                    priorDayLow   = currentLow;
                    priorDayClose = currentClose;

                    double pivotPrice         = (priorDayHigh + priorDayLow + priorDayClose) / 3;
                    double pivotHighLowMiddle = (priorDayHigh + priorDayLow) / 2;
                    double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                    pivotUpperBound = pivotPrice + pivotDifferential;
                    pivotLowerBound = pivotPrice - pivotDifferential;
                    PivotHigh[0]    = pivotUpperBound;
                    PivotLow[0]     = pivotLowerBound;

                    // Initilize the current day settings to the new days data
                    currentHigh  = High[0];
                    currentLow   = Low[0];
                    currentClose = Close[0];
                    #endregion

                    #region NumberLine
                    if (CurrentBars[2] > 36)
                    {
                        String numberLineText = String.Format("Outlook: {8}{1}NL: {0}{1}Days: {2}, {3}, {4}{1}Trend: {5}, {6}, {7}{1}Drop: {9}",
                                                              numberLineSeries[0].ToString("+#;-#;0"),
                                                              Environment.NewLine,
                                                              dayNumberLineSeries[2].ToString("+#;-#;0"),
                                                              dayNumberLineSeries[1].ToString("+#;-#;0"),
                                                              dayNumberLineSeries[0].ToString("+#;-#;0"),
                                                              numberLineSeries[2].ToString("+#;-#;0"),
                                                              numberLineSeries[1].ToString("+#;-#;0"),
                                                              numberLineSeries[0].ToString("+#;-#;0"),
                                                              Close[1] > PivotHigh[0] ? "Plus" : Close[1] < PivotLow[0] ? "Minus" : "Neutral",
                                                              numberLineDropOffScore.ToString("+#;-#;0"));

                        Draw.Text(this, String.Format("NumberLine_{0}", currentDate.ToShortDateString()), false, numberLineText, 5,
                                  priorDayLow, 10,
                                  textColor, textFont, TextAlignment.Justify, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion
                }
                else
                {
                    MyOpen[0]   = opening;
                    OpenHigh[0] = openingHigh;
                    OpenLow[0]  = openingLow;
                    AUp[0]      = currentAUp;
                    ADown[0]    = currentADown;
                    CUp[0]      = currentCUp;
                    CDown[0]    = currentCDown;

                    #region Pivot
                    currentHigh  = Math.Max(currentHigh, High[0]);
                    currentLow   = Math.Min(currentLow, Low[0]);
                    currentClose = Close[0];

                    DateTime projectTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, this.ProjectHour, this.ProjectMinute, 0);

                    if (Time[0] >= projectTime)
                    {
                        double pivotPrice         = (currentHigh + currentLow + currentClose) / 3;
                        double pivotHighLowMiddle = (currentHigh + currentLow) / 2;
                        double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                        PivotHigh[0] = pivotPrice + pivotDifferential;
                        PivotLow[0]  = pivotPrice - pivotDifferential;
                    }
                    else
                    {
                        PivotHigh[0] = pivotUpperBound;
                        PivotLow[0]  = pivotLowerBound;
                    }
                    #endregion

                    #region NumberLine
                    AddNumberLineEvents(currentNumberLineEvents,
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.AUpBreached, aUpBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.AUpSuccess, aUpSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.ADownBreached, aDownBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.ADownSuccess, aDownSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CUpBreached, cUpBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CUpSuccess, cUpSuccessBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CDownBreached, cDownBreachedBar > 0),
                                        new KeyValuePair <NumberLineEvents, bool>(NumberLineEvents.CDownSuccess, cDownSuccessBar > 0));

                    currentOpeningRangeClose = GetOpeningRangeClose(Close[0]);

                    if (CurrentBars[2] > 36)
                    {
                        double tempNumberLineScore = ScoreNumberLineMaster();

                        //PrintValues(numberLineSeries[0], tempNumberLineSum, tempNumberLineScore);

                        String numberLineText = String.Format("Drop: {1}{0}Add: {2}{0}Proj: {3}{0}OR: {4}{0}",
                                                              Environment.NewLine,
                                                              numberLineDropOffScore.ToString("+#;-#;0"),
                                                              tempNumberLineScore.ToString("+#;-#;0"),
                                                              (numberLineMinusOneSum + tempNumberLineScore).ToString("+#;-#;0"),
                                                              (Math.Abs(openingHigh - openingLow).ToString("C")));

                        Draw.TextFixed(this, "numberLineToday", numberLineText, textPosition: TextPosition.BottomRight);
                    }
                    #endregion
                }

                RollingPivotHigh[0] = rollingPivotUpperBound;
                RollingPivotLow[0]  = rollingPivotLowerBound;

                if (!String.IsNullOrEmpty(redrawTag) && !String.IsNullOrEmpty(redrawText))
                {
                    bool isUp = redrawTag.StartsWith("Up_");

                    Draw.Text(this, redrawTag, false, redrawText, 0,
                              isUp ? Math.Max(High[0], High[1]) : Math.Min(Low[0], Low[1]),
                              isUp ? 20 : -10,
                              textColor, textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);

                    redrawTag  = String.Empty;
                    redrawText = String.Empty;
                }
            }
            else if (BarsInProgress == 1)
            {
                fastPivotPriceSeries[0] = (High[0] + Low[0] + Close[0]) / 3;

                if (fastCurrentDate != sessionIterator.GetTradingDay(Time[0]))
                {
                    fastCurrentDate = sessionIterator.GetTradingDay(Time[0]);
                    fastCurrentBar  = 1;
                }
                else
                {
                    fastCurrentBar += 1;
                }

                if (fastCurrentBar >= openingBars)
                {
                    #region A Up
                    if (aUpBreachedBar == 0 && aDownSuccessBar == 0 && fastPivotPriceSeries[0] > currentAUp)
                    {
                        aUpBreachedBar = CurrentBar;
                    }

                    if (aUpBreachedBar > 0 &&
                        aUpSuccessBar == 0 &&
                        aDownSuccessBar == 0 &&
                        (CurrentBar - aUpBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] > currentAUp, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        aUpSuccessBar = CurrentBar;

                        redrawTag  = "Up_" + currentDate.ToShortDateString();
                        redrawText = " A Up ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Highs[0][0], 50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region A Down
                    if (aDownBreachedBar == 0 && aUpSuccessBar == 0 && fastPivotPriceSeries[0] < currentADown)
                    {
                        aDownBreachedBar = CurrentBars[0];
                    }

                    if (aDownBreachedBar > 0 &&
                        aUpSuccessBar == 0 &&
                        aDownSuccessBar == 0 &&
                        (CurrentBar - aDownBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] < currentADown, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        aDownSuccessBar = CurrentBars[0];

                        redrawTag  = "Down_" + currentDate.ToShortDateString();
                        redrawText = " A Down ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Lows[0][0], -50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region C Up
                    if (aDownSuccessBar > 0 && cUpBreachedBar == 0 && cDownSuccessBar == 0 && fastPivotPriceSeries[0] > currentCUp)
                    {
                        cUpBreachedBar = CurrentBar;
                    }

                    if (cUpBreachedBar > 0 &&
                        cUpSuccessBar == 0 &&
                        cDownSuccessBar == 0 &&
                        (CurrentBar - cUpBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] > currentCUp, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        cUpSuccessBar = CurrentBar;

                        redrawTag  = "Up_" + currentDate.ToShortDateString();
                        redrawText = " C Up ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Highs[0][0], 50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion

                    #region C Down
                    if (aUpSuccessBar > 0 && cDownBreachedBar == 0 && cUpSuccessBar == 0 && fastPivotPriceSeries[0] < currentCDown)
                    {
                        cDownBreachedBar = CurrentBar;
                    }

                    if (cDownBreachedBar > 0 &&
                        cDownSuccessBar == 0 &&
                        cUpSuccessBar == 0 &&
                        (CurrentBar - cDownBreachedBar) >= halfTimeFrameBars &&
                        CountIf(() => fastPivotPriceSeries[0] < currentCDown, halfTimeFrameBars) >= halfTimeFrameBars)
                    {
                        cDownSuccessBar = CurrentBar;

                        redrawTag  = "Down_" + currentDate.ToShortDateString();
                        redrawText = " C Down ";

                        Draw.Text(this, redrawTag, false, redrawText, 0, Lows[0][0], -50, textColor,
                                  textFont, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
                    }
                    #endregion
                }
            }
            else if (BarsInProgress == 2 && CurrentBar > 3)
            {
                double high = MAX(High, 3)[0];
                double low  = MAX(High, 3)[0];

                double pivotPrice         = (high + low + Close[0]) / 3;
                double pivotHighLowMiddle = (high + low) / 2;
                double pivotDifferential  = Math.Abs(pivotPrice - pivotHighLowMiddle);
                rollingPivotUpperBound = pivotPrice + pivotDifferential;
                rollingPivotLowerBound = pivotPrice - pivotDifferential;

                trueRangeSeries[0] = (new List <double>()
                {
                    High[0] - Low[0], Math.Abs(High[0] - Close[0]), Math.Abs(Low[0] - Close[0])
                }).Max();

                if (CurrentBar > 35)
                {
                    List <double> trueRangeFactors = new List <double>();
                    for (int i = 10; i <= 30; i++)
                    {
                        trueRangeFactors.Add(SUM(trueRangeSeries, i)[0] / i);
                    }

                    double firstValue = trueRangeFactors.Average();
                    aSeries[0]  = this.Instrument.MasterInstrument.RoundToTickSize(.1 * (firstValue / 2));
                    cSeries[0]  = this.Instrument.MasterInstrument.RoundToTickSize(.15 * (firstValue / 2));
                    setACValues = true;
                }

                currentOpeningRangeClose = GetOpeningRangeClose(Close[0]);
                dayNumberLineSeries[0]   = ScoreNumberLineMaster();
                numberLineSeries[0]      = SUM(dayNumberLineSeries, 30)[0];
                numberLineMinusOneSum    = SUM(dayNumberLineSeries, 29)[0];

                try
                {
                    numberLineDropOffScore = dayNumberLineSeries[29];
                }
                catch { }

                currentNumberLineEvents  = new List <NumberLineEvents>();
                currentOpeningRangeClose = OpeningRangeCloses.None;

                //RollingPivotHigh[0] = rollingPivotUpperBound;
                //RollingPivotLow[0] = rollingPivotLowerBound;
                //Draw.TextFixed(this, "tag1", String.Format("Text to draw{0}Yo", Environment.NewLine), textPosition: TextPosition.BottomRight);
            }
        }