Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cant get realt time Unrealized ProfitLoss

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

    Cant get realt time Unrealized ProfitLoss

    Follwoing code mostly provide with negative decreasing value as unrealized PnL

    double currentPrice = (Position.MarketPosition == MarketPosition.Long) ? GetCurrentBid() : GetCurrentAsk();
    Print ("currentPrice="+currentPrice );
    double currentProfit = Position.GetUnrealizedProfitLoss( PerformanceUnit.Currency, currentPrice);

    Even when my Unrealized pnl in Ninjatrader worksatetion under account section, is positive.

    I need to get current unrealized pnl to decide to close all of my positions.

    if (currentProfit>0)
    ExitLong();

    How can I get a realtime Unrealized PnL?

    Thanks in advance.



    #2
    Hello godric,

    Thank you for your note.

    I attached 4 sample strategies which demonstrate pulling PL. You may be most interested in PrintPLOfStrategyBothRealizedAndUnrealized.

    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thank you so much Alan for the codes. It solved my problem.

      Now I faced another one. If I run the same strategy on two different instruments (Lets say QQQ and DIA) and on each instrument I have several positions open, then I think the Unrealized PnL I will get would be a shared value based on all the open positions on both instrument's positions.
      How can I track each position Unrealized PnL, or how can I access each instrument's total Unrealized PnL, separately?

      Thanks in advance.

      Comment


        #4
        Hello godric,

        When running the strategy, on the strategies tab, click the arrow drop down next to the strategies name which will expand the instruments in the strategy and associated positions/pl/etc. See screen shot.

        Please let us know if you need further assistance.



        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X