• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 afoschini, Today, 02:57 AM
    0 responses
    1 view
    0 likes
    Last Post afoschini  
    Started by jecoyeko, Today, 12:45 AM
    0 responses
    6 views
    0 likes
    Last Post jecoyeko  
    Started by Newtrader101, Yesterday, 06:31 PM
    1 response
    9 views
    0 likes
    Last Post NinjaTrader_EricB  
    Started by Tyler7498, Yesterday, 07:34 PM
    0 responses
    4 views
    0 likes
    Last Post Tyler7498  
    Started by Woomera, Yesterday, 07:24 PM
    2 responses
    10 views
    0 likes
    Last Post Woomera
    by Woomera
     
    Working...
    X