Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unrealised p and l

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

    Unrealised p and l

    Hi,

    When i use get 'unrealized p and l'

    it doesnt seem to adjust for the fact if one entry has a bigger lot size than the 2nd entry.

    How can i write it so that it factors in different lot size entries as at the moment it seems to just ignore the quantity and just base it off price.

    Thanks for the help

    #2
    Hello freddy250,

    Thank you for writing in. Could you please clarify which of the following you are referring to, to help me narrow down the issue?
    Code:
    Position.GetProfitLoss(double marketPrice, PerformanceUnit performanceUnit)
    or
    Code:
    GetAtmStrategyUnrealizedProfitLoss(string AtmStrategyId)
    Thank you in advance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Hi,

      I am using

      Position.GetProfitLoss(double marketPrice, PerformanceUnit performanceUnit)

      Should this add all positions together and account for entry sizing?

      Comment


        #4
        Hello freddy250,

        If you are using PerformanceUnit.Points you can multiply by the position quantity to get what you are expecting. For example:
        Code:
        Print(Position.GetProfitLoss(Close[0], PerformanceUnit.Points) * Position.Quantity);
        PerformanceUnit.Currency should reflect correctly based on quantity and PerformanceUnit.Percent does not take quantity into consideration.

        Please let me know if you have any further questions.
        Michael M.NinjaTrader Quality Assurance

        Comment


          #5
          Hi

          That fixes it thanks!

          The only thing is when using different size entries the cumulative profit is wrong. Are all other values correct in a backtest or others i need to ignore as well

          Thanks

          Freddy

          Comment


            #6
            Hello freddy250,

            Are you using the following code for cumulative profit? Could you please clarify what is wrong with the value you are seeing?
            Code:
            Performance.AllTrades.TradesPerformance.Currency.CumProfit
            Thank you in advance.
            Michael M.NinjaTrader Quality Assurance

            Comment


              #7
              It seems fine just when doing a backtest and looking at the cum profit column in trades tab it doesnt adjust for position size so

              if 1st entry is half of second it is treated as the same profit even if both entries and exits are at the same price.

              Surely the second entry should be double the profit (in relation to the account) as if not the cum profit of these values added would be incorrect. It seems only net profit is correct when using different size entries.

              Comment


                #8
                Hello freddy250,

                Thank you for clarifying. Here are the formulas used for cumulative profit for your convenience:

                Cumulative profit
                This statistic returns a value representing a summation of all the profits earned by all your trades. It can be interpreted as a performance measure for your strategy.

                Currency
                SUM(profit * quantity * point value) of all trades

                Percent
                PRODUCT(1 + profit / entry price) of all trades - 1

                Points
                SUM(profit * quantity) of all trades

                where profit is defined as (exit price – entry price) for long trades and as (entry price – exit price) for short trades, quantity is defined as the number of contracts traded, and point value is defined as the monetary conversion of each point (e.g. 100 for currency pairs).

                Here is a list of the other statistics definitions in our help guide: http://ninjatrader.com/support/helpG...efinitions.htm

                Please let me know if I may be of further assistance.
                Michael M.NinjaTrader Quality Assurance

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                647 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                369 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                108 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                572 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X