public override bool LoadData(string rootFolder, StockSerie stockSerie)
        {
            string archiveFileName = rootFolder + ARCHIVE_FOLDER + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt";
             if (File.Exists(archiveFileName))
             {
            stockSerie.ReadFromCSVFile(archiveFileName);
             }

             string fileName = rootFolder + INTRADAY_FOLDER + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt";

             if (File.Exists(fileName))
             {
            if (ParseIntradayData(stockSerie, fileName))
            {
               stockSerie.Values.Last().IsComplete = false;
               var lastDate = stockSerie.Keys.Last();

               DateTime firstArchiveDate = lastDate.AddMonths(-2).AddDays(-lastDate.Day + 1).Date;

               stockSerie.SaveToCSVFromDateToDate(archiveFileName, firstArchiveDate, lastDate.AddDays(-5).Date);

               // Archive other time frames
               string durationFileName;
               StockSerie.StockBarDuration previousDuration = stockSerie.BarDuration;
               foreach (StockSerie.StockBarDuration duration in cacheDurations)
               {
                  durationFileName = rootFolder + ARCHIVE_FOLDER + "\\" + duration + "\\" + stockSerie.ShortName.Replace(':', '_') + "_" + stockSerie.StockName + "_" + stockSerie.StockGroup.ToString() + ".txt";

                  if (File.Exists(durationFileName) &&
                      File.GetLastWriteTime(durationFileName).Date == DateTime.Today.Date) break; // Only cache once a day.
                  stockSerie.BarDuration = duration;
                  stockSerie.SaveToCSVFromDateToDate(durationFileName, stockSerie.Keys.First(), lastDate.AddDays(-1).Date);
               }

               // Set back to previous duration.
                if (previousDuration != stockSerie.BarDuration)
                {
                    stockSerie.BarDuration = previousDuration;
                }
            }
            else
            {
               return false;
            }
             }
             return true;
        }
        public override bool LoadIntradayDurationArchiveData(string rootFolder, StockSerie serie, StockSerie.StockBarDuration duration)
        {
            StockLog.Write("LoadIntradayDurationArchiveData Name:" + serie.StockName + " duration:" + duration);
             string durationFileName = rootFolder + ARCHIVE_FOLDER + "\\" + duration + "\\" + serie.ShortName.Replace(':', '_') + "_" + serie.StockName + "_" + serie.StockGroup.ToString() + ".txt";
             if (File.Exists(durationFileName))
             {
            var values = serie.GetValues(duration);
            if (values == null)
               StockLog.Write("LoadIntradayDurationArchiveData Cache File Found, current size is: 0");
            else  StockLog.Write("LoadIntradayDurationArchiveData Cache File Found, current size is: " + values.Count);
            serie.ReadFromCSVFile(durationFileName, duration);

            StockLog.Write("LoadIntradayDurationArchiveData New serie size is: " + serie.GetValues(duration).Count);
            if (serie.GetValues(duration).Count > 0)
            {
               StockLog.Write("LoadIntradayDurationArchiveData First bar: " +
                              serie.GetValues(duration).First().ToString());
               StockLog.Write("LoadIntradayDurationArchiveData Last bar: " + serie.GetValues(duration).Last().ToString());
            }
            else
            {
               return false;
            }
             }
             else
             {
            return false;
             }
             return true;
        }
 public override bool LoadIntradayDurationArchiveData(string rootFolder, StockSerie serie,
  StockSerie.StockBarDuration duration)
 {
     string durationFileName = rootFolder + ARCHIVE_FOLDER + "\\" + duration + "\\" +
                            serie.ShortName.Replace(':', '_') + "_" + serie.StockName + "_" +
                            serie.StockGroup.ToString() + ".txt";
      if (File.Exists(durationFileName))
      {
     serie.ReadFromCSVFile(durationFileName, duration);
      }
      else
      {
     return false;
      }
      return true;
 }