Forex_Strategy_Builder.Price_Move.Calculate C# (CSharp) Method

Calculate() public method

Calculates the indicator's components
public Calculate ( SlotTypes slotType ) : void
slotType SlotTypes
return void
        public override void Calculate(SlotTypes slotType)
        {
            // Reading the parameters
            BasePrice price   = (BasePrice)IndParam.ListParam[1].Index;
            double    dMargin = IndParam.NumParam[0].Value * Point;
            int       iPrvs   = IndParam.CheckParam[0].Checked ? 1 : 0;

            // TimeExecution
            if (price == BasePrice.Open && dMargin == 0)
                IndParam.ExecutionTime = ExecutionTime.AtBarOpening;
            else if (price == BasePrice.Close && dMargin == 0)
                IndParam.ExecutionTime = ExecutionTime.AtBarClosing;

            // Calculation
            double[] adBasePr = Price(price);
            double[] adUpBand = new double[Bars];
            double[] adDnBand = new double[Bars];

            int iFirstBar = 1 + iPrvs;

            for (int iBar = iFirstBar; iBar < Bars; iBar++)
            {
                adUpBand[iBar] = adBasePr[iBar - iPrvs] + dMargin;
                adDnBand[iBar] = adBasePr[iBar - iPrvs] - dMargin;
            }

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

            Component[0]           = new IndicatorComp();
            Component[0].CompName  = "Up Price";
            Component[0].ChartType = IndChartType.NoChart;
            Component[0].FirstBar  = iFirstBar;
            Component[0].Value     = adUpBand;

            Component[1]           = new IndicatorComp();
            Component[1].CompName  = "Down Price";
            Component[1].ChartType = IndChartType.NoChart;
            Component[1].FirstBar  = iFirstBar;
            Component[1].Value     = adDnBand;

            switch (IndParam.ListParam[0].Text)
            {
                case "Enter long after an upward move":
                    Component[0].DataType = IndComponentType.OpenLongPrice;
                    Component[1].DataType = IndComponentType.OpenShortPrice;
                    break;

                case "Enter long after a downward move":
                    Component[0].DataType = IndComponentType.OpenShortPrice;
                    Component[1].DataType = IndComponentType.OpenLongPrice;
                    break;

                default:
                    break;
            }

            return;
        }