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 wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Started by andrewtrades, Today, 04:57 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X