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

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.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by GussJ, 03-04-2020, 03:11 PM
        15 responses
        3,271 views
        0 likes
        Last Post xiinteractive  
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        2 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        10 responses
        403 views
        1 like
        Last Post beobast
        by beobast
         
        Working...
        X