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

AddDataSeries Number of bars 6 charts/timeframes

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

    AddDataSeries Number of bars 6 charts/timeframes

    I am struggling to work with the limitations of AddDataSeries. Can someone clarify if this is correct. I have 6 charts displayed on a screen. 5 m, 30m, 60m, daily, weekly, monthtly all using candlestick type, displaying the same symbol. I have a time frame continuity indicator that shows those time frames in the top right of each chart(screen attached). It very simply displays the time green or red if its up or down since the open. If I want this to work on all 6 charts, I need to load: 8,920(ish) bars because that's how many 5 min candles (my lowest time frame) are in a month (my highest time frame).

    First, is my understanding right about right? Second if anyone has a clever way to load a new bar type so I can overload the data series # of bars per time frame, or specific code placements tips so it does not calculate more than they needed for each time frame, etc. in an attempt to make this relatively light indicator without bogging it down with an inordinateamount of bars that I only need for a simple calculation. It seems my best course would be loading a different bar type so I can use the overload feature of AddDataSeries, but that is where my knowledge tops out as a new NT user.

    Thanks for any help!

    Image image hosted in ImgBB

    #2
    Hello UncleRyan,

    A script will not start processing data until all series have at least one bar.

    This does mean that you would need to load the same amount of data on all of the series no matter the size or interval.

    While this can load more data than you really need, there isn't a work around for this when using AddDataSeries() and the data will need to load in the entirety.

    With a BarsRequest, this would allow you to pull data out of sync and manipulate this data how you would like, however note that data cannot be supplied to indicators.



    The AddDataSeries() method does have a barsToLoad method but this only works when selecting a different instrument.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      According to the manual:
      When adding multiple Data Series of the same instrument and the same Bar Type, the 'barsToLoad' property will only be effective on the first added series. Subsequent series with a different barsToLoad setting will not load a different number of bars then the first series.

      From this I would interpret that I could load - say a OHLC bar of the same instrument and that would allow me to use barstoload.or there is no way with the same instrument?

      Lastly - even when I load enough bars I often get the error that's basically "you tried to reference 5 when you only loaded 4".. If I know I am loading enough bars what would this tend to indicate?

      Thanks

      Comment


        #4
        Hello UncleRyan,

        Thanks for your reply.

        Well, OHLC is a chart style in Ninjatrader and not a bar type. It would need to be a bar type as found in the Type field of the data series window.

        "Lastly - even when I load enough bars I often get the error that's basically "you tried to reference 5 when you only loaded 4".. If I know I am loading enough bars what would this tend to indicate?" This error has no bearing on the amount of bars loaded by the data series. It relates to the sequence of bars that the script is processing. All scripts will start on the very first bar in the data series and will execute your code on each bar in sequence up to the latest bar in the series. If on the first historical bar you try to access a previous bar then the script does not know of a previous bar and will produce that type error. The same thing would be true at any time you access a previous bars ago that exceeds the first bar of the data, for example on the 100th bar if you try to access a bar ago of 101 you would get that error. You would need to review your code for what bars ago you are accessing and when and then adjust your script by using a CurrentBars check to ensure that your script does not process until that number of bars have been processed above the current bars check. Please see the help guide here: https://ninjatrader.com/support/help...urrentbars.htm

        To gain a better overview of multi time frame considerations, please take the time to review: https://ninjatrader.com/support/help...nstruments.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks a lot, Paul - that was very helpful!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cls71, Today, 04:45 AM
          0 responses
          1 view
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          213 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          544 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          12 views
          0 likes
          Last Post XXtrader  
          Working...
          X