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 Perr0Grande, Today, 08:16 PM
        0 responses
        2 views
        0 likes
        Last Post Perr0Grande  
        Started by elderan, Today, 08:03 PM
        0 responses
        5 views
        0 likes
        Last Post elderan
        by elderan
         
        Started by algospoke, Today, 06:40 PM
        0 responses
        10 views
        0 likes
        Last Post algospoke  
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        12 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        7 views
        0 likes
        Last Post quantismo  
        Working...
        X