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

Backtesting Executions - Exit before Entry

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

    Backtesting Executions - Exit before Entry

    Hello,

    I'm backtesting a strategy on a daily chart (so BarsInProgress == 0 is daily), and my results seem to show a bug in the executions logic. Using ExitOnClose = true gets me out of the trades before I enter them. (why do I even get executions when the exit price wasn't reached?)

    I attached two pictures. The exit price seems ok, but please have a look at the Date, 19.01. - that should be 20.01. (as in the appropriate chart).

    To get intraday Executions I added minute data to the strategy:
    Code:
    protected override void Initialize() {
       ...
       Add(PeriodType.Day, 1); // BarsInProgress == 1
       Add(PeriodType.Minute, 1); // BarsInProgress == 2
       ...
    }
    I only use the values for the Bars with BarsInProgress == 1 in the strategy, as I need to create signals solely from daily chart data:
    protected override void OnBarUpdate() {
    if (BarsInProgress != 1)
    return;
    ...
    }
    But how do I finally get the correct intraday execution times and results (especially when using ExitOnClose) in the backtest chart and statistic table?
    All I need is a daily chart showing the intraday executions.

    Best Regards,

    Cody
    Attached Files
    Last edited by traderhh; 09-12-2010, 08:59 AM.

    #2
    Cody, we will get back to you tomorrow.
    AustinNinjaTrader Customer Service

    Comment


      #3
      I'd be pleased as I still can't get that to work.
      I simply want a strategy get triggered from daily chart and executed on 1-minute chart (ExitOnClose).
      To show the execution triangles it would be great if I may choose ANY chart period (for BarsInProgress==0) - e.g. daily or 15min - in the backtest panel.
      Last edited by traderhh; 09-13-2010, 08:03 AM.

      Comment


        #4
        Cody, thanks for your patience - with which NT version are you working? To which bars object are you submitting your orders for execution?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hello!

          I'm working with NT 7.0.0.21.
          All bars objects I use in Initialize() and OnBarUpdate() are as described in the code below and my
          orders go to the BarsInProgress==2: EnterLongLimit(2, true, 1, price, "Long_1");

          Best Regards,

          Cody

          Comment


            #6
            traderhh,

            This happens because "Exit on Close" logic is based off of your BIP0 timestamps and BIP0 daily timestamps do not have much granularity. Instead of relying on "Exit on Close" when you running on daily charts, to get the granularity you are looking for I suggest self programming an ExitLong() or ExitShort() into the minute time frame to close your trade when the time arises. When you do it this way you will then get granular execution timestamps to the minute here. If you want even more granularity to get as close to the exit as possible you would then want to maybe even add a 3rd bar series for even more granularity.

            Alternatively, using a more granular chart as the BIP0 primary bars would suffice too.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you for support.

              I now wrote a custom ExitOnClose that doesn't use the BIP0 Bars object:
              ExitLong(2, ...)

              But I still get different backtesting results for different BIP0 chosen in the strategy analyzer panel. I don't like to view the results on a 1-minute chart.

              My exit orders (now submitted to BIP2) are filled at the close price of the BIP0 Bars.

              My entry orders are also submitted to BIP2 (1-Minute Bars) by EnterLongLimit(2, ...);
              I could approve the 1-minute granularity in the output window. But they get filled when the next BIP0-Bar (not BIP2) closes beyond the entry limit.

              All entry and exit execution timestamps show the BIP0 times, but I don't process BIP0 Bars anywhere in my code.

              What am I doing wrong?

              Comment


                #8
                Cody, can you perhaps share a simplified test script showing the issues you ran into so we could give a run here? The strategy analyzer charts would only display your primary series, the added ones are internal for calculations only.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Cody, can you perhaps share a simplified test script showing the issues you ran into so we could give a run here? The strategy analyzer charts would only display your primary series, the added ones are internal for calculations only.
                  I append a test script which I used to reproduce what I mean.
                  The executions seem to depend on the BIP0-Bars object, as strategy results and timestamps are changing when chosing a different BIP0 for the backtest.

                  Regards,

                  Cody
                  Attached Files

                  Comment


                    #10
                    Thanks Cody, I could reproduce a related issue which we're looking into. Thanks for the support.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Ok. I'm looking forward to hear from you again.
                      Thank you.

                      Comment


                        #12
                        Bertrand,

                        have you been able to get ahead? Is it generally possible to switch the backtest chart timeframe (BarsInProgress 0) just to get a another view of the results? So that the BIP0 won't affect the results in any way..?

                        Regards,

                        Cody

                        Comment


                          #13
                          Cody, yes I could reproduce this here in my B21 and we're currently looking into the 'core' I'll provide an update further when I have one.

                          Thanks for your patience.
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Sorry for my impatience here - as this really is a vital question for me - is there any chance/workaround at the moment to view strategy results on a daily chart after testing it on 1-minute basis?
                            If this is not the case and NT65 also doesn't support that, I'll have to consider another software for adjusting my strategies really soon :-( I wish this could work...!



                            Originally posted by NinjaTrader_Bertrand View Post
                            Cody, yes I could reproduce this here in my B21 and we're currently looking into the 'core' I'll provide an update further when I have one.

                            Thanks for your patience.

                            Comment


                              #15
                              Cody, I'm not aware of a temporary workaround - the fix would be included with B22, however I could not give an ETA for its release unfortunately.

                              If you like, send me a note to support at ninjatrader dot com so you can test on B20 where the issue should not be present.
                              BertrandNinjaTrader 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