• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

finding calculating time difference

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

    finding calculating time difference

    hi
    could someone help me how to find out todays firstbarofsession time and then subtract 24 hours from it

    #2
    easyfying, you mean something like the below snippet?

    if (Bars.FirstBarOfSession)
    test = Time[0].AddHours(24);

    That would Add 24 hrs to the end bar time of the first bar of the session.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      basically what i am trying to plot is if its an upday ,the complete session colour should be green and if its down day it shoud be red.following is my code but it only drawss the last bar of session...pls advise
      Code:
      if ( Bars.BarsSinceSession >=0)
                      
                  {
                  if ((CurrentDayOHL().CurrentOpen[0] < Close[0]) &&  (ToTime(Time[0]) > 215900))
                      
                      {
                          BackColor = Color.FromArgb(100, Color.LightGreen);
                          
                      }
                  
                  if ((CurrentDayOHL().CurrentOpen[0] > Close[0]) &&  (ToTime(Time[0]) > 215900))
                      {
                          BackColor = Color.FromArgb(100, Color.LightPink);
                      }
                  }

      Comment


        #4
        easyfying, that's because you chose to do the coloring only from a certain time on for the bars where the condition holds true, you're not coloring the past bars at this point.

        You can do that however with the BackColorSeries by providing how many bars back to color via the index - http://www.ninjatrader.com/support/h...olorseries.htm
        BertrandNinjaTrader Customer Service

        Comment


          #5
          yes i thought about it but problem is i am developing indicator for linebreak chart and there i cant give exact number of bars since session begin...because everyday there will be different numbers of bars formed

          Comment


            #6
            easyfying, correct but the BarsSinceSession property should reflect that. It would not be a static amount for the time based session, so giving you the actual bar count per session.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              thanks.
              i wanted to plot background colour depending upon if the session was up or down.below code is working for me.but problem is the indicator shows rectangle only for previous day and not for all days.

              Code:
                          if (Bars.FirstBarOfSession)
                          {
                              if(PriorDayOHLC().PriorOpen[0] < PriorDayOHLC().PriorClose[0])
                              
                                  
                                  {
                                      DrawRectangle("Colorupdown", true, Time[1], PriorDayOHLC().PriorLow[0], Time[1].AddHours(-24), PriorDayOHLC().PriorHigh[0], Color.Transparent, Color.Green,2);
                         
                                  }
                              
                          else if(PriorDayOHLC().PriorOpen[0] > PriorDayOHLC().PriorClose[0])
                              
                                  
                                  {
                                      DrawRectangle("Colorupdown", true, Time[1], PriorDayOHLC().PriorLow[0], Time[1].AddHours(-24), PriorDayOHLC().PriorHigh[0], Color.Transparent, Color.Pink,2);
                         
                                  }
                          }

              Comment


                #8
                The issue here is that you're really only drawing / modifying one object all the time by using the same tag id - namely the Colorupdown

                When you are settings things for the new day / session you want to use a new tag id as well so a new draw object would get created and you would be able to see the history as desired.

                http://www.ninjatrader.com/support/f...ead.php?t=3419
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  thank you.it solved it..

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Leope, Today, 03:15 AM
                  0 responses
                  6 views
                  0 likes
                  Last Post Leope
                  by Leope
                   
                  Started by Frook1951, Today, 03:09 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Frook1951  
                  Started by unlobotrader, Today, 02:46 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post unlobotrader  
                  Started by greg6622, Today, 01:26 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post greg6622  
                  Started by Splex, Today, 12:04 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post Splex
                  by Splex
                   
                  Working...
                  X