/// <summary> /// Saves a snapshot of the current chart. /// </summary> /// <param name="Indicator"></param> /// <param name="InstrumentName"></param> /// <param name="Chart"></param> /// <param name="Bars"></param> /// <param name="TimeFrame"></param> public static void SaveSnapShot(string Indicator, String InstrumentName, IEnumerable <IChart> AllCharts, IBars Bars, ITimeFrame TimeFrame) { string filepart = GlobalUtilities.CleanFileName(Indicator + "_" + TimeFrame.PeriodicityValue + TimeFrame.Periodicity + "_" + InstrumentName + "_" + DateTime.Now.ToString("yyyy_MM_dd_HH_mm")); string directory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\Auswertung\\SnapShot\\" + filepart + "\\"; System.IO.Directory.CreateDirectory(directory); string fileName = InstrumentName + "_" + TimeFrame.PeriodicityValue + TimeFrame.Periodicity + "_" + Bars[0].Time.ToString("yyyy_MM_dd_HH_mm") + ".jpg"; fileName = GlobalUtilities.CleanFileName(fileName); //take 20 Bars to future and 20 Bars from the past (but only if they exist, if not, just take first or last) DateTime ChartStart = DateTime.MinValue; DateTime ChartEnd = DateTime.MinValue; if (Bars.GetByIndex(Bars.GetIndex(Bars[0]) + 20) != null) { ChartEnd = Bars.GetByIndex(Bars.GetIndex(Bars[0]) + 20).Time; } else { ChartEnd = Bars.Last().Time; } if (Bars.GetByIndex(Bars.GetIndex(Bars[0]) - 20) != null) { ChartStart = Bars.GetByIndex(Bars.GetIndex(Bars[0]) - 20).Time; } else { ChartStart = Bars.First().Time; } //pick the right chart matching the current timeframe foreach (IChart chart in AllCharts) { if (chart.HistoryRequest.TimeFrame.Periodicity == TimeFrame.Periodicity && chart.HistoryRequest.TimeFrame.PeriodicityValue == TimeFrame.PeriodicityValue) { chart.SetDateRange(ChartStart, ChartEnd); chart.SaveChart(directory + fileName); } } }