I try to find out the number of consecutive losses that a strategy had. Currently I use the code below, which works fine in backtests when there is just one strategy running at a time. But on a live system that runs several strategies, it returns the number of consecutive lossses of all strategies and not just of the strategy were I execute this code.
How can I select the trades by strategy (e.g. strategy name or SignalName), so that I get a losscount for that strategy only?
Ana help will be greatly appreciated.
Thanks in advance,
Till
int losses = 0;
if (Performance.AllTrades.Count > 0)
{
for(int n = 1; n <= Performance.AllTrades.Count; n++) {
// Get the last completed trade (at index 0)
Trade lastTrade = Performance.AllTrades[Performance.AllTrades.Count - n];
// Calculate the PnL for the last completed real-time trade
double lastProfit = lastTrade.ProfitCurrency * lastTrade.Quantity;
if(lastProfit < 0) losses++;
if(lastProfit > 0) break;
}
}

Comment