Announcement

Collapse
No announcement yet.

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());

    http://ninjatrader.com/support/helpG.../alltrades.htm
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by aligator, Today, 02:12 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_ChristopherJ  
    Started by Roman Hrabovskyi, Today, 01:46 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by The_Saint, Today, 12:44 PM
    0 responses
    19 views
    0 likes
    Last Post The_Saint  
    Started by 12VMan, Today, 12:43 PM
    0 responses
    17 views
    0 likes
    Last Post 12VMan
    by 12VMan
     
    Started by pvtrader, Today, 10:34 AM
    3 responses
    18 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X