Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rithmic real time P&L

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

    Rithmic real time P&L

    I may be wrong about this but based on things I've read on here I am under the impression that there is some known issue regarding Ninja pulling real-time P&L data when using Rithmic for data and as a broker.

    My goal is to carefully control position and stop sizing as I approach a given daily loss limit.

    If this is true it has me thinking that I would need to create a global variable that gets updated with each trade's P&L using something like this:

    Code:
    protected override void OnBarUpdate()
    {
      if (SystemPerformance.RealTimeTrades.Count > 0)
      {
          // Check to make sure there is at least one trade in the collection
          Trade lastTrade = SystemPerformance.RealTimeTrad es[SystemPerformance.RealTimeTrades.Count - 1];
    
          // Calculate the PnL for the last completed real-time trade
          double lastProfitCurrency = lastTrade.ProfitCurr ency;
    
          // Store the quantity of the last completed real-time trade
          double lastTradeQty = lastTrade.Quantity;
    
          // Pring the PnL to the NinjaScript Output window
          Print("The last trade's profit in currency is " + lastProfitCurrency);
          // The trade profit is quantity aware, we can easily print the profit per traded unit as well
          Print("The last trade's profit in currency per traded unit is " + (lastProfitCurrency / lastTradeQty));
      }
    }


    In order to avoid re-inventing the wheel I wanted to make this post to run it past the fine folks at this forum to see if I'm on the right path or if I should adjust course?

    #2
    Hi WalterSkinner , thanks for posting. There is no known issue with PnL, I would need you to link where you heard this information. To track an open position unrealized PnL, use Position.GetUnrealizedPnL(), to read the information from trades the strategy has already completed, the SystemPerformance class is the correct tool to use.

    Kind regards,
    -ChrisL

    Comment


      #3
      Hi Chris,

      If you're not familiar with this "issue" I'm sure that means I am mistaken.

      Thanks for your help I will move forward with GetUnrealizedProfitLoss() and the SystemPerformance class.

      Have a great weekend!

      Comment

      Latest Posts

      Collapse

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