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 helpwanted, Today, 03:06 AM
    0 responses
    3 views
    0 likes
    Last Post helpwanted  
    Started by Brevo, Today, 01:45 AM
    0 responses
    6 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X