Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Enter & Exit on the same bar

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

    Enter & Exit on the same bar

    I wrote a strategy that sometimes enters and exits on the same bar. I set a stop loss and profit target and sometimes one of these are hit on the same bar.

    Is this allowed? Is it valid? Since Ninjatrader is using say a 5 minute bar, it knows the OHLC. How would it know which price (entry or exit) was hit first?

    #2
    Hi cunparis,

    You are right that NinjaTrader does not know which one is hit first so what NinjaTrader does in these situations is take the most conservative approach that will not overestimate your results. It will fill the stop loss.

    Not sure what you mean by which comes first though for entry and exit. You will not be able to exit unless you've entered already.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      Hi cunparis,

      You are right that NinjaTrader does not know which one is hit first so what NinjaTrader does in these situations is take the most conservative approach that will not overestimate your results. It will fill the stop loss.

      Not sure what you mean by which comes first though for entry and exit. You will not be able to exit unless you've entered already.
      What if I put a limit order for 900.

      Now let's say price goes from 910 to 900 in the next bar.

      Will Ninjatrader:
      - give me a fill at 900 and keep position open?
      - give me a fill at 900 and stop loss at 910?

      I'm not sure which it's doing.

      Thanks

      Comment


        #4
        Not sure I am following your scenario, but what I recommend is for you to use TraceOrders = true. Follow the trace outputs for your orders and then you will know exactly what is happening and in what order.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          Not sure I am following your scenario, but what I recommend is for you to use TraceOrders = true. Follow the trace outputs for your orders and then you will know exactly what is happening and in what order.
          My question is more about whether the backtesting results are realistic.

          If I put a limit order 900, stop loss 895 and profit target 905.

          is it possible for Ninjatrader to give me the fill at 900 and profit target at 905 in the backtest when in reality price went from 900 to 895 before reaching 905?

          I got some good results but I'm thinking there is aproblem and it's not possible.

          Comment


            #6
            If the bar in question touched 895 as well as 905 you will be filled at the stop for 895 to prevent overestimation.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              If the bar in question touched 895 as well as 905 you will be filled at the stop for 895 to prevent overestimation.
              So it's possible that my strategy works. I'm going to try it out with the simulator and find out. Thanks for your information, I appreciate it.

              Comment


                #8
                Hi,

                Just to build on from this, is it technically possible to adapt the fill code (for the purpose of backtesting) to basically say:

                if entry order short has been filled in this bar then do not fill target order in the same bar if bar is green

                or something along those lines?

                would just make backtesting a bit more realistic

                Comment


                  #9
                  You can create your own custom fill types, but the only information we can provide on that endeavor can be found here: http://www.ninjatrader-support.com/H...FillTypes.html
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Great, its good to know at least that it is possible. Now just need to decide if its worth the time investment!

                    Comment


                      #11
                      In this thread, there was a recommendation to use TraceOrders = True.

                      Where does this setting take place?

                      Comment


                        #12
                        skat100,

                        You place the TraceOrders = true; in the Initialize() section of the strategy. Then open the output window to review the output.

                        Comment


                          #13
                          Thanks ctrlbrk!

                          skat100, please review this link here - http://www.ninjatrader-support.com/H...aceOrders.html
                          BertrandNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by algospoke, 04-17-2024, 06:40 PM
                          3 responses
                          26 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by bmartz, 03-12-2024, 06:12 AM
                          3 responses
                          27 views
                          0 likes
                          Last Post NinjaTrader_Zachary  
                          Started by Aviram Y, Today, 05:29 AM
                          2 responses
                          8 views
                          0 likes
                          Last Post Aviram Y  
                          Started by gentlebenthebear, Today, 01:30 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by cls71, Today, 04:45 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X