Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

AvgPrice or UnrealizedPnL from Unique Entries

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

    AvgPrice or UnrealizedPnL from Unique Entries

    In using a managed approach you can EnterLong(Condition 1) and EnterLong(Condition 2) as well as ExitLong from each by name. However I've not found much information on being able to get the AveragePrice or UnrealizedPnL from say only (Condition 1). How do I specify which unique entry to get this information from?

    Example:
    EnterLong(10, Cond1) "Buy 10 due to Cond1 rules"
    EnterLong(10, Cond2) "Buy 10 due to Cond2 rules"

    Cond2 entry has an UnrealizedPnL of 10% while Cond1 is 1%.
    So ExitLong Cond2 shares while leaving Cond1 shares open.

    Using Position.AveragePrice and Position.GetUnrealizedProfitLoss(PerformanceUnit.P ercent, Close[0]) is only used for the overall position and not unique entries.
    Is there a method for doing this?

    Thanks,

    #2
    Hello antrux,

    All entries contribute to the position.

    The position has an AverageEntryPrice as this is the average price of all entries that have contributed to that one position. The positions are not distinguished or separated by entry. You would need to track this information using variables.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Using a variable it would be easy to say record the current close with a unique name however even with Limit orders that value will most likely be different than that Close[0] value.

      So what would you recommend to use to derive that more accurate value to store?

      (Cond 2 ShareQty) * (What?) = (Total Cost of Cond 2 Entry)

      (Close[0] * (Cond 2 ShareQty)) / (Total Cost of Cond 2 Entry) = var1

      (var1 * 100) - 100 = (UnrealizedPnL% of Cond 2)

      Comment


        #4
        Hello antrux,

        You could have a list of Order objects that holds each entry order when the position is not flat or a list of doubles if you just want to save the prices and not the orders themselves. You could then compare the entry price from the <order>.AverageFillPrice or the saved price to the current Close[0] price to see how far the price has traveled since that specific entry price. A custom calculation with the point value and tick size and this would give you the profit per entry instead of for the entire position.

        An example is attached of using a dictionary to track the entries that contribute to a position.
        PositionEntryOrdersExample_NT8.zip
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X