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

Bar Date

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

    Bar Date

    Hi all,

    I would like to know how I can compare a bar date with system date

    Thanks

    Dervakon

    #2
    Hello,

    A bar's time stamp is Time[0].
    Your system clock is Date.Time.Now

    There is NinjaScript method ToDay() that takes the day portion of a date/time object and converts to integer. You can also use C# methods for comparing date / time.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan,

      But my problem is when I use
      protectedoverridevoid OnBarUpdate() Is always downloading all the bar you got on your chart.


      Me I want to do this; is the bar date is not equal to the date system skip it


      Thanks


      Dervakon

      Comment


        #4
        How I can convert Time[0]. to Date.Time.Now so I can compare them...

        Thanks

        Dervakon

        Comment


          #5
          if (ToDay(Time[0]) != ToDay(DateTime.Now))
          {
          //do something
          }
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thank you for your help...

            Comment


              #7
              Another question,

              With the same
              if (ToDay(Time[0]) != ToDay(DateTime.Now))
              {
              //do something
              }

              How I can compare minute to minute...

              Thanks

              Comment


                #8
                You can use NinjaScript method ToTime() to take the time portion of a date / time object and convert to integer.

                Please see this reference sample for additional help working with date / time objects:
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by Dervakon View Post
                  Another question,

                  With the same
                  if (ToDay(Time[0]) != ToDay(DateTime.Now))
                  {
                  //do something
                  }

                  How I can compare minute to minute...

                  Thanks
                  Code:
                  Time[0].Minute != DateTime.Now.Minute

                  Comment


                    #10
                    Thank you Koganam

                    This will help

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by pkefal, 04-11-2024, 07:39 AM
                    11 responses
                    36 views
                    0 likes
                    Last Post jeronymite  
                    Started by bill2023, Yesterday, 08:51 AM
                    8 responses
                    44 views
                    0 likes
                    Last Post bill2023  
                    Started by yertle, Today, 08:38 AM
                    6 responses
                    25 views
                    0 likes
                    Last Post ryjoga
                    by ryjoga
                     
                    Started by algospoke, Yesterday, 06:40 PM
                    2 responses
                    24 views
                    0 likes
                    Last Post algospoke  
                    Started by ghoul, Today, 06:02 PM
                    3 responses
                    16 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Working...
                    X