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

Compare bar date to todays date

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

    Compare bar date to todays date

    I am sure this is on the forum someplace but what can I use to compare the bar date to today.

    If ToDay(Time[0]) if the date of the bar (in ccyymmdd format), how can I compare that to see if the bar is today or a previous day. I want to display statistics on the screen and show various stats for just today (but I want to load the chart for the last week).

    I know I can input a variable and compare against that but I am looking to just use the current date (and not have to change an input variable everytime).

    #2
    Hello gregm,

    Thank you for your post and welcome to the NinjaTrader Support Forum.

    You can compare a bar to the current day by using Time[0].Date and DateTime.Today:
    Code:
    if (Time[0].Date == DateTime.Today)
    {
    //Do something.
    }
    For information on Time please visit the following link: http://www.ninjatrader.com/support/h....html?time.htm
    For information on the DateTime structure please visit the following link: http://msdn.microsoft.com/en-us/libr....datetime.aspx

    Please let me know if I may be of further assistance.

    Comment


      #3
      thanks - works great !!

      -greg

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rbeckmann05, Yesterday, 06:48 PM
      1 response
      12 views
      0 likes
      Last Post bltdavid  
      Started by llanqui, Today, 03:53 AM
      0 responses
      6 views
      0 likes
      Last Post llanqui
      by llanqui
       
      Started by burtoninlondon, Today, 12:38 AM
      0 responses
      10 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      15 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      11 views
      0 likes
      Last Post carnitron  
      Working...
      X