Replies

ninsonphilip2
25 Aug 2021, 16:31

RE: thank you very much

amusleh said:

Hi,

You can use this method to get the number of bars since last cross between two moving averages:

        private int GetNumberOfBarsFromLastCross(MovingAverage fastMa, MovingAverage slowMa)
        {
            var index = Bars.Count - 1;
            var barCount = 0;

            for (int iBarIndex = index; iBarIndex >= 1; iBarIndex--)
            {
                if ((fastMa.Result[iBarIndex] > slowMa.Result[iBarIndex] && fastMa.Result[iBarIndex - 1] <= slowMa.Result[iBarIndex - 1]) || (fastMa.Result[iBarIndex] < slowMa.Result[iBarIndex] && fastMa.Result[iBarIndex - 1] >= slowMa.Result[iBarIndex - 1]))
                {
                    break;
                }

                barCount++;
            }

            return barCount;
        }

 

 


@ninsonphilip2

ninsonphilip2
23 Aug 2021, 22:03

RE: I've been able to do it guys. Thanks

PanagiotisCharalampous said:

Hi ninsonphilip2,

Please share your source code so that we can help you further.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

 


@ninsonphilip2