Forex_Strategy_Builder.Instrument.SetDataStats C# (CSharp) Method

SetDataStats() private method

Calculate statistics for the loaded data.
private SetDataStats ( ) : void
return void
        void SetDataStats()
        {
            instrMinPrice = double.MaxValue;
            instrMaxPrice = double.MinValue;
            double maxHighLowPrice   = double.MinValue;
            double maxCloseOpenPrice = double.MinValue;
            double sumHighLow   = 0;
            double sumCloseOpen = 0;
            instrDaysOff = 0;
            double sumGap = 0;
            double instrMaxGap = double.MinValue;
            double gap;

            for (int bar = 1; bar < Bars; bar++)
            {
                if (High(bar) > instrMaxPrice)
                    instrMaxPrice = High(bar);

                if (Low(bar) < instrMinPrice)
                    instrMinPrice = Low(bar);

                if (Math.Abs(High(bar) - Low(bar)) > maxHighLowPrice)
                    maxHighLowPrice = Math.Abs(High(bar) - Low(bar));
                sumHighLow += Math.Abs(High(bar) - Low(bar));

                if (Math.Abs(Close(bar) - Open(bar)) > maxCloseOpenPrice)
                    maxCloseOpenPrice = Math.Abs(Close(bar) - Open(bar));
                sumCloseOpen += Math.Abs(Close(bar) - Open(bar));

                int dayDiff = (Time(bar) - Time(bar - 1)).Days;
                if (instrDaysOff < dayDiff)
                    instrDaysOff = dayDiff;

                gap = Math.Abs(Open(bar) - Close(bar - 1));
                sumGap += gap;
                if (instrMaxGap < gap)
                    instrMaxGap = gap;
            }

            maxHighLow       = (int)(maxHighLowPrice / Point);
            averageHighLow   = (int)(sumHighLow / (Bars * Point));
            maxCloseOpen     = (int)(maxCloseOpenPrice / Point);
            averageCloseOpen = (int)(sumCloseOpen / (Bars * Point));
            maxGap           = (int)(instrMaxGap / Point);
            averageGap       = (int)(sumGap / ((Bars - 1) * Point));

            return;
        }