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

Multi Time Frame Indicator behaves different upon "Load data based on days or bars"

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

    Multi Time Frame Indicator behaves different upon "Load data based on days or bars"

    Hi,
    This simple multi time frame indicator behaves different upon "Load data based on days or bars".
    Attached Files

    #2
    Originally posted by td_910 View Post
    Hi,
    This simple multi time frame indicator behaves different upon "Load data based on days or bars".
    Can you attach the complete indicator code?

    Comment


      #3
      Sorry, I thought I did.
      here you go
      Attached Files

      Comment


        #4
        Hello td_910,

        Thanks for your post.

        If you are loading a different number of days or bars on the chart then it could be possible for the indicator to behave differently since different data is being used. For results to be the exact same then the exact same amount of data would have to be loaded on the chart.

        Each added secondary series in the script would need to have a minimum of 20 bars loaded on the chart before the backbrush color is changed.

        You could add prints to the strategy that prints out the CurrentBars value along with the time to see exactly how the script's logic is behaving.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        CurrentBars: https://ninjatrader.com/support/help...urrentbars.htm

        Working with multi-timeframe/multi-instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          I'll add my 2˘, which I interpret to be your problem.

          When comparing two charts (and the indys loaded on
          those charts) both charts need to be the same bar type
          and start at the exact same point in time, so that each
          subsequent bar in both charts is built using the start and
          end of the same sequence of data.

          This problem is extremely noticeable on charts using
          tick data, such as Tick, Second, Range, UniRenko, etc.

          What this means is, unless the first bar in both
          charts starts at the exact same moment on the
          same tick, the rest of the bars will be off. You
          gotta get the first bars in sync on the same starting
          data, so that all subsequent bars are also in sync.

          The easiest way to screw this up is to use different
          'Days to Load' settings on the charts, or using 'Days
          to Load' on one chart and 'Bars to Load' on the other.

          This is the only way to make sure your indys on both
          charts are exactly the same -- you gotta make sure
          all the bars (starting at the very first bar) are exactly
          the same.

          Time based charts may have less of an issue than
          tick based charts, but it does happen. The 'drift'
          happens in indys because many indys use a window
          of data (think of an EMA) that continues to impact
          the calculated results many bars past that window.

          Using your two charts,
          Trying loading 100 days and 10000 bars -- this might
          allow enough bars to pass such that the builtin 'drift'
          effects from the unsynced starting bars to mellow
          out -- so that the right hand side of both charts has
          time to 'settle down', so to speak, but this kind of
          side-effect is very indicator dependent.

          In summary, just start both charts on the exact same
          bar, using same 'Load data' method, when the charts
          are created -- your life is much easier if you do this.

          This silly foray of 'why are my charts different when
          I use different settings to create my charts' is, perhaps,
          an interesting discussion, but may continue to waste your
          time if you don't change your ways.

          Make sense?

          Comment


            #6
            I'm not talking about tick or volume charts which are different on almost any reload.
            What about M5 bars and 24/7 as trading hours template?
            Attached Files

            Comment


              #7
              Hello td_910,

              Thanks for your notes.

              bltdavid has provided some great information on this topic.

              The script has multiple data series added and 5 60-minute bars would be 3 hours whereas 5 1-minute bars is 5 minutes.

              As bltdavid mentioned, using 'Days to load' on one chart and using 'Bars to load' on another chart would cause a discrepancy with how the indicator is behaving. Both charts should be set to the exact same 'Load data based on' setting of 'Days' when comparing the indicator on separate charts to ensure the exact same data is being used.

              As a general rule, if you are using a multi-series script you should not load data based on Bars. Instead, make sure that you are loading data based on Days when using multi-series scripts.
              Brandon H.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_BrandonH View Post
                Hello td_910,

                Thanks for your notes.

                bltdavid has provided some great information on this topic.

                The script has multiple data series added and 5 60-minute bars would be 3 hours whereas 5 1-minute bars is 5 minutes.

                As bltdavid mentioned, using 'Days to load' on one chart and using 'Bars to load' on another chart would cause a discrepancy with how the indicator is behaving. Both charts should be set to the exact same 'Load data based on' setting of 'Days' when comparing the indicator on separate charts to ensure the exact same data is being used.

                As a general rule, if you are using a multi-series script you should not load data based on Bars. Instead, make sure that you are loading data based on Days when using multi-series scripts.
                Thanks for that. What still puzzles me is that the same number of bars are loaded (visible on the chart) with the same starting point...
                But let's just call it a discrepancy... LOL

                Just need to always tell a user to load data based on days... or is there a way to check that

                Comment


                  #9
                  Hello td_910,

                  Thanks for your notes.

                  There would be no supported NinjaScript methods or properties to set the chart's data series to use Load Data Based On Days.

                  In the script you could get what 'Load data based on' value the chart's data series is using with ChartBars.Properties.RangeType.

                  Note that ChartBars.Properties.RangeType could be used in State.DataLoaded in OnStateChange() or in OnBarUpdate().
                  Brandon H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by llanqui, Today, 03:53 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post llanqui
                  by llanqui
                   
                  Started by burtoninlondon, Today, 12:38 AM
                  0 responses
                  10 views
                  0 likes
                  Last Post burtoninlondon  
                  Started by AaronKoRn, Yesterday, 09:49 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post AaronKoRn  
                  Started by carnitron, Yesterday, 08:42 PM
                  0 responses
                  11 views
                  0 likes
                  Last Post carnitron  
                  Started by strategist007, Yesterday, 07:51 PM
                  0 responses
                  14 views
                  0 likes
                  Last Post strategist007  
                  Working...
                  X