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

Printing DayOfWeek

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

    Printing DayOfWeek

    Hi,

    I'm trying to write a strategy that will (among other things) write the day of week to the output window. I'm trying the following but it doesn't seem to work:

    Print(Time[0].DayOfWeek)

    Is that not the right format? I also tried Print(Time[0].DayOfWeek.ToString) but that's asking for an Object Reference also (I thought Time[0] was the object?).

    Thanks,

    Sniff

    #2
    Hello Sniff,

    Thanks for your post.

    The code Print(Time[0].DayOfWeek) works. The code Print(Time[0].DayOfWeek.ToString) will work if you add () to the ToString, for example: Print(Time[0].DayOfWeek.ToString())

    Here is an example I tested (on 1 minute bars) with and the example output.

    Code:
    			if (ToTime(Time[0]) >= ToTime(0, 0, 0) && ToTime(Time[0]) <= ToTime(0, 0, 1))
    			{
    				Print ("Day using ToString() " + Time[0].DayOfWeek.ToString());
    				Print ("Day w/o ToString() " + Time[0].DayOfWeek);
    			}
    Day using ToString() Monday
    Day w/o ToString() Monday
    Day using ToString() Tuesday
    Day w/o ToString() Tuesday
    Day using ToString() Wednesday
    Day w/o ToString() Wednesday
    Day using ToString() Thursday
    Day w/o ToString() Thursday
    Day using ToString() Friday
    Day w/o ToString() Friday
    Day using ToString() Monday
    Day w/o ToString() Monday
    Day using ToString() Tuesday
    Day w/o ToString() Tuesday
    Day using ToString() Wednesday
    Day w/o ToString() Wednesday
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul! Print(Time[0].DayOfWeek.ToString()) worked great.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by ct, 05-07-2023, 12:31 PM
      6 responses
      202 views
      0 likes
      Last Post wisconsinpat  
      Started by kaywai, Today, 06:26 AM
      0 responses
      1 view
      0 likes
      Last Post kaywai
      by kaywai
       
      Started by kevinenergy, 02-17-2023, 12:42 PM
      118 responses
      2,778 views
      1 like
      Last Post kevinenergy  
      Started by briansaul, Today, 05:31 AM
      0 responses
      9 views
      0 likes
      Last Post briansaul  
      Started by traderqz, Yesterday, 12:06 AM
      11 responses
      28 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X