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 kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      27 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      17 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      23 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      22 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      137 views
      0 likes
      Last Post SalmaTrader  
      Working...
      X