Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.AvgPrice Real Value

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

    Position.AvgPrice Real Value

    I have always assumed that when calling "Position.AvgPrice" for position one gets the average ENTRY price for a position, but judging by how my strategy is behaving it appears that I am actually getting the average Price of my combined positions based on what they were at the last bar close. My problem is I am using the above price as a limit order for the remaining runner after I take off two contracts at a first profit target. Here is the code I am using.

    Code:
    if (Position.MarketPosition == MarketPosition.Short
                    && Position.Quantity == 1)
                {
                    ExitShortLimit(Position.AvgPrice , "SBreakEven Exit", "SRunner");
                }
    The problem is, this order is executing on the next bar after I close out the first two contracts and the price it is closing at, is generally the same as my first profit exit. If, as I suspect, the Position.AvgPrice gives us the avg price of the position at the time it is called, then is there a way to get the average entry price of a position? Perhaps store a variable and refer to it later? Or better yet, there is an actual command that provides the average entry price of a position. It seems that would be a very useful command if you don't already have it.
    Thanks
    DaveN

    #2
    Hi daven,

    Position.AvgPrice returns you the average entry price of your complete position at the very moment you call it. If your position is already closed then this will likely not yield a value you want.

    Instead you will want to access the historical Trades objects to get their entry prices. http://www.ninjatrader-support.com/H...radeClass.html

    You can access the IExecution object of the entry and from there get the entry price for that trade.
    Josh P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    85 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    47 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    29 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    67 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X