I want to set up a stop loss when I have one losing trade with the strategy. I know that Ninja provides System performance class to handle this but when I use SystemPerformance.AllTrades.LosingTrades.Count it does not perform as I expect. Here is the code I use:
if (SystemPerformance.AllTrades.LosingTrades.Count - CumulativeLosingTrade >= DailyStoplossLimit)
{
return;
}
if (Times[0][0].TimeOfDay > Times[0][1].TimeOfDay)
{
CumulativeLosingTrade = SystemPerformance.AllTrades.LosingTrades.Count; //This is to get total number of stop loss before today.
}
When I tested # of losing trade with the following code in Onbarclose function:
Print("Current total number of losing trades: " + SystemPerformance.AllTrades.LosingTrades.Count);
Print("Current cumulative historical number of losing trades:" + CumulativeLosingTrade.ToString());
I see 0 only, and even there is a losing trade already during the test, the number does not update. So I want to ask how I should use the class correctly for my stop loss condition.
I look forward to your assistance.
Thanks!
Comment