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 cre8able, Today, 03:20 PM
        0 responses
        5 views
        0 likes
        Last Post cre8able  
        Started by Fran888, 02-16-2024, 10:48 AM
        3 responses
        47 views
        0 likes
        Last Post Sam2515
        by Sam2515
         
        Started by martin70, 03-24-2023, 04:58 AM
        15 responses
        114 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by The_Sec, Today, 02:29 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by jeronymite, 04-12-2024, 04:26 PM
        2 responses
        31 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X