Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intrabar Backtest

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

    Intrabar Backtest

    So, working on an intrabar backtest using 15 min (primary) and 1 min data and entering on limit orders. If I set liveUntilCancelled to false the limit order is cancel after 1 minute but if I set it to true I am not sure when/how to cancel it as the next bar may fire a new limit entry order . How do i set this up to keep the order working for the full 15 minute primary bar instead of the 1 minute secondary bar?

    GT

    #2
    GreenTrade, this is currently not possible without some extra code. You will have to set liveUntilCancelled to true and then you can cancel the order after 15 minutes have passed with CancelOrder().
    AustinNinjaTrader Customer Service

    Comment


      #3
      What happens if the previous 15 bar sent a long entry order names "myLE" and is liveUntilCancelled is set to true, then on the next 15 minute bar I send cancel order for "myLE" but the current bar is sending the entry order again because the entry criteria is met again? Will the new order be working or will it cause a problem?

      This is a huge NT limitation that makes me consider other platforms.

      GT

      Comment


        #4
        GreenTrade, you can check to see if the conditions are still true, and if they are, you can leave the order open and not cancel it at all.

        Another option would be to cancel the order every bar and then reissue the order after the cancel if the conditions are still true.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Austin View Post
          Another option would be to cancel the order every bar and then reissue the order after the cancel if the conditions are still true.
          I like this option as the limit order price may change from one bar to the next. How would this be coded to ensure the new order is being place after the cancel?

          GT

          Comment


            #6
            It just has to follow the cancel code:
            Code:
            OnBarUpdate()
            {
               CancelOrder(some order);
            
               if (trade conditions = true)
                 EnterTrade(...);
            }
            AustinNinjaTrader Customer Service

            Comment


              #7
              So after adding the suggested cancelOrder code and changing the strategy code to include IOrder entry and exit orders I get the following information via TraceOrders. Any ideas where to start with this?

              1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=1 Action=Buy OrderType=Limit Quantity=0.1M LimitPrice=1.0074 StopPrice=0 SignalName='myLE' FromEntrySignal=''
              1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=1.0034 SignalName='MyStop' FromEntrySignal='myLE'
              1/4/2011 3:45:00 AM Ignored PlaceOrder() method at 1/4/2011 3:45:00 AM: Action=Sell OrderType=Stop Quantity=0.1M LimitPrice=0 StopPrice=1.0034 SignalName=MyStop' FromEntrySignal='myLE' Reason='An Exit() method to submit an exit order has been ignore. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.'
              **NT** An Exit() method to submit an exit order at '1/4/2011 3:45:00 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
              1/4/2011 3:45:00 AM Entered internal PlaceOrder() method at 1/4/2011 3:45:00 AM: BarsInProgress=0 Action=Sell OrderType=Limit Quantity=0.1M LimitPrice=1.0079 StopPrice=0 SignalName='MyTarget' FromEntrySignal=myLE'
              **NT** Error on calling 'OnBarUpdate' method for strategy 'MyCustomStrat/97641bd0718b424db9d05a027565f88c': Object reference not set to an instance of an object.
              1/4/2011 4:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00002/Backtest' Name='Profit target' State=Working Instrument='$AUDUSD' Action=Sell Limit price=1.0079 Stop price=0 Quantity=0.1M Strategy='MyCustomStrat' Type=Limit Tif=Gtc Oco='NT-00000-942' Filled=0 Fill price=0 Token='a0cfa878243f4da39d6761d23c7cdbea' Gtd='12/1/2099 12:00:00 AM'
              1/4/2011 4:00:00 AM Cancelled pending exit order, since associated position is closed: Order='NT-00001/Backtest' Name='Stop loss' State=Working Instrument='$AUDUSD' Action=Sell Limit price=0 Stop price=1.0034 Quantity=0.1M Strategy=MyCustomStrat' Type=Stop Tif=Gtc Oco='NT-00000-942' Filled=0 Fill price=0 Token='53cf79c8f8924ed497f86fd6cf325a55' Gtd='12/1/2099 12:00:00 AM'
              Thanks!
              GT

              Comment


                #8
                GreenTrade, I see two different issues in your order traces. First of all is the ignored order, which was caused by you trying to open an order that opposes another, already open, order. NinjaTrader does not allow for two opposing orders to be working at the same time. To get around this, you'll need to either submit only one at a time, or move to an Unmanaged strategy.

                The second issue is the object reference error. This is caused when you try to access an object that doesn't exist. You will most likely need to run some null checks on the objects in your code before you access them to be sure they actually exist.
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by judysamnt7, 03-13-2023, 09:11 AM
                4 responses
                59 views
                0 likes
                Last Post DynamicTest  
                Started by ScottWalsh, Today, 06:52 PM
                4 responses
                36 views
                0 likes
                Last Post ScottWalsh  
                Started by olisav57, Today, 07:39 PM
                0 responses
                7 views
                0 likes
                Last Post olisav57  
                Started by trilliantrader, Today, 03:01 PM
                2 responses
                22 views
                0 likes
                Last Post helpwanted  
                Started by cre8able, Today, 07:24 PM
                0 responses
                10 views
                0 likes
                Last Post cre8able  
                Working...
                X