Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Impossible exit price during backtest

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

    Impossible exit price during backtest

    Hi,

    I've been backtesting my strategy for a while now, and it keep giving me impossible exit prices on certain trades resulting in unrealistic results. Here is a screen capture of a EURNZD trade from 09/26 which supposedly exited on the 09/29 at a price of 1.6116. Unfortunately there wasnt a price even near that level. The low of that 4-hour candle on 09/29 was 1.6313.

    The 1.6116 price was the closing day low of 09/26.
    The 1.6313 price was the closing day low of 09/29.

    My strategy is programmed so that all trades are closed at the end of the day. I use a Add(PeriodType.Day,1) in the Initialize() section for this. And then I check if(BarsInProgress == 1) { exitlong(); exitshort(); return; }

    For some reason the Strategy Analyzer thinks that it can close the 09/29 trade for the price of the 09/26 day close.

    So I wonder why the Strategy Analyzer gives me this result? There is some serious errors going on in the handling of bars and prices.

    Last edited by siroki; 10-22-2014, 08:45 AM.

    #2
    Hello Siroki,

    Thanks for your post.

    This would be expected behavior. When you do backtesting you are only using the open, high Low and close of each bar. Because of that, backtesting operates the same as CalculateOnBarClose = true which means that orders placed on one bar are not executed until the next bar. In the case of using Day bars the exit order is place at the price level of the close of the day bar but is not executed until the open of the next day bar. Here is a link to the help guide section: http://www.ninjatrader.com/support/h...ime_vs_bac.htm

    Alternatively you could add 1 minute bars and exit based on time.

    Please let me know if I can be of further assistance.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your answer.

      I know how the bar / order processing works. But I just dont understand how the four orders that were opened on the 29th could have closed at 1.6117. Price never went that low after the 26th...
      Last edited by siroki; 10-22-2014, 02:55 PM.

      Comment


        #4
        Hello siroki,

        Thanks for your reply.

        So that I can replicate the issue, who is your datafeed provider and what session template are you using?

        Regarding the exit, you may want to employ the ExitOnClose in the strategy parameters or use the more advanced overloads in ExitShort: http://www.ninjatrader.com/support/h...?exitshort.htm

        I look forward to your reply.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your answer.

          I'm using FXCM (Active Trader) in a live-environment. I use the Forex template which uses the 5PM - 5PM EST template.

          The thing is, i have tried using the ExitOnClose. This indeed closes the trades at the end of each session, but this gives me total different results. Which I find strange because when I use ExitLong() / ExitShort() on the BarsInProgress == 1 (which is the first added period Day) I should get the same results right?

          Comment


            #6
            Hello siroki,

            Thank you for your response.

            When using the Day Period Type to exit on, it will submit the orders after the bar closes thus filling on the next bar or next day.

            So if you use ExitOnClose without the Day Period Type, do you see the expected results?

            Comment


              #7
              In my live environment, positions are closed when the Day Period bar is executed, just the same when ExitOnClose is enabled. My point is more that in the example given in this thread, the position is closed at a price that was not valid for the four trades that were opened on the 29th.

              The four trades that were opened near 1.6357, 1.6344, 16334 were all closed end of day near 1.6117. But price never went to that level on the 29th.

              My point basically is this, that I have developed a strategy that on paper looks profitable, but when analyzing each individual trade it actually is not, because many profitable trades in reality are not profitable because those exits could not have happened.

              Comment


                #8
                Hello siroki,

                have been unable to replicate the issue of concern, IE: trades on the 29th closing at price level of the 26th. I created a sample strategy using the information you provided in your first post and it does not exhibit this behavior.

                Can you share more of your strategy so that I can investigate this further? If you would prefer, you can send this to me via e-mail to PLatformSupport[at]NinjaTrader[dot]com and reference this thread in the e-mail.
                Paul H.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by techgetgame, Today, 11:42 PM
                0 responses
                7 views
                0 likes
                Last Post techgetgame  
                Started by sephichapdson, Today, 11:36 PM
                0 responses
                1 view
                0 likes
                Last Post sephichapdson  
                Started by bortz, 11-06-2023, 08:04 AM
                47 responses
                1,612 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                9 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                19 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Working...
                X