Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator on indicator referencing Time[0]

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

    Indicator on indicator referencing Time[0]

    NT Team,

    When working with a standard price DataSeries (e.g. ^SP500), "Time[0]" references the time value of bar[0]. However, an indicator based on the DataSeries (e.g. SMA(^SP500, 10)) has no time values. Therefore, "Time[0]" equals 1 January 1800.

    To restate, it is my understanding the indicator has no time values. This is OK in itself. However where an indicator based on an indicator requires time values an issue presents.

    In an indicator on an indicator, how can I retrieve a useable Time[0]?
    Is it possible to "look through" an indicator to its input DataSeries and retrieve its time values?

    As always, thanks a bunch
    Shannon

    #2
    Have you tried to put a Print(); statement on it? For example Print("Time:" +Time[0].ToString()); to see a printed time in the output window.

    Comment


      #3
      Originally posted by Shansen View Post
      NT Team,

      When working with a standard price DataSeries (e.g. ^SP500), "Time[0]" references the time value of bar[0]. However, an indicator based on the DataSeries (e.g. SMA(^SP500, 10)) has no time values. Therefore, "Time[0]" equals 1 January 1800.

      To restate, it is my understanding the indicator has no time values. This is OK in itself. However where an indicator based on an indicator requires time values an issue presents.

      In an indicator on an indicator, how can I retrieve a useable Time[0]?
      Is it possible to "look through" an indicator to its input DataSeries and retrieve its time values?

      As always, thanks a bunch
      Shannon
      All indicators are based on the barSeries, which is one-to-one bound to the current Time series. IOW, the problem that you describe does not exist. Time[0] is always the time on Bar[0], and so always the time on any indicator that is being evaluated on Bar[0].

      Comment


        #4
        luxurious_04 & koganam,

        Thanks for the quick reply.

        As a thought experiment, please create a new indicator with the below code:
        Code:
        protected override void OnBarUpdate() {
          Print (CurrentBar.ToString() + " = " + Time[0].ToString());			
        }
        On a chart of your choosing, please add the indicator. Modify the input series from the default instrument to a SMA on the instrument. In the attached screenshot, the indicator input series has been altered from ^SP500 (60 Min) to SMA(^SP500 (60 Min), 14).

        In the output window, the thought experiment returns:
        0 = 1/01/1800 12:00:00 AM
        1 = 1/01/1800 12:00:00 AM
        2 = 1/01/1800 12:00:00 AM
        3 = 1/01/1800 12:00:00 AM
        4 = 1/01/1800 12:00:00 AM
        ....
        Again, in this situation how can a useable Time[0] be retrieved?
        Is it possible to "look through" the indicator to its input series and retrieve its time values?
        While a secondary barsArray could be added to the indicator on indicator (identical to the original indicator's input series) and then time values extracted from there, it does not seem like efficient code.

        Thanks again
        Shannon
        Attached Files

        Comment


          #5
          Hello,

          Thank you for your detailed post.

          This is a current expected limitation when changing the input series. We're looking to improve this handling in a future release however I do not have an ETA on when this will change.

          In the mean time, the only workaround I know of is adding another bars array.
          MatthewNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          587 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          341 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          555 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          552 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X