Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using DateTime.Now to Fetch Current Day of Week

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

    Using DateTime.Now to Fetch Current Day of Week

    Hello Ninjatrader staff,

    When I use a command to Print(DateTime.Now.DayOfWeek), the output is correctly letting me know that today is Wednesday.
    However, when I use a command to check if(DateTime.Now.DayOfWeek == Wednesday), I am receiving the error of "The name 'Wednesday' does not exist in the current context."
    What can I do within Ninjascript to solve this problem? I have to use DateTime.Now, and I can not use ToDay(), as the former uses the time of my PC, while the latter uses the timestamp of the bar index, something that is not available on a Saturday or Sunday.

    Thank you in advance for your time, I look forward to your answer.

    Best wishes,

    GLFX005

    Solution: Sorry for the post, although I hope that this post may help others in the future. The problem was in my code. I had to write if(DateTime.Now.DayOfWeek == DayOfWeek.Wednesday).
    Last edited by GLFX005; 08-10-2022, 03:41 AM.

Latest Posts

Collapse

Topics Statistics Last Post
Started by CarlTrading, 03-31-2026, 09:41 PM
1 response
45 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by CarlTrading, 04-01-2026, 02:41 AM
0 responses
21 views
0 likes
Last Post CarlTrading  
Started by CaptainJack, 03-31-2026, 11:44 PM
0 responses
31 views
1 like
Last Post CaptainJack  
Started by CarlTrading, 03-30-2026, 11:51 AM
0 responses
50 views
0 likes
Last Post CarlTrading  
Started by CarlTrading, 03-30-2026, 11:48 AM
0 responses
42 views
0 likes
Last Post CarlTrading  
Working...
X