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

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.
    Kate W.NinjaTrader Customer Service

    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 WHICKED, Today, 12:45 PM
      2 responses
      18 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by GussJ, 03-04-2020, 03:11 PM
      15 responses
      3,276 views
      0 likes
      Last Post xiinteractive  
      Started by Tim-c, Today, 02:10 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by Taddypole, Today, 02:47 PM
      0 responses
      3 views
      0 likes
      Last Post Taddypole  
      Started by chbruno, 04-24-2024, 04:10 PM
      4 responses
      51 views
      0 likes
      Last Post chbruno
      by chbruno
       
      Working...
      X