Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SystemPerformance RealTimeTrades in Strategy Analyzer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SystemPerformance RealTimeTrades in Strategy Analyzer

    Hello,
    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!

    #2
    Hello dr_cortex,

    To have this work in the backtest you need to change to using the AllTrades collection so historial trades are being counted. You can find a sample that shows how to break the performance down per session when using the AllTrades collection here:

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X