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

How is data processed?

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

    How is data processed?

    Hello,

    During a strategy analyzer back-test, my strategy calculates on price change and uses the 1 Tick chart for entries and exits for intra-bar granularity but I use a time chart to trigger when the strategy can enter.

    What I noticed is when I test different Time Data Series but use the same exact time of entry, different results are produced.

    For example:
    Using a 30 Minute Data Series, the open price of the 9:00 AM Bar is captured and trading begins.
    VS.
    Using a 1 Minute Data Series, the open price of the 8:31 AM Bar is captured and trading begins.

    The example shown should be using the same open price between the two data series. Each however is also using the 1 Tick Data Series as mentioned for accurate entries and exits. Each also has Tick Data turned on for the back-tests.

    The tests showed two completely different results. Why would I be receiving two totally different results?


    #2
    Hello Don22Trader1,

    During a backtest your script always calculates OnBarClose, OnPriceChange and OnEachTick are realtime processing modes, these are not used for historical tests. If your logic relies on using OnPriceChange you should avoid using the backtesting tools and instead use forward testing tools like the playback connection or a realtime data feed.

    For historical tests you can use an added 1 tick series for submitting orders in a more granular way. That would allow for fills to be more granular. Depending on how you programmed the strategy that can also affect your conditions if you are now executing your logic for each tick in addition to the primary series bars.

    The two tests you have described are using a different primary series so your logic would be executed differently in those two tests. In one test you are running the primary logic once every 30 minute bar, in the second test you are executing the logic once every 1 minute bar. Again this also depends how you coded the secondary series, you may additionally be running your logic for every tick.

    The Times you see relate to the bar series used. 9am is an interval of 30 so you would see 9am, 9:30 etc. 8:31 is an interval of a 1 minute series, you would see each minute of the hour using a 1 minute series.

    If you are having trouble understanding how the strategy is working in each test you can use Prints to output what your logic is doing. That can help to highlight how the strategy is logically working to understand the results it is producing.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello,

      Thank you for your response NinjaTrader_Jesse.

      I've read through supplement materials which are insightful but it still is quite some task understanding much of the processes as a beginner.

      I apologize for asking the question in another way but let me just rephrase it in a simpler manner and hopefully you can help me understand it a bit more.

      My strategy starts by finding a "Benchmark" to perform its trades. This benchmark is the open of a Timestamp Bar of my choosing. For example:

      1.) Using the 1 Minute Bars, I would like "Benchmark" to be the Open[0] of the 9:01am bar, then trades will be submitted to a secondary 1 Tick Data Series.

      2.) Using the 30 Minute Bars, Benchmark is to be the Open[0] of the 9:30am Bar, then trades will be submitted to a secondary 1 Tick Data Series.

      These two different bars give the exact same time and Open Value and Both submit orders to the one tick. Should it be expected to produce the exact same results?

      Comment


        #4
        Hello Don22Trader1,

        If you are running your logic on the 1 tick series and submitting orders to the 1 tick series at the same point in time then yes that would be expected to have the same results. If you are using 1 and 30 minute bar close series then no it would not be the same test because you are using two different series for executing logic. The fill will be based on the 1 tick series but not how your logic was executed.

        The Timestamps you see in NinjaScript are based on the bar close times. 9:01 would be a time that you see using a 1 minute series and would not be observed on a 30 minute series. 9:30 would be seen on both the 1 minute series and 30 minute series because 30 is an interval that both series can have.

        If you are having difficulty understanding the logic you made I would suggest adding some Prints into your conditions so that you can better understand when each condition is becoming true when you run the test and at what time. That can help to see how the logic was executed after making that change in each test.
        JesseNinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_Jesse,

          Thanks for the response.

          So in that case I will run my logic under Primary 1 Tick Data Series and have orders submit on the 1 Tick Data Series.

          Now what is the best way to add an indicator that uses a different (higher) data series? For Example:

          If BarsInProgress == 0 (1 Tick)
          {
          (Strategy & Entry/Exit Logic Here)
          }

          if BarsInProgress == 1 (30 Minute)
          {
          (Indicator Logic to find "Benchmark" so that main strategy can trade off of this value)
          }


          I realize that I have to check the Prints to check the order of outputs but is it fine this way?
          Or should I have BarsInProgress == 1 also be within the brackets of BarsInProgress == 0?

          Comment


            #6
            Hello Don22Trader1,

            When submitting to a more granular series you would generally use the primary as the higher timeframe and then add a secondary 1 tick series so that you can use the BarsInProgress overload for the order. There is a sample of that concept here: https://ninjatrader.com/support/help...ipt_strate.htm

            With what you provided that would be correct, each if condition needs to be seperate like that so that when OnBarUpdate is called one of those conditions will be true depending on the BarsInProgress.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Great,

              I would like to suggest another alternative,

              Would it also be fine by creating a separate custom indicator that uses a 30 minute data series used to find the value = "Benchmark", then load this indicator (under State.DataLoaded) into my main strategy which will be placed in the brackets of; if BarsInProgress == 0 (1 Tick)? Essentially, the only thing that will be referenced from my indicator into my main strategy will be one bool and the "Benchmark" double value.

              Also, would I still have to add the 30 Minute data series to my strategy or will that not be necessary since the 30 Minute is already being used in my indicator?

              Comment


                #8
                Hello Don22Trader1,

                Yes you can do that however the strategy still needs to add the secondary data that the indicator uses so that it can work. You would still need to use BarsInProgress conditions in that use case. You can otherwise expose data from indicators so that the strategy can read it.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rajendrasubedi2023, Today, 09:50 AM
                2 responses
                14 views
                0 likes
                Last Post rajendrasubedi2023  
                Started by geddyisodin, Today, 05:20 AM
                4 responses
                28 views
                0 likes
                Last Post geddyisodin  
                Started by geotrades1, Today, 10:02 AM
                2 responses
                8 views
                0 likes
                Last Post geotrades1  
                Started by ender_wiggum, Today, 09:50 AM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by bmartz, Today, 09:30 AM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X