Forex_Strategy_Builder.Indicator.IndicatorCrossesAnotherIndicatorUpwardLogic C# (CSharp) Method

IndicatorCrossesAnotherIndicatorUpwardLogic() protected method

Returns signals for the logic rule "The Indicator crosses AnotherIndicator upward"
protected IndicatorCrossesAnotherIndicatorUpwardLogic ( 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 IndicatorCrossesAnotherIndicatorUpwardLogic(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;
        }