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 techgetgame, Yesterday, 11:42 PM
          0 responses
          8 views
          0 likes
          Last Post techgetgame  
          Started by sephichapdson, Yesterday, 11:36 PM
          0 responses
          2 views
          0 likes
          Last Post sephichapdson  
          Started by bortz, 11-06-2023, 08:04 AM
          47 responses
          1,613 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Yesterday, 05:56 PM
          0 responses
          10 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          20 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Working...
          X