Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time issue

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

    Time issue

    if(DateTime.Now.Date == DateTime.Today && ToTime(Time[0]) > 093000 )

    I read this as do something when it's today and after 930 am.
    is this correct?

    if It is then I have an issue lol!

    #2
    Yes lah......

    Tell us the issues, bro,

    Comment


      #3
      I want to draw a ray from an indicator only between those 2 times and only for today.
      Each time it ignores the day - but does follow the time.

      if(DateTime.Now.Date == DateTime.Today && ToTime(Time[0]) > 093000 )
      blueray = Draw.Ray(this,"p"+CurrentBar,Time[0],Close[0] ,midnight,Close[0],IsRayGlobal,"Blue Ray");

      I should add I also get object doesn't exist errors as well!!

      Comment


        #4
        I simply don't understand why it reads yesterday's bars as today?

        Comment


          #5
          Hello Mindset,

          What do you mean it reads yesterdays bars as today? Are you seeing this drawn on the wrong bar or what specifically is the problem that you see?

          Time[0] represents the last closed bar, depending on what series you used that may be yesterday if you are using a Daily series.

          DateTime.Now is your PC clock which holds no relevance toward NinjaScript, Generally you should avoid using this in your code, the Date and Time will always be from Today right now. If you need to reference the PC clock you should do so using the correct property which includes the platforms time offset settings. NinjaTrader.Core.Globals.Now


          I look forward to being of further assistance.


          JesseNinjaTrader Customer Service

          Comment


            #6
            Ok so how do I properly ( Ninjascript wise) check that now is today?
            i tried == DateTime.Today and also ToDay(Time[0]) - both produce errors
            Last edited by Mindset; 01-13-2021, 12:39 AM.

            Comment


              #7
              Hello Mindset,

              You can use NinjaTrader.Core.Globals.Now. That variable represents the equivalent of DateTime.Now, its the PC time including the timezone settings you set in the options menu.

              You could compare the processing bar time against NinjaTrader.Core.Globals.Now to know if that bar was today.

              Code:
              if(NinjaTrader.Core.Globals.Now.Date == Time[0].Date)
              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Thanks very much Jesse. Time[0].Date - so simple!!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Cimhripljwe, Today, 10:18 PM
                0 responses
                2 views
                0 likes
                Last Post Cimhripljwe  
                Started by TimothyDavis, Today, 09:37 PM
                0 responses
                2 views
                0 likes
                Last Post TimothyDavis  
                Started by cetrtrew, Today, 09:35 PM
                0 responses
                1 view
                0 likes
                Last Post cetrtrew  
                Started by smcllr, Today, 04:15 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ShawnB  
                Started by rtwave, Today, 02:33 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Kate  
                Working...
                X