Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Access to ALL realtime trades

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

    Access to ALL realtime trades

    I was under the impression that
    Code:
    [URL="https://ninjatrader.com/support/helpGuides/nt8/realtimetrades.htm"]SystemPerformance.RealTimeTrades.TradesPerformance.Currency.CumProfit
    [/URL]

    would give me access to the cumulative pnl of the strategy.

    But when I stop/start the strategy, this quantity goes back to zero.

    Is this only the realtimetrades since the strategy last started? From https://ninjatrader.com/support/help...ount_class.htm I think it does but my question would then be, how do I get access to older trades so that they are included into the cumulative pnl.

    Thanks

    #2
    Hello crystalet,

    Thanks for your post.

    When you disable and re-enable a strategy, it processes historical data again from the starting point of the data series to the last completed bar. After that it transitions to realtime processing, and any later trades will be in the RealTimeTrades collection.

    You can use SystemPerformance.AllTrades to access the trades that were calculated from processing historical data, and the trades calculated later with realtime data.

    Past completed trades that NinjaTrader sees are recorded in the NinjaTrader database, but this is not supported for NinjaScript access, so we would suggest using SystemPerformance.AllTrades to read the trades calculated from historical data as well as the trades that are made with realtime data.

    We look forward to assisting.
    Last edited by NinjaTrader_Jim; 09-06-2021, 09:45 AM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for clarifying that. I will work around that with something that uses all trades. Thanks.

      A follow up question:
      Is there any programmatic way to access the NT trade DB ?

      I like the trade performance functionality you have, but the filters don't allow me to drill into strategy level. Would be handy to have a pivot with that detail.

      Even in that list, only when the strategy is active, the Strategy field is linked that that strategy. For the older Trades, the Strategy has become empty. I can still see the Entry/Exit name (and I provide label to entry per strategy name) but I cannot filter on that (only on accounts, Instruments and templates (not sure yet what that is)

      Comment


        #4
        Hello crystalet,

        Accessing the NinjaTrader database is not supported. Others have tried this and have shared their success, however. An older NinjaTrader 7 thread can be found here:



        You should really just use SystemPerformance.AllTrades because NinjaScript strategies were designed to calculate historical data and calculate what the past trades would have taken place on the data series they are applied to. AllTrades will also include the realtime trades after transitioning to realtime data, so it would include all of the trades created by that strategy.

        This only wouldn't be the case if that strategy did not calculate those trades with historical data, but that can generally be worked through by using Tick Replay (if using Caluclate.OnPriceChange/OnEachTick) and submitting orders to a single tick data series.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by chbruno, Today, 04:10 PM
        0 responses
        3 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        6 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by frslvr, 04-11-2024, 07:26 AM
        9 responses
        127 views
        1 like
        Last Post caryc123  
        Working...
        X