Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetUnrealizedProfitLoss() on Real Account

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

    GetUnrealizedProfitLoss() on Real Account

    Hello,

    I've problem with the function GetUnrealizedProfitLoss().

    If i call this function from a Sim account when i close a trade(IsLastExit boolean), i get the good value and everything is good.

    But if i use a real account, the returned value is 0.

    I don't know how to get the good value from a real account and the documentation "https://ninjatrader.com/fr/support/helpGuides/nt8/?account_class.htm" does not work.

    Can you help me ?

    Regards
    johnok
    NinjaTrader Ecosystem Vendor - Trade With Me

    #2
    Hello johnok,

    Thank you for your post.

    Who is your broker?

    Can you supply a code example of what you're trying that isn't working for you?

    Are you accessing it like Position.GetUnrealizedProfitLoss(PerformanceUnit.P oints, Close[0])?

    Thanks in advance; I look forward to assisting you further.

    Comment


      #3
      Hello,

      I'm using Leeloo trading as a data source.

      Here, an example of my code to print profit

      PHP Code:
      private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
      {
        if ( e.Execution.IsLastExit )
        {
          Position current_position = e.Execution.Account.Positions[e.Execution.Position];
          double current_profit = current_position.GetUnrealizedProfitLoss(PerformanceUnit.Currency);
          NinjaTrader.Code.Output.Process(String.Format("Profit: {0}", current_profit), PrintTo.OutputTab1);
        }
      } 
      
      johnok
      NinjaTrader Ecosystem Vendor - Trade With Me

      Comment


        #4
        i've another problem,

        I would like to get the global profit of a trade(with multiple lots) but when i call GetUnrealizedProfitLoss, i just get the PnL of current opened lots(it's normal) but not all the position.

        Is it possible to get in the last exit of a position, the total PnL of this position with all the lots ?

        Regards,
        johnok
        NinjaTrader Ecosystem Vendor - Trade With Me

        Comment


          #5
          Everything is good,

          I just stock every Entry(price and quantity) and exit and recompute every profit by my side.

          Thanks and have a nice day
          johnok
          NinjaTrader Ecosystem Vendor - Trade With Me

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          633 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          364 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          105 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          567 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          568 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X