Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Regarding the RealTime Trades collection

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

    Regarding the RealTime Trades collection

    Hello,

    I'm trying to count PnL made by strategy. I've used to loop through AllTrades collection to count PnL made for current day, but I'd like to avoid using virtual trades to count only those that were really made.

    One question comes up immediately: say, if I disable and enable strategy throughout the day for few times, will the strategy include real trades that were made by it while counting the PnL when the strategy is enabled again (RealTime collection)? If not, is there a way to avoid counting virtual trades and just to count real ones (without saving realtime trades into file)?

    Thank you in advance.

    #2
    Hi RobertasJ, the Realtime trades collection is reset if you reenable the strategy, it would not 'housekeep' the value generated for the current session, but only include live generated trades since the last enablement, as this is done per started instance of the strategy.

    What you would unfortunately need to do here in your case is persisting / saving the prior realtime trades to a custom file and then appending those values with the newer realtime results generated after you've restarted the strategy.

    Comment


      #3
      I see, thank you for your reply.

      I've decided to play with GetAccountValue instead. And all seems well apart one thing: it gets value during "OnBarUpdate" methods, it gets "0" if I try to extract it's value during strategy initialization (be it OnStartUp or Initialize). Any suggestions on how can I extract initial account's balance once when the strategy is enabled?

      Comment


        #4
        This is likely returned as this call would be done then on historical data still, if you request it on the first realtime OnBarUpdate() bar it would be accessible (this would be the first possible access point).

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        68 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        37 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        62 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X