Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Working with Time and Date

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

    Working with Time and Date

    Hello,

    I can use the Time on current day for indicators and script like if(ToTime(Time[0]) >= 093000 && ToTime(Time[0]) < 161500) then do..
    And I can work with Date like if(Time[0].DayOfWeek != DayOfWeek.Sunday) then do...

    But I dont know how to use Date like "if(Today and ToTime>9:30....) then do" and "if(Yesterday and ToTime>9:30...)" then do....

    Didnt understand it from helpguide (I understand the sample there) nor from forum.

    Thank you!
    Tony

    #2
    Hello tonynt,

    Thank you for your post.

    To confirm, when you say today, you mean the current date of incoming data, not, say, the current date of the bar being processed, is that correct?

    You could do something like this:

    if (DateTime.Now.Date == Time[0].Date)
    {
    //do something
    }

    For yesterday's date, you could do:

    if (DateTime.Now.AddDays(-1).Date == Time[0].Date)
    {
    // do something
    }

    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Hello Kate,

      thank you for your reply. Yes, I mean current date of incoming data. I try to work out with this now what I need.

      Thank you for your support!
      Tony

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      128 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      74 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      116 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      110 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      89 views
      0 likes
      Last Post CarlTrading  
      Working...
      X