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

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.
    Kate W.NinjaTrader Customer Service

    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 senderExecutionEventArgs 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 stafe, 04-15-2024, 08:34 PM
          6 responses
          30 views
          0 likes
          Last Post stafe
          by stafe
           
          Started by adeelshahzad, Today, 03:54 AM
          4 responses
          25 views
          0 likes
          Last Post adeelshahzad  
          Started by merzo, 06-25-2023, 02:19 AM
          10 responses
          823 views
          1 like
          Last Post NinjaTrader_ChristopherJ  
          Started by frankthearm, Today, 09:08 AM
          5 responses
          17 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by jeronymite, 04-12-2024, 04:26 PM
          3 responses
          43 views
          0 likes
          Last Post jeronymite  
          Working...
          X