Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ScottWalsh, Today, 06:52 PM
4 responses
32 views
0 likes
Last Post ScottWalsh  
Started by olisav57, Today, 07:39 PM
0 responses
4 views
0 likes
Last Post olisav57  
Started by trilliantrader, Today, 03:01 PM
2 responses
19 views
0 likes
Last Post helpwanted  
Started by cre8able, Today, 07:24 PM
0 responses
6 views
0 likes
Last Post cre8able  
Started by Haiasi, Today, 06:53 PM
1 response
5 views
0 likes
Last Post NinjaTrader_Manfred  
Working...
X