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 NullPointStrategies, Yesterday, 05:17 AM
0 responses
56 views
0 likes
Last Post NullPointStrategies  
Started by argusthome, 03-08-2026, 10:06 AM
0 responses
132 views
0 likes
Last Post argusthome  
Started by NabilKhattabi, 03-06-2026, 11:18 AM
0 responses
73 views
0 likes
Last Post NabilKhattabi  
Started by Deep42, 03-06-2026, 12:28 AM
0 responses
45 views
0 likes
Last Post Deep42
by Deep42
 
Started by TheRealMorford, 03-05-2026, 06:15 PM
0 responses
49 views
0 likes
Last Post TheRealMorford  
Working...
X