/// <summary> /// Exports the bar summary /// </summary> public void ExportBarSummary() { string stage = String.Empty; if (Data.IsProgramBeta) { stage = " " + Language.T("Beta"); } else if (Data.IsProgramRC) { stage = " " + "RC"; } sb.Append("Forex Strategy Builder v" + Data.ProgramVersion + stage + Environment.NewLine); sb.Append("Strategy name: " + Data.Strategy.StrategyName + Environment.NewLine); sb.Append("Exported on " + DateTime.Now.ToString() + Environment.NewLine); sb.Append(Data.Symbol + " " + Data.PeriodString + "; Values in pips" + Environment.NewLine); sb.Append("Bar Numb\t"); sb.Append("Date\t"); sb.Append("Hour\t"); sb.Append("Open\t"); sb.Append("High\t"); sb.Append("Low\t"); sb.Append("Close\t"); sb.Append("Volume\t"); sb.Append("Direction\t"); sb.Append("Lots\t"); sb.Append("Transaction\t"); sb.Append("Price\t"); sb.Append("Profit Loss\t"); sb.Append("Floating P/L\t"); sb.Append("Spread\t"); sb.Append("Rollover\t"); sb.Append("Balance\t"); sb.Append("Equity\t"); sb.Append("Interpolation" + Environment.NewLine); for (int bar = 0; bar < Data.Bars; bar++) { sb.Append((bar + 1).ToString() + "\t"); sb.Append(Data.Time[bar].ToString(sDF) + "\t"); sb.Append(Data.Time[bar].ToString("HH:mm") + "\t"); sb.Append(Data.Open[bar].ToString(FF) + "\t"); sb.Append(Data.High[bar].ToString(FF) + "\t"); sb.Append(Data.Low[bar].ToString(FF) + "\t"); sb.Append(Data.Close[bar].ToString(FF) + "\t"); sb.Append(Data.Volume[bar].ToString() + "\t"); if (Backtester.IsPos(bar)) { sb.Append(Backtester.SummaryDir(bar).ToString() + "\t"); sb.Append(Backtester.SummaryLots(bar).ToString() + "\t"); sb.Append(Backtester.SummaryTrans(bar).ToString() + "\t"); sb.Append(Backtester.SummaryPrice(bar).ToString(FF) + "\t"); sb.Append(Backtester.ProfitLoss(bar).ToString() + "\t"); sb.Append(Backtester.FloatingPL(bar).ToString() + "\t"); } else { sb.Append("\t\t\t\t\t\t"); } sb.Append(Backtester.ChargedSpread(bar).ToString() + "\t"); sb.Append(Backtester.ChargedRollOver(bar).ToString() + "\t"); sb.Append(Backtester.Balance(bar).ToString() + "\t"); sb.Append(Backtester.Equity(bar).ToString() + "\t"); sb.Append(Backtester.BackTestEval(bar) + "\t"); sb.Append(Environment.NewLine); } string fileName = Data.Strategy.StrategyName + "-" + Data.Symbol.ToString() + "-" + Data.Period.ToString(); SaveData(fileName); return; }
/// <summary> /// Updates the journal data from the backtester /// </summary> void UpdateJournalData() { asJournalData = new string[shownBars, columns]; aiPositionIcons = new Image[shownBars]; for (int bar = firstBar; bar < firstBar + shownBars; bar++) { int row = bar - firstBar; asJournalData[row, 0] = (bar + 1).ToString(); asJournalData[row, 1] = Data.Time[bar].ToString(Data.DF); asJournalData[row, 2] = Data.Time[bar].ToString("HH:mm"); asJournalData[row, 3] = Data.Open[bar].ToString(Data.FF); asJournalData[row, 4] = Data.High[bar].ToString(Data.FF); asJournalData[row, 5] = Data.Low[bar].ToString(Data.FF); asJournalData[row, 6] = Data.Close[bar].ToString(Data.FF); asJournalData[row, 7] = Data.Volume[bar].ToString(); if (Backtester.IsPos(bar)) { asJournalData[row, 8] = Language.T(Backtester.SummaryTrans(bar).ToString()); asJournalData[row, 9] = Language.T(Backtester.SummaryDir(bar).ToString()); if (Configs.AccountInMoney) { string sign = Backtester.SummaryDir(bar) == PosDirection.Short ? "-" : ""; asJournalData[row, 10] = sign + Backtester.SummaryAmount(bar).ToString(); } else { asJournalData[row, 10] = Backtester.SummaryLots(bar).ToString(); } asJournalData[row, 11] = Backtester.SummaryPrice(bar).ToString(Data.FF); if (Configs.AccountInMoney) { // Profit Loss if (Backtester.SummaryTrans(bar) == Transaction.Close || Backtester.SummaryTrans(bar) == Transaction.Reduce || Backtester.SummaryTrans(bar) == Transaction.Reverse) { asJournalData[row, 12] = Backtester.MoneyProfitLoss(bar).ToString("F2"); } else { asJournalData[row, 12] = "-"; } // Floating Profit Loss if (Backtester.SummaryTrans(bar) != Transaction.Close) { asJournalData[row, 13] = Backtester.MoneyFloatingPL(bar).ToString("F2"); } else { asJournalData[row, 13] = "-"; } } else { // Profit Loss if (Backtester.SummaryTrans(bar) == Transaction.Close || Backtester.SummaryTrans(bar) == Transaction.Reduce || Backtester.SummaryTrans(bar) == Transaction.Reverse) { asJournalData[row, 12] = Backtester.ProfitLoss(bar).ToString(); } else { asJournalData[row, 12] = "-"; } // Floating Profit Loss if (Backtester.SummaryTrans(bar) != Transaction.Close) { asJournalData[row, 13] = Backtester.FloatingPL(bar).ToString(); } else { asJournalData[row, 13] = "-"; } } // Icons aiPositionIcons[row] = Backtester.SummaryPositionIcon(bar); } else { // Icons aiPositionIcons[row] = Properties.Resources.pos_square; } if (Configs.AccountInMoney) { asJournalData[row, 14] = Backtester.MoneyBalance(bar).ToString("F2"); asJournalData[row, 15] = Backtester.MoneyEquity(bar).ToString("F2"); } else { asJournalData[row, 14] = Backtester.Balance(bar).ToString(); asJournalData[row, 15] = Backtester.Equity(bar).ToString(); } asJournalData[row, 16] = Backtester.SummaryRequiredMargin(bar).ToString("F2"); asJournalData[row, 17] = Backtester.SummaryFreeMargin(bar).ToString("F2"); asJournalData[row, 18] = Language.T(Backtester.BackTestEval(bar)); } return; }