I am working with a strategy and I want to stop taking trades for the day if a certain daily loss is met or if there are too many trades taken that day. I have tested this to be working in the "Playback" connection as well as in real time and the way I have achieved this is with the following,
if ((SystemPerformance.RealTimeTrades.TradesPerforman ce.Currency.CumProfit > DailyProfitLimit) || (SystemPerformance.RealTimeTrades.TradesPerformanc e.Currency.CumProfit < DailyLossLimit))
{
return;
}
However when I am running the strategy in the analyzer, this condition is not being met because the values returned are 0 for the entire day. Another problem I am having is the number of trades taken per day is also showing up as 0. I have a condition to exit if there are too many trades taken as well that works in playback and real time.
protected override void OnBarUpdate()
{
Print("Cumulative profit " + SystemPerformance.RealTimeTrades.TradesPerformance .Currency.CumProfit + " " + Time[0]);
Print("The strategy has taken " + SystemPerformance.RealTimeTrades.Count + " real-time trades.");
// do some work here
}
Produces the following output
...
Cumulative profit 0 4/2/2024 6:58:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 6:59:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:00:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:00:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:01:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:02:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:03:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:04:00 AM
The strategy has taken 0 real-time trades.
Cumulative profit 0 4/2/2024 7:30:00 AM
...
Based on this output, it appears that RealTimeTrades is not set in the strategy analyzer although I cannot find this in the docs. Does anyone know how to achieve such a limiting condition that will be used in the strategy analyzer? Thanks!

Comment