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

Get AccountOrders in backtesting

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

    Get AccountOrders in backtesting

    Hi,

    I developed a strategy on NT8 that uses AccountOrders to find out which orders are posted and then with this information, make a decision.
    In real time and in Playback the strategy works correctly.

    However, when performing backtesting, AccountOrders does not return orders to me and due to this I am not able to use StrategyAnalyzer.

    How can I get the list of orders that were sent by the strategy in backtesting ?


    Thanks.

    #2
    Hello brunoviveiros,

    I wanted to gather more details on what you are trying to do. What is the goal of using the account directly here? Are you intending to run multiple strategies or was that just one way to access order information that you located?

    If you are referencing an account directly that won't work for backtesting or historical trades, you have effectively created a realtime only strategy by referencing the account and its orders. Generally the approach in the following example would be used for tracking orders: https://ninjatrader.com/support/help...and_onexec.htm

    This would work in a backtest because the strategies order overrides are being used, the orders being seen in the backtest would not exist in the Account because they weren't actual orders in realtime.


    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      What is the goal of using the account directly here?
      - For example, i want to know if my pending order (working) has been filled or not.

      Are you intending to run multiple strategies or was that just one way to access order information that you located?
      - At first it would be just one strategy being executed on my account, but in the future I may have several.


      Can I get a list of the orders that were sent by the strategy or the only way would be to track this information locally?
      Tks for your support.

      Comment


        #4
        Hello brunoviveiros,

        Thank you for the additional details.

        Based on this information It seems you are likely using the incorrect approach for what you are wanting to do. Strategies by nature have overrides which provide their order information as they work forward in time so you would track this locally instead of accessing a list of orders.

        The sample I provided would be where I would suggest starting, https://ninjatrader.com/support/help...and_onexec.htm

        That demonstrates monitoring orders and keeping them as objects in your script for later use. That would be how you check if a order is working or filled and that is actually showed in that sample:

        Code:
         else if (execution.Order.OrderState == OrderState.Filled && sumFilled == execution.Order.Filled)
        If you wanted to get a list of open orders that would entail that you would have a few order object variables, your script would track the orders as they progress and keep them as variables for use.


        I look forward to being of further assistance.






        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          Regarding the SampleOnOrderUpdate example, I noticed that when a target order is filled, effectively closing the position, there doesn't appear to be explicit code to cancel the corresponding stop order.

          I'm keen to understand how this scenario is handled within the strategy.
          Is the cancellation of the stop order managed internally by NinjaTrader's framework when using the managed approach, or is there an aspect of the strategy's code that addresses this which I might have overlooked?

          Thank you!

          Comment


            #6
            Hello QuantumShadow,

            That sample uses the managed approach which does have some internal handling. That makes use of the signal name system so once the position for the associated signal name is closed the orders which are still open will be canceled as they no longer have a position to target.

            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Christopher_R, Today, 12:29 AM
            0 responses
            9 views
            0 likes
            Last Post Christopher_R  
            Started by sidlercom80, 10-28-2023, 08:49 AM
            166 responses
            2,235 views
            0 likes
            Last Post sidlercom80  
            Started by thread, Yesterday, 11:58 PM
            0 responses
            3 views
            0 likes
            Last Post thread
            by thread
             
            Started by jclose, Yesterday, 09:37 PM
            0 responses
            8 views
            0 likes
            Last Post jclose
            by jclose
             
            Started by WeyldFalcon, 08-07-2020, 06:13 AM
            10 responses
            1,415 views
            0 likes
            Last Post Traderontheroad  
            Working...
            X