Announcement

Collapse
No announcement yet.

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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      51 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      31 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      99 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      177 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      170 views
      0 likes
      Last Post CarlTrading  
      Working...
      X