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

Displaying the Day of the Week (DOW)

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

    Displaying the Day of the Week (DOW)

    Hi,

    I'm using intraday charts and I would like to be able to display the Day Of the Week on the chart i.e. bottom left beside the session start vertical line.
    This way, when I scroll back through the charts, it displays the actual day of the week beside each new session.
    I have tried the following and it sort of works. i.e. if I leave out the IF statement and just use the switch, I can get it to display on the far left (not session start). With the if statement I get nothing.

    if (Bars.FirstBarOfSession)
    {
    switch (Time[0].DayOfWeek)
    //switch (Bars.GetTime.dayofweek)
    {
    case DayOfWeek.Monday : DOW = "Monday" ; break ;
    case DayOfWeek.Tuesday : DOW = "Tuesday" ; break ;
    case DayOfWeek.Wednesday : DOW = "Wednesday" ; break ;
    case DayOfWeek.Thursday : DOW = "Thursday" ; break ;
    case DayOfWeek.Friday : DOW = "Friday" ; break ;
    case DayOfWeek.Saturday : DOW = "Saturday" ; break ;
    case DayOfWeek.Sunday : DOW = "Sunday" ; break ;
    }
    graphics.DrawString("DOW = " + DOW, ChartControl.Font, textBrush, bounds.X , bounds.Y + bounds.Height - (50+textHeight), stringFormat);
    }



    Any ideas?

    Thanks,
    Neil.

    #2
    Neil, did you try adding prints to check if the FirstBarOfSession is triggering as you would expect in your script? It would just evaluate to 'true' if the bar detected is starting a new session, it would not effect the relative placement of your custom graphcis.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi,
      I have the below code in the OnBarUpdate. In the Output box, I get the days of the week scrolling through but on my chart I always get Tuesday, which happens to be the last traded day.

      Also, how do I tie this to the session open time? i.e. print below the first bar of each new session?

      string DOW = "";
      if (Bars.FirstBarOfSession)
      {
      switch (Time[0].DayOfWeek)
      //switch (Bars.GetTime.dayofweek)
      {
      case DayOfWeek.Monday : DOW = "Monday" ; break ;
      case DayOfWeek.Tuesday : DOW = "Tuesday" ; break ;
      case DayOfWeek.Wednesday : DOW = "Wednesday" ; break ;
      case DayOfWeek.Thursday : DOW = "Thursday" ; break ;
      case DayOfWeek.Friday : DOW = "Friday" ; break ;
      case DayOfWeek.Saturday : DOW = "Saturday" ; break ;
      case DayOfWeek.Sunday : DOW = "Sunday" ; break ;
      }
      DrawTextFixed("DOW", DOW, TextPosition.BottomLeft);
      Print("Printed "+DOW);
      }
      Last edited by NWT27; 11-09-2010, 03:38 PM.

      Comment


        #4
        Hello NWt27,

        You will likely want to use DrawText(), as DrawTextFixed() places one object in a static position on the chart. It will use the last bar to get its values.

        if (Bars.FirstBarOfSession)
        DrawText("DOW" + CurrentBar, Time[0].DayOfWeek.ToString(), 0, Low[0] - TickSize * 15, Color.Black);
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Perfect, Thanks.

          And so much simpler than mine

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alifarahani, Today, 09:40 AM
          6 responses
          36 views
          0 likes
          Last Post alifarahani  
          Started by Waxavi, Today, 02:10 AM
          1 response
          17 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by Kaledus, Today, 01:29 PM
          5 responses
          14 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Waxavi, Today, 02:00 AM
          1 response
          12 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by gentlebenthebear, Today, 01:30 AM
          3 responses
          17 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X