コード例 #1
0
        private void ImportBarFile(JForexDataFiles file)
        {
            var          streamReader = new StreamReader(file.FilePath);
            var          streamWriter = new StreamWriter(file.FileTargetPath);
            const string dateFormat   = "yyyy.MM.dd HH:mm:ss";

            const char      fieldSplitter  = ',';
            IFormatProvider formatProvider = CultureInfo.InvariantCulture;
            int             bars           = 0;

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }
                    if (line.StartsWith("Time"))
                    {
                        continue; // Skips annotation line.
                    }
                    string[] data = line.Split(new[] { fieldSplitter });

                    DateTime time   = DateTime.ParseExact(data[0], dateFormat, formatProvider);
                    double   open   = StringToDouble(data[1]);
                    double   high   = StringToDouble(data[2]);
                    double   low    = StringToDouble(data[3]);
                    double   close  = StringToDouble(data[4]);
                    var      volume = (int)StringToDouble(data[5]);

                    if (volume > 0 &&
                        !(Math.Abs(open - high) < 0.000001 && Math.Abs(open - low) < 0.000001 &&
                          Math.Abs(open - close) < 0.000001))
                    {
                        streamWriter.WriteLine(
                            time.ToString("yyyy-MM-dd\tHH:mm") + "\t" +
                            open + "\t" +
                            high + "\t" +
                            low + "\t" +
                            close + "\t" +
                            volume
                            );
                        bars++;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamWriter.Close();
            streamReader.Close();
            SetInfoText(file.Symbol + " " + Data.DataPeriodToString((DataPeriods)file.Period) + " - " +
                        (Language.T("Bars")).ToLower() + ": " + bars + Environment.NewLine);
        }
コード例 #2
0
        private void ReadJForexFiles()
        {
            if (!Directory.Exists(TxbDataDirectory.Text))
            {
                return;
            }

            string[] dataFiles = Directory.GetFiles(TxbDataDirectory.Text);
            foreach (string filePath in dataFiles)
            {
                if (Path.GetExtension(filePath) != ".csv")
                {
                    continue;
                }
                var file = new JForexDataFiles(filePath, TxbDestFolder.Text);
                if (file.IsCorrect)
                {
                    _files.Add(file);
                }
            }
        }
コード例 #3
0
        private void ReadJForexFiles()
        {
            if (!Directory.Exists(TxbDataDirectory.Text))
                return;

            string[] dataFiles = Directory.GetFiles(TxbDataDirectory.Text);
            foreach (string filePath in dataFiles)
            {
                if (Path.GetExtension(filePath) != ".csv") continue;
                var file = new JForexDataFiles(filePath);
                if (file.IsCorrect)
                    _files.Add(file);
            }
        }
コード例 #4
0
        private void ImportTicks(JForexDataFiles file)
        {
            var streamReader = new StreamReader(file.FilePath);
            var outStream = new FileStream(file.FileTargetPath, FileMode.Create);
            var binaryWriter = new BinaryWriter(outStream);

            DateTime time = DateTime.MinValue;
            int volume = 0;
            var reccord = new List<double>();
            int count1MinBars = 1;
            int totalVolume = 0;

            string dateFormat = "#";
            char delimiter = '#';

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line != null && line.StartsWith("Time"))
                        continue; // Skips annotation line.
                    if (line != null)
                    {
                        if (delimiter == '#')
                            delimiter = FindDelimiter(line);

                        string[] data = line.Split(new[] { delimiter });

                        if (dateFormat == "#")
                            dateFormat = FindDateFormat(data[0]);

                        DateTime t = ParseDateWithoutSeconds(data[0], dateFormat);
                        var tickTime = new DateTime(t.Year, t.Month, t.Day, t.Hour, t.Minute, 0);
                        double bid = StringToDouble(data[2]);

                        if (tickTime.Minute != time.Minute || volume == 0)
                        {
                            if (volume > 0 && !IsWeekend(time))
                            {
                                FilterReccord(reccord);
                                SaveReccord(binaryWriter, time, volume, reccord);
                                count1MinBars++;
                            }

                            time = tickTime;
                            volume = 0;
                            reccord.Clear();
                            reccord.Add(bid);
                        }
                        else if (reccord.Count > 0 && Math.Abs(bid - reccord[reccord.Count - 1]) > 0.000001)
                        {
                            reccord.Add(bid);
                        }
                    }

                    volume++;
                    totalVolume++;
                }
                if (volume > 0 && !IsWeekend(time))
                {
                    FilterReccord(reccord);
                    SaveReccord(binaryWriter, time, volume, reccord);
                    count1MinBars++;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamReader.Close();
            binaryWriter.Close();
            outStream.Close();

            totalVolume--;
            count1MinBars--;

            SetInfoText(file.Symbol + " " + Language.T("Ticks") + " - " + (Language.T("Ticks")).ToLower() + ": " +
                        totalVolume + " - 1M " + (Language.T("Bars")).ToLower() + ": " + count1MinBars +
                        Environment.NewLine);
        }
コード例 #5
0
        private void ImportBarFile(JForexDataFiles file)
        {
            var streamReader = new StreamReader(file.FilePath);
            var streamWriter = new StreamWriter(file.FileTargetPath);
            string dateFormat = "#";
            char delimiter = '#';
            int bars = 0;

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line == null) continue;
                    if (line.StartsWith("Time"))
                        continue; // Skips annotation line.

                    if (delimiter == '#')
                        delimiter = FindDelimiter(line);

                    string[] data = line.Split(new[] {delimiter});

                    string timeInput = data.Length == 6 ? data[0] : data[0] + " " + data[1];

                    if (dateFormat == "#")
                        dateFormat = FindDateFormat(timeInput);

                    DateTime time = ParseDateWithoutSeconds(timeInput, dateFormat);
                    double open = StringToDouble(data[data.Length - 5]);
                    double high = StringToDouble(data[data.Length - 4]);
                    double low = StringToDouble(data[data.Length - 3]);
                    double close = StringToDouble(data[data.Length - 2]);
                    var volume = (int) StringToDouble(data[data.Length - 1]);

                    if (Math.Abs(open - high) < 0.000001 &&
                        Math.Abs(open - low) < 0.000001 &&
                        Math.Abs(open - close) < 0.000001) continue;

                    streamWriter.WriteLine(time.ToString("yyyy-MM-dd\tHH:mm") + "\t" +
                        open + "\t" + high + "\t" + low + "\t" + close + "\t" + volume);
                    bars++;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamWriter.Close();
            streamReader.Close();
            SetInfoText(file.Symbol + " " + Data.DataPeriodToString((DataPeriods) file.Period) + " - " +
                        (Language.T("Bars")).ToLower() + ": " + bars + Environment.NewLine);
        }
コード例 #6
0
        private void ImportTicks(JForexDataFiles file)
        {
            var streamReader = new StreamReader(file.FilePath);
            var outStream    = new FileStream(file.FileTargetPath, FileMode.Create);
            var binaryWriter = new BinaryWriter(outStream);

            DateTime time          = DateTime.MinValue;
            int      volume        = 0;
            var      reccord       = new List <double>();
            int      count1MinBars = 1;
            int      totalVolume   = 0;

            string dateFormat = "#";
            char   delimiter  = '#';

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line != null && line.StartsWith("Time"))
                    {
                        continue; // Skips annotation line.
                    }
                    if (line != null)
                    {
                        if (delimiter == '#')
                        {
                            delimiter = FindDelimiter(line);
                        }

                        string[] data = line.Split(new[] { delimiter });

                        if (dateFormat == "#")
                        {
                            dateFormat = FindDateFormat(data[0] + " " + data[1]);
                        }

                        DateTime t        = ParseDateWithoutSeconds(data[0] + " " + data[1], dateFormat);
                        var      tickTime = new DateTime(t.Year, t.Month, t.Day, t.Hour, t.Minute, 0);
                        double   bid      = StringToDouble(data[2]);

                        if (tickTime.Minute != time.Minute || volume == 0)
                        {
                            if (volume > 0 && !IsWeekend(time))
                            {
                                FilterReccord(reccord);
                                SaveReccord(binaryWriter, time, volume, reccord);
                                count1MinBars++;
                            }

                            time   = tickTime;
                            volume = 0;
                            reccord.Clear();
                            reccord.Add(bid);
                        }
                        else if (reccord.Count > 0 && Math.Abs(bid - reccord[reccord.Count - 1]) > 0.000001)
                        {
                            reccord.Add(bid);
                        }
                    }

                    volume++;
                    totalVolume++;
                }
                if (volume > 0 && !IsWeekend(time))
                {
                    FilterReccord(reccord);
                    SaveReccord(binaryWriter, time, volume, reccord);
                    count1MinBars++;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamReader.Close();
            binaryWriter.Close();
            outStream.Close();

            totalVolume--;
            count1MinBars--;

            SetInfoText(file.Symbol + " " + Language.T("Ticks") + " - " + (Language.T("Ticks")).ToLower() + ": " +
                        totalVolume + " - 1M " + (Language.T("Bars")).ToLower() + ": " + count1MinBars +
                        Environment.NewLine);
        }
コード例 #7
0
        private void ImportBarFile(JForexDataFiles file)
        {
            var    streamReader = new StreamReader(file.FilePath);
            var    streamWriter = new StreamWriter(file.FileTargetPath);
            string dateFormat   = "#";
            char   delimiter    = '#';
            int    bars         = 0;

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line == null)
                    {
                        continue;
                    }
                    if (line.StartsWith("Time"))
                    {
                        continue; // Skips annotation line.
                    }
                    if (delimiter == '#')
                    {
                        delimiter = FindDelimiter(line);
                    }

                    string[] data = line.Split(new[] { delimiter });

                    string timeInput = data.Length == 6 ? data[0] : data[0] + " " + data[1];

                    if (dateFormat == "#")
                    {
                        dateFormat = FindDateFormat(timeInput);
                    }


                    DateTime time   = ParseDateWithoutSeconds(timeInput, dateFormat);
                    double   open   = StringToDouble(data[data.Length - 5]);
                    double   high   = StringToDouble(data[data.Length - 4]);
                    double   low    = StringToDouble(data[data.Length - 3]);
                    double   close  = StringToDouble(data[data.Length - 2]);
                    var      volume = (int)StringToDouble(data[data.Length - 1]);

                    if (Math.Abs(open - high) < 0.000001 &&
                        Math.Abs(open - low) < 0.000001 &&
                        Math.Abs(open - close) < 0.000001)
                    {
                        continue;
                    }

                    streamWriter.WriteLine(time.ToString("yyyy-MM-dd\tHH:mm") + "\t" +
                                           open + "\t" + high + "\t" + low + "\t" + close + "\t" + volume);
                    bars++;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamWriter.Close();
            streamReader.Close();
            SetInfoText(file.Symbol + " " + Data.DataPeriodToString((DataPeriods)file.Period) + " - " +
                        (Language.T("Bars")).ToLower() + ": " + bars + Environment.NewLine);
        }
コード例 #8
0
        private void ImportBarFile(JForexDataFiles file)
        {
            var streamReader = new StreamReader(file.FilePath);
            var streamWriter = new StreamWriter(file.FileTargetPath);
            const string dateFormat = "yyyy.MM.dd HH:mm:ss";

            const char fieldSplitter = ',';
            IFormatProvider formatProvider = CultureInfo.InvariantCulture;
            int bars = 0;

            try
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    if (line == null) continue;
                    if (line.StartsWith("Time"))
                        continue; // Skips annotation line.
                    string[] data = line.Split(new[] {fieldSplitter});

                    DateTime time = DateTime.ParseExact(data[0], dateFormat, formatProvider);
                    double open = StringToDouble(data[1]);
                    double high = StringToDouble(data[2]);
                    double low = StringToDouble(data[3]);
                    double close = StringToDouble(data[4]);
                    var volume = (int) StringToDouble(data[5]);

                    if (volume > 0 &&
                        !(Math.Abs(open - high) < 0.000001 && Math.Abs(open - low) < 0.000001 &&
                          Math.Abs(open - close) < 0.000001))
                    {
                        streamWriter.WriteLine(
                            time.ToString("yyyy-MM-dd\tHH:mm") + "\t" +
                            open + "\t" +
                            high + "\t" +
                            low + "\t" +
                            close + "\t" +
                            volume
                            );
                        bars++;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }

            streamWriter.Close();
            streamReader.Close();
            SetInfoText(file.Symbol + " " + Data.DataPeriodToString((DataPeriods) file.Period) + " - " +
                        (Language.T("Bars")).ToLower() + ": " + bars + Environment.NewLine);
        }