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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X