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 futtrader, 04-21-2024, 01:50 AM
    4 responses
    41 views
    0 likes
    Last Post futtrader  
    Started by Option Whisperer, Today, 09:55 AM
    1 response
    11 views
    0 likes
    Last Post bltdavid  
    Started by port119, Today, 02:43 PM
    0 responses
    1 view
    0 likes
    Last Post port119
    by port119
     
    Started by Philippe56140, Today, 02:35 PM
    0 responses
    3 views
    0 likes
    Last Post Philippe56140  
    Started by 00nevest, Today, 02:27 PM
    0 responses
    2 views
    0 likes
    Last Post 00nevest  
    Working...
    X