Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about Position.AvgPrice and tracking multiple entries

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

    Question about Position.AvgPrice and tracking multiple entries

    Hi,

    I am testing a simple crossover strategy that submit orders at the close of every candle that mean the criteria, for example,

    protected override void Initialize()
    {
    EntriesPerDirection = 50;
    EntryHandling = EntryHandling.UniqueEntries;
    }

    protected override void OnBarUpdate()
    {
    if (CrossAbove(SMA(10), SMA(20), 1)
    EnterLongLimit(GetCurrentBid(), "SMA Cross Entry");
    }

    Suppose during the past 5 candles, all of them met the criteria, and 5 entry orders were filled at different prices, my question is if I want to use Position.AvgPrice later on in my strategy, will it calculate the average price of all the open positions, or the price of the latest entry( the fifth bar). And if I want to treat those five entries individually(perhaps using reverse on stop), how do I track the entry prices of the other previous entries( i.e., the first, the second, the third, the forth bar) ?

    Thank you.

    #2
    Hi kw123,

    Position.AvgPrice will calculate the average fill price of all positions, since the last time the strategy was flat.

    If you want to track individual fill prices, you can switch to IOrders - http://www.ninjatrader-support.com/H...de.html?IOrder

    Or you can access AvgPrice after each fill, and store them in a variable or perhaps a dataseries.
    TimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    52 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    142 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X