Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Position and Active Orders While Backtesting

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

    Position and Active Orders While Backtesting

    Is there a collection that is available in Strategy Script that contains all open / working orders for historical processing?

    I have a strategy that scales into and out of a position with multiple legs. I am trying to debug this strategy through the Strategy Analyzer (NT8) and I need access to working stop orders and completed executions that contains qty and avgPrice for each entry.

    Are there collections available that store Active / Working Orders and Executions for the Strategy Position as it Backtested?. My understanding is that PositionAccount is where I would find realtime / live account orders and Position is the object you would get the historical / backtesting position information.

    But I do not see a Position.Orders collection. I see that I can get the Position.Quantity and Position.AveragePrice for the entire position.

    Where can I find a collection of open / active / working orders (i.e. orders associated with my working ExitLongStopMarket orders) and a collection of Executions with Qty and AvgPrice for each entry?

    I have been maintaining my own collections as I enter orders and then update my collections in OnExecutionUpdate and OnOrderUpdate. But my logic would be much more simple if I could rely on some collections that NT maintains.

    Thanks,
    Last edited by tornadoatc; 09-18-2016, 03:50 PM.

    #2
    Hello tornadoatc,

    A NinjaScript Strategy does have a collection of historical orders, however, there is not a collection of live orders.

    You would need to store the IOrder objects as they are created to an array (or individual variables).

    Attached is an example of storing IOrder objects named DailyLossLimitMultiTradeExample.

    With historical orders these can be found with the Performance collection.
    For example:
    Print(Performance.AllTrades[Performance.AllTrades.Count - 1].Entry.Order.AvgFillPrice.ToString());

    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kevinenergy, 02-17-2023, 12:42 PM
    118 responses
    2,778 views
    1 like
    Last Post kevinenergy  
    Started by briansaul, Today, 05:31 AM
    0 responses
    9 views
    0 likes
    Last Post briansaul  
    Started by traderqz, Yesterday, 12:06 AM
    11 responses
    28 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by PaulMohn, Today, 03:49 AM
    0 responses
    8 views
    0 likes
    Last Post PaulMohn  
    Started by inanazsocial, Today, 01:15 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jason  
    Working...
    X