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 problem

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

    backtesting problem

    Hi,
    I'm getting zero trades for the attached strategy. I have downloaded data in the required format for the past 7 months. The instrument is SGXNK 03-10 and I am backtesting offline. The instrument ticker belongs to IB and I am using 1 minute data.

    Please help. Thanks
    Attached Files
    Last edited by kaywai; 12-14-2009, 06:31 AM.

    #2
    kaywai,

    I suggest you go into your code and add this line to Initialize():
    Code:
    TraceOrders = true;
    Then we will know what is happening to the orders and why they may or may not have been ignored/rejected.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh, I've included TraceOrders = true as below:-
      protectedoverridevoid Initialize()
      {
      TraceOrders =
      true;
      CalculateOnBarClose =
      true;
      }

      Where do i look for the errors? still reflecting zero trades on strategy analyzer.

      Comment


        #4
        kaywai,

        You would want to open the Output Window and then run the strategy one more time to see any output.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Josh, It failed because of an "invalid order price"

          From the log, these messages were recorded:-
          "Error on calling 'OnBarUpdate' method for strategy...: stop price has to be greater /equal 0"
          "A buy order placed at "5/18/2009" has been ignored since the stop price is less than or equal to the close of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy."

          Not sure what I'm doing wrong. could you please help?

          Comment


            #6
            kaywai,

            For one, you should not submit simultaneous working entry orders in opposite directions. Next you should print the value of the Close bar and whatever your entry stop price is evaluated as.

            So you should print the value of "highestHigh + TickSize" and Close[0] and compare it by hand to understand why the price is invalid.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thanks for your advice Josh. Let me play around with it for now.

              Comment


                #8
                Josh, I've edited the strategy to one that only goes long when the conditions are fulfilled. I still get the "A buy order placed at "5/18/2009 8:07:00AM" has been ignored since the stop price is less than or equal to the close of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy."

                20090518 074500;9155;9155;9150;9150;371
                20090518 074600;9150;9150;9115;9125;504
                20090518 074700;9120;9120;9110;9115;207
                20090518 074800;9115;9115;9110;9110;68
                20090518 074900;9115;9120;9115;9115;81
                20090518 075000;9120;9120;9105;9110;336
                20090518 075100;9105;9105;9100;9105;181
                20090518 075200;9110;9110;9105;9110;141
                20090518 075300;9115;9130;9115;9125;350
                20090518 075400;9120;9120;9115;9120;217
                20090518 075500;9120;9120;9115;9115;113
                20090518 075600;9115;9115;9100;9110;368
                20090518 075700;9110;9120;9110;9115;80
                20090518 075800;9115;9115;9110;9115;47
                20090518 075900;9110;9110;9095;9095;540
                20090518 080000;9100;9105;9095;9105;625
                20090518 080100;9110;9110;9095;9100;849
                20090518 080200;9100;9105;9090;9100;513
                20090518 080300;9100;9100;9085;9090;1037
                20090518 080400;9085;9095;9085;9095;391
                20090518 080500;9090;9095;9085;9090;406
                20090518 080600;9090;9100;9085;9100;663
                20090518 080700;9100;9100;9095;9095;510
                20090518 080800;9100;9105;9095;9100;241

                Conditions didnot exist for it to place a longstop at 8:07...Please help.
                Attached Files

                Comment


                  #9
                  kaywai,

                  Here is the issue. You are saying when Close[0] > highestHigh. When that happens you submit your long order in at highestHigh + 1 tick. Problem with that is Close[0] can be significantly greater than highestHigh + 1 tick. When that happens you are now submitting at a price <= close of the current bar which is an invalid stop price.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh, I get what you are trying to say but I'm not sure how to address it. Ideally, I would like to initiate a long position when the highestHigh has been exceeded by 2 ticks. Is it possible to write the script for such a situation? could you please help me with the script?

                    Comment


                      #11
                      Instead of running your order off of highestHigh + TickSize you could do Close[0] + TickSize directly. Even with that, you could have an invalid price too as price can move quickly to exceed the price you submit at and thus become invalid.

                      You may even want to consider just using market orders.

                      Code:
                      if (Close[0] > highestHigh + 2 * TickSize)
                           EnterLong();
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you Josh. Your assistance is much appreciated

                        Comment


                          #13
                          Josh, I've chosen to take the enterlonglimit path so that i don't overpay to go long. question i have now is how can i cancel the order if it doesn't get filled within say 10 bars?

                          Comment


                            #14
                            Hi, would appreciate some help regarding the question i posed yesterday on the cancellation of unfilled orders. Thanks

                            Comment


                              #15
                              You will need to count how many bars you have had the order active yourself through code. Then when it reaches 10, you can use Can just stop resubmitting your entry order and it will auto expire. EnterLongLimit()s need to be submitted on every single bar to keep it alive. When it is not kept alive it will auto cancel on the bar.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by lorem, 04-25-2024, 09:18 AM
                              17 responses
                              67 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by joselube001, 05-10-2024, 12:17 PM
                              3 responses
                              18 views
                              0 likes
                              Last Post joselube001  
                              Started by DawnTreader, 05-08-2024, 05:58 PM
                              21 responses
                              81 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by doihaveto13, Today, 12:46 PM
                              2 responses
                              4 views
                              0 likes
                              Last Post doihaveto13  
                              Started by Vitamite, Today, 12:48 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X