I've been using the following code (and the NT7 equivalent before NT8) as part of my money management strategy for years now. It works perfectly as long as a strategy is only applied to a single currency pair. However, a strategy that I am currently testing was profitable on four different currency pairs; for the sake of simplicity, I started forward-testing on only two.
When a strategy is applied to more than one currency pair in real-time (sim101 account for starters), it appears that SystemPerformance.AllTrades.Count never increments, even if both instances of the strategy have opened and closed multiple trades. I have applied the strategy in question to a single currency pair and the following code works as expected. Also, I have set IncludeTradeHistoryInBacktest = true.
With that in mind - is there a way to tweak the following code to retrieve a count of trades for that strategy for a particular symbol/currency pair? If not, or if that isn't the cause - any ideas why it might not be counting?
Here is the basic code layout:
if (SystemPerformance.AllTrades.Count > 0)
{
Trade lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1];
double lastProfit = lastTrade.ProfitCurrency;
//Use this value to calculate lot sizing - if profit was >= 0, do something, else do another thing
}
else
{
//Default lot size here --> THIS SECTION ALWAYS TRIGGERS
}
Thank you.
Comment