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

Loading multiple data series by number of bars

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

    Loading multiple data series by number of bars

    I have an indicator that uses three data series: one for minutes, one for seconds and one for ticks. When I load data by Days, the indicator works correctly across the chart, but when I load by number of Bars, it misses signals apart from the last few bars on the chart. Is this because, when I load, say, 3000 bars (which would give just over two days of 1-minute data, I also get 3000 bars of second data and 3000 bars of tick data?
    If that's not the case, and loading 3000 1-minute bars will actually load the equivalent number of 1-second bars (180,000) and the corresponding number of tick bars, can you suggest any reason why the loading of days and loading of bars would make the indicator work differently?
    Thanks

    #2
    Hello Scotty33,

    May I confirm that you are writing a value for every plot bar, even when the other series are not updating?

    Use prints and confirm that IsValidDataPoint() is true for every bar.


    Below is a link to a forum post that demonstrates using prints to understand behavior.


    Below is a link to an example of plotting values from a another time frame.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea, thanks for your reply.

      I ran a test which proves that when you load by Bars, the number of bars loaded is the same for all series. So, in my case, I entered 1000 bars, and the data loaded consisted of 1000 1-minute bars, 1000 tick bars and 1000 1-second bars.

      I inserted the following line in the OnBarUpdate code:
      Print(string.Format("OnBarUpdate Bar {0} Time {1: o} BarsInProgress {2} Close {3}", CurrentBar, Time[0], BarsInProgress, Close[0]));

      Having loaded 1000 bars at approx. 10:43 local time (NY + 6), the main 1-minute chart started at 16:48 on February 12, and the output report shows bar 0 for BarsInProgress 0 (the 1-minute series) at that time.
      Bar 0 for the tick chart (BarsInProgress 2) doesn’t appear until 09:28 on February 15, at which time the 1-minute series is on bar 925.
      Bar 0 for the 1-second chart appears at 10:31, with the 1-minute series now on bar 988 and the tick series on bar 885.
      At 10:43, all three series are on bar 999. Here’s an extract from the Output file at that time:


      OnBarUpdate Bar 997 Time 2021-02-15T10:42:40.9290000 BarsInProgress 1 Close 3947
      OnBarUpdate Bar 998 Time 2021-02-15T10:42:41.0000000 BarsInProgress 2 Close 3947
      OnBarUpdate Bar 998 Time 2021-02-15T10:42:41.0000000 BarsInProgress 2 Close 3947
      OnBarUpdate Bar 999 Time 2021-02-15T10:43:00.0000000 BarsInProgress 0 Close 3947.25
      OnBarUpdate Bar 999 Time 2021-02-15T10:43:00.0000000 BarsInProgress 0 Close 3947.25
      OnBarUpdate Bar 998 Time 2021-02-15T10:42:43.9060000 BarsInProgress 1 Close 3947.25
      OnBarUpdate Bar 999 Time 2021-02-15T10:42:43.9060000 BarsInProgress 1 Close 3947.25
      OnBarUpdate Bar 999 Time 2021-02-15T10:42:44.0000000 BarsInProgress 2 Close 3947.25

      So, the difference is that when you load data using Days, all series will start from the same point in time. When you load data using bars, each series is loaded counting the number of bars back from the time at which the data load was initiated. This explains why I only saw signals at the end of the chart, because it was only then that all three data series were active.
      Lesson learned: always load data using Days when multiple time series are involved.
      Last edited by Scotty33; 02-15-2021, 05:24 AM.

      Comment


        #4
        Hello Scotty33,

        Your analysis is correct. The added series will use the same bars to load or days to load setting as the primary.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by ETFVoyageur, 05-07-2024, 07:05 PM
        10 responses
        70 views
        0 likes
        Last Post ETFVoyageur  
        Started by Zeezee, Today, 12:45 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Started by ldanenberg, Today, 03:19 PM
        0 responses
        2 views
        0 likes
        Last Post ldanenberg  
        Started by TheTradingMantis, 01-19-2023, 02:05 AM
        42 responses
        914 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by _Zero_, 04-10-2020, 03:21 PM
        144 responses
        7,896 views
        6 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X