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 Perr0Grande, Today, 08:16 PM
      0 responses
      2 views
      0 likes
      Last Post Perr0Grande  
      Started by elderan, Today, 08:03 PM
      0 responses
      5 views
      0 likes
      Last Post elderan
      by elderan
       
      Started by algospoke, Today, 06:40 PM
      0 responses
      10 views
      0 likes
      Last Post algospoke  
      Started by maybeimnotrader, Today, 05:46 PM
      0 responses
      11 views
      0 likes
      Last Post maybeimnotrader  
      Started by quantismo, Today, 05:13 PM
      0 responses
      7 views
      0 likes
      Last Post quantismo  
      Working...
      X