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

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 DJ888, Yesterday, 10:57 PM
          0 responses
          6 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          158 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          7 views
          0 likes
          Last Post Belfortbucks  
          Started by zstheorist, Yesterday, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          151 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Working...
          X