Forex_Strategy_Builder.Ross_Hook.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)
        {
            double[] adRhUp = new double[Bars];
            double[] adRhDn = new double[Bars];

            for (int iBar = 5; iBar < Bars - 1; iBar++)
            {
                if (High[iBar] < High[iBar - 1])
                {
                    if (High[iBar - 3] < High[iBar - 1] && High[iBar - 2] < High[iBar - 1])
                        adRhUp[iBar + 1] = High[iBar - 1];
                }

                if (Low[iBar] > Low[iBar - 1])
                {
                    if (Low[iBar - 3] > Low[iBar - 1] && Low[iBar - 2] > Low[iBar - 1])
                        adRhDn[iBar + 1] = Low[iBar - 1];
                }
            }

            // Is visible
            for (int iBar = 5; iBar < Bars; iBar++)
            {
                if (adRhUp[iBar - 1] > 0 && adRhUp[iBar] == 0 && High[iBar - 1] < adRhUp[iBar - 1])
                    adRhUp[iBar] = adRhUp[iBar - 1];
                if (adRhDn[iBar - 1] > 0 && adRhDn[iBar] == 0 && Low[iBar - 1] > adRhDn[iBar - 1])
                    adRhDn[iBar] = adRhDn[iBar - 1];
            }

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

            Component[0]            = new IndicatorComp();
            Component[0].ChartType  = IndChartType.Level;
            Component[0].ChartColor	= Color.SpringGreen;
            Component[0].FirstBar	= 5;
            Component[0].Value	    = adRhUp;

            Component[1]            = new IndicatorComp();
            Component[1].ChartType  = IndChartType.Level;
            Component[1].ChartColor = Color.DarkRed;
            Component[1].FirstBar	= 5;
            Component[1].Value	    = adRhDn;

            // Sets the Component's type
            if (slotType == SlotTypes.Open)
            {
                if (IndParam.ListParam[0].Text == "Enter long at an Up Ross hook")
                {
                    Component[0].DataType = IndComponentType.OpenLongPrice;
                    Component[1].DataType = IndComponentType.OpenShortPrice;
                }
                else
                {
                    Component[0].DataType = IndComponentType.OpenShortPrice;
                    Component[1].DataType = IndComponentType.OpenLongPrice;
                }
                Component[0].CompName = "Up Ross hook";
                Component[1].CompName = "Down Ross hook";
            }
            else if (slotType == SlotTypes.Close)
            {
                if (IndParam.ListParam[0].Text == "Exit long at an Up Ross hook")
                {
                    Component[0].DataType = IndComponentType.CloseLongPrice;
                    Component[1].DataType = IndComponentType.CloseShortPrice;
                }
                else
                {
                    Component[0].DataType = IndComponentType.CloseShortPrice;
                    Component[1].DataType = IndComponentType.CloseLongPrice;
                }
                Component[0].CompName = "Up Ross hook";
                Component[1].CompName = "Down Ross hook";
            }

            return;
        }