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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      89 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      133 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X