Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Submitting order on next bar

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

    Submitting order on next bar

    In my strategy, I have an issue backtesting where after entering a position and reaching a certain condition I wish to move a stop order to breakeven. However if the condition is met on the same bar as the entry of my position, the BE stop gets triggered since in backtesting I assume ninja can not determine the price action and assumes that since the bar at some point touched the order it should be filled. So my thought was to submit the stop order to be active for the next bar just for backtesting purposes, but I am unclear how to do this. I am using SubmitOrder and unmanaged for this strategy. So how can I submit the order for the next bar without storing variables about the order I want to place and then waiting for the next OnBarUpdate to place it.

    Also, is there a better way to get around this backtesting limitation?

    Thanks,

    Mark

    #2
    Hi Mark, you would likely not have enough granularity available to properly backtest this setup using your primary series, one option would be submitting to a finer series in backtesting for simulating executing intrabar : http://www.ninjatrader.com/support/f...ead.php?t=6652
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      I am not as worry about the granularity of the orders at this point. I just want to be able to send a SubmitOrder command but have it delayed by a bar, would this be possible?

      Mark

      Comment


        #4
        Hi Mark,

        One way to do this may be adding a condition that checks BarsSinceEntry() > 0 before submitting or modifying your order.

        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          The problem with that solution would be that I would need to check this in OnBarsUpdate instead of the OnExecution method. Hence I would need to save information from the previous fill that is triggering the event, which I would prefer not to do if possible. Cause currently, I could just save all information I need to create my order, set some class variable to tell me what bar to enter the order on, and then in the OnBarUpdate I could submit when I reach that bar, but this seems like a lot less elegant solution than just having some functionallity to say I want this order to go in at so and so offset

          Comment


            #6
            I see. There's no delay possible so will all come to down to the conditions you use before submitting the order.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Mark,

              OnExection() is only called when an order is filled. Delaying orders in this method isn't possible. It won't be executed again until you submit another order. There are no delayed order functions, as BarsSinceEntry() is pretty much what is used for this purpose.

              I would recommend simply adding Ryan's suggestion to your code along with any necessary things you need to keep track of. You could make a flag to toggle between the backtesting mode and live mode.

              Please let me know if I can assist further.
              Last edited by NinjaTrader_AdamP; 10-19-2011, 11:33 AM.
              Adam P.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by ghoul, Today, 06:02 PM
              0 responses
              4 views
              0 likes
              Last Post ghoul
              by ghoul
               
              Started by Barry Milan, Yesterday, 10:35 PM
              6 responses
              18 views
              0 likes
              Last Post Barry Milan  
              Started by DanielSanMartin, Yesterday, 02:37 PM
              2 responses
              13 views
              0 likes
              Last Post DanielSanMartin  
              Started by DJ888, 04-16-2024, 06:09 PM
              4 responses
              13 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by terofs, Today, 04:18 PM
              0 responses
              12 views
              0 likes
              Last Post terofs
              by terofs
               
              Working...
              X