Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to check for Time being valid?

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

    How to check for Time being valid?

    How should I check to see whether Time is valid before trying to access it?
    • Time is often non-null, but still invalid, so that does not work
    • Time.Count throws if accessed before Time is valid. Technically one could do a try...catch, but that is not really a very satisfactory method
    • I know from the debugger that Time is sometimes valid and sometimes NULL when State >=State.Historical. I do not like a state-based method anyway, because it is subject to breaking in the future if the implementation changes
    • ISeries supports IsValidDataPoint(0), but unfortunately TimeSeries does not

    What I am really looking for is a way to directly test whether or not Time is yet valid. Any suggestions will be appreciated.

    Thanks,
    --EV
    Last edited by ETFVoyageur; 08-05-2015, 03:46 AM.

    #2
    If you're talking about the TimeSeries associated with data bars, as long as CurrentBar != -1, the value of the Time[0] should be set.

    Code:
    if(CurrentBar != -1)
         Print(Time[0]);
    MatthewNinjaTrader Product Management

    Comment


      #3
      Originally posted by ETFVoyageur View Post
      How should I check to see whether Time is valid before trying to access it?
      • Time is often non-null, but still invalid, so that does not work
      • Time.Count throws if accessed before Time is valid. Technically one could do a try...catch, but that is not really a very satisfactory method
      • I know from the debugger that Time is sometimes valid and sometimes NULL when State >=State.Historical. I do not like a state-based method anyway, because it is subject to breaking in the future if the implementation changes
      • ISeries supports IsValidDataPoint(0), but unfortunately TimeSeries does not

      What I am really looking for is a way to directly test whether or not Time is yet valid. Any suggestions will be appreciated.

      Thanks,
      --EV
      Time of "what"? And how do you mean "valid"? What is the determinant of validity? A time is a time.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, Today, 06:46 AM
      0 responses
      8 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, Yesterday, 05:21 PM
      0 responses
      12 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      15 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      82 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      47 views
      0 likes
      Last Post PaulMohn  
      Working...
      X