public bool GetRangeCenter(int numberSteps, ref Fluctuation fluctuation)
        {
            if (numberSteps >= TralOpensHistoryList.Count)
            {
                return(false);
            }

            int lastValue = FlagUP ? Min : Max;
            int min       = lastValue;
            int max       = lastValue;

            int firstIndex = TralOpensHistoryList.Count - 1;
            int lastIndex  = firstIndex - numberSteps;

            for (int i = firstIndex; i > lastIndex; i--)
            {
                lastValue -= TralOpensHistoryList[i];

                if (lastValue < min)
                {
                    min = lastValue;
                }
                if (lastValue > max)
                {
                    max = lastValue;
                }
            }

            fluctuation.AveragePrice            = (min + max) / 2;
            fluctuation.PeakDistanceFromAverage = (max - min) / 2;

            return(true);
        }
Exemplo n.º 2
0
        public FluctuationCollection(int start, int end)
        {
            this.StartIndex = start;
            this.EndIndex   = end;

            FluctuationList = new Fluctuation[EndIndex];
            for (int i = StartIndex; i < EndIndex; i++)
            {
                FluctuationList[i] = new Fluctuation(0, 0);
            }
        }