Forex_Strategy_Builder.Exit_Hour.Calculate C# (CSharp) Метод

Calculate() публичный Метод

Calculates the indicator's components
public Calculate ( SlotTypes slotType ) : void
slotType SlotTypes
Результат void
        public override void Calculate(SlotTypes slotType)
        {
            // Reading the parameters
            int iExitHour = (int)IndParam.NumParam[0].Value;
            TimeSpan tsExitHour = new TimeSpan(iExitHour, 0, 0);

            // Calculation
            int iFirstBar = 1;
            double[] adBars = new double[Bars];

            // Calculation of the logic
            for (int iBar = iFirstBar; iBar < Bars; iBar++)
            {
                if (Time[iBar - 1].DayOfYear == Time[iBar].DayOfYear &&
                    Time[iBar - 1].TimeOfDay < tsExitHour &&
                    Time[iBar].TimeOfDay >= tsExitHour)
                    adBars[iBar - 1] = Close[iBar - 1];
                else if (Time[iBar - 1].DayOfYear != Time[iBar].DayOfYear &&
                    Time[iBar - 1].TimeOfDay < tsExitHour )
                    adBars[iBar - 1] = Close[iBar - 1];
                else
                    adBars[iBar] = 0;
            }

            // Check the last bar
            if(Time[Bars - 1].TimeOfDay.Add(new TimeSpan(0, (int)Period, 0)) == tsExitHour)
                adBars[Bars - 1] = Close[Bars - 1];

            // Saving the components
            Component = new IndicatorComp[1];

            Component[0] = new IndicatorComp();
            Component[0].CompName      = "Exit hour";
            Component[0].DataType      = IndComponentType.ClosePrice;
            Component[0].ChartType     = IndChartType.NoChart;
            Component[0].ShowInDynInfo = false;
            Component[0].FirstBar      = iFirstBar;
            Component[0].Value         = adBars;

            return;
        }