Forex_Strategy_Builder.Indicator.IndicatorCrossesAnotherIndicatorDownwardLogic C# (CSharp) Method

IndicatorCrossesAnotherIndicatorDownwardLogic() protected method

Returns signals for the logic rule "The Indicator crosses AnotherIndicator downward"
protected IndicatorCrossesAnotherIndicatorDownwardLogic ( int firstBar, int prvs, double adIndValue, double adAnotherIndValue, IndicatorComp &indCompLong, IndicatorComp &indCompShort ) : void
firstBar int
prvs int
adIndValue double
adAnotherIndValue double
indCompLong IndicatorComp
indCompShort IndicatorComp
return void
        protected void IndicatorCrossesAnotherIndicatorDownwardLogic(int firstBar, int prvs, double[] adIndValue, double[] adAnotherIndValue, ref IndicatorComp indCompLong, ref IndicatorComp indCompShort)
        {
            double sigma = Sigma();

            for (int bar = firstBar; bar < Bars; bar++)
            {
                int currBar = bar - prvs;
                int baseBar = currBar - 1;
                while (Math.Abs(adIndValue[baseBar] - adAnotherIndValue[baseBar]) < sigma && baseBar > firstBar)
                { baseBar--; }

                indCompLong.Value[bar]  = adIndValue[currBar] < adAnotherIndValue[currBar] - sigma && adIndValue[baseBar] > adAnotherIndValue[baseBar] + sigma ? 1 : 0;
                indCompShort.Value[bar] = adIndValue[currBar] > adAnotherIndValue[currBar] + sigma && adIndValue[baseBar] < adAnotherIndValue[baseBar] - sigma ? 1 : 0;
            }

            return;
        }