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 yertle, Yesterday, 08:38 AM
      7 responses
      28 views
      0 likes
      Last Post yertle
      by yertle
       
      Started by bmartz, 03-12-2024, 06:12 AM
      2 responses
      20 views
      0 likes
      Last Post bmartz
      by bmartz
       
      Started by funk10101, Today, 12:02 AM
      0 responses
      4 views
      0 likes
      Last Post funk10101  
      Started by gravdigaz6, Yesterday, 11:40 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by MarianApalaghiei, Yesterday, 10:49 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X