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, 05-11-2026, 05:56 AM
0 responses
63 views
0 likes
Last Post CarlTrading  
Started by CarlTrading, 05-10-2026, 08:12 PM
0 responses
35 views
0 likes
Last Post CarlTrading  
Started by Hwop38, 05-04-2026, 07:02 PM
0 responses
199 views
0 likes
Last Post Hwop38
by Hwop38
 
Started by CaptainJack, 04-24-2026, 11:07 PM
0 responses
365 views
0 likes
Last Post CaptainJack  
Started by Mindset, 04-21-2026, 06:46 AM
0 responses
283 views
0 likes
Last Post Mindset
by Mindset
 
Working...
X