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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          93 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          138 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          68 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          123 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          73 views
          0 likes
          Last Post PaulMohn  
          Working...
          X