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 Mindset, 04-21-2026, 06:46 AM
0 responses
89 views
0 likes
Last Post Mindset
by Mindset
 
Started by M4ndoo, 04-20-2026, 05:21 PM
0 responses
135 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by M4ndoo, 04-19-2026, 05:54 PM
0 responses
68 views
0 likes
Last Post M4ndoo
by M4ndoo
 
Started by cmoran13, 04-16-2026, 01:02 PM
0 responses
119 views
0 likes
Last Post cmoran13  
Started by PaulMohn, 04-10-2026, 11:11 AM
0 responses
69 views
0 likes
Last Post PaulMohn  
Working...
X