Forex_Strategy_Builder.Scanner.LoadTickData C# (CSharp) Method

LoadTickData() private method

Loads available tick data.
private LoadTickData ( ) : void
return void
        void LoadTickData()
        {
            FileStream   fileStream   = new FileStream(Data.OfflineDataDir + Data.Symbol + "0.bin", FileMode.Open);
            BinaryReader binaryReader = new BinaryReader(fileStream);
            Data.TickData = new double[Data.Bars][];
            int bar = 0;

            long totalVolume = 0;
            int  min1Bars    = 0;

            long pos    = 0;
            long length = binaryReader.BaseStream.Length;
            while (pos < length)
            {
                DateTime time = DateTime.FromBinary(binaryReader.ReadInt64());
                pos += sizeof(Int64);

                int volume = binaryReader.ReadInt32();
                pos += sizeof(Int32);

                int count = binaryReader.ReadInt32();
                pos += sizeof(Int32);

                double[] bid = new double[count];
                for (int i = 0; i < count; i++)
                    bid[i] = binaryReader.ReadDouble();
                pos += count * sizeof(Double);

                while (bar < Data.Bars - 1 && Data.Time[bar] < time)
                {
                    if (time < Data.Time[bar + 1])
                        break;
                    bar++;
                }

                if (time == Data.Time[bar])
                {
                    Data.TickData[bar] = bid;
                }
                else if ((bar < Data.Bars - 1 && time > Data.Time[bar] && time < Data.Time[bar + 1]) || bar == Data.Bars - 1)
                {
                    if (Data.TickData[bar] == null && (Math.Abs(Data.Open[bar] - bid[0]) < 10 * Data.InstrProperties.Pip))
                        Data.TickData[bar] = bid;
                    else
                        AddTickData(bar, bid);
                }

                totalVolume += volume;
                min1Bars++;
            }

            binaryReader.Close();
            fileStream.Close();

            Data.IsTickData = false;
            int barsWithTicks = 0;
            for (int b = 0; b < Data.Bars; b++)
                if (Data.TickData[b] != null)
                    barsWithTicks++;

            if (barsWithTicks > 0)
            {
                Data.Ticks = totalVolume;
                Data.IsTickData = true;
            }
        }