Topic: Custom Account Statistics for FSB Pro
I'm now experimenting with loading custom account statistics.
In that connection I totally rewrite it's code.
The main parameters and stats values are calculated by the Backtester at every test.
After that program calls AccountStatistics class and provides a link to Backteser.
/// <summary>
/// Calculates the account statistics.
/// </summary>
public void CalculateAccountStats(IBackTester backtester)
{
IStrategy strategy = backtester.Strategy;
IDataSet dataSet = backtester.DataSet;
IProfile profile = backtester.Profile;
int bars = dataSet.Bars;
int firstBar = strategy.FirstBar;
isInfoInCurrency = profile.IsInfoInCurrency;
accountCurrency = profile.AccountCurrency;
SentOrders = backtester.SentOrders;
isScanPerformed = backtester.IsScanPerformed;
testedBars = bars - firstBar;
NetBalance = backtester.NetBalance;
NetMoneyBalance = backtester.NetMoneyBalance;
In that way, the custom code has full access to all strategy, data series, profile settings and backtest data.
CalculateAccountStats method of the custom code copies what it needs from backtester and calculates the new parameters.
The stats info is stored in a InfoRecord class record by record:
public struct InfoRecord
{
public string Name { get; set; }
public string Value { get; set; }
public InfoRecordFlag Flag { get; set; }
}
records.Add(new InfoRecord
{
Name = "Profit per day",
Value = isInfoInCurrency
? MoneyProfitPerDay.ToString("F2") + unit
: ProfitPerDay + unit,
Flag = ProfitPerDay < 0
? InfoRecordFlag.Bad
: InfoRecordFlag.Normal
});
records.Add(new InfoRecord
{
Name = "Tested bars",
Value = testedBars.ToString(CultureInfo.InvariantCulture),
Flag = InfoRecordFlag.Normal
});
This concept works fine for now, but I want to experiment more.
Can you suggests some stats info you want to see in Account Stats info window.
I'll use it for a demo.