Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trouble with time update

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

    Trouble with time update

    Hi,

    I have built an indicator but it doesn't appear on the daily diagrams. When I do the debugging the orders after second "if" (see in the picture below) don't execute and I have observed that when I reload the ninjascript and see the time updates, it says that time is updated every day at 3. Can you tell me what's the problem with the daily charts and time?

    Thank you in advance
    Attached Files
    Last edited by Joleto; 08-10-2015, 06:43 AM.

    #2
    Hello Joleto,

    Thanks for your post.

    Whom are you connected to (datafeed) when you run this code?

    What is CalculateOnBarClose set to (True or false)?

    Comment


      #3
      Hello Paul,

      I am connected to CQG and CalculateOnBarClose is true.My code works good in Minute Charts but it doesn't work on Daily or Weekly...Any ideas?

      Comment


        #4
        Hello Joleto,

        Thanks for your reply.

        The issue would be that your code is set to CalculateOnBarClose (true) which means it will only execute once per bar, at the close of that bar. So it can only check that it is within the date/time requirements at the end of the day or end of the week when looking at daily or weekly data. On the lower time frames, such as minute bars, there are enough OnBarUpdates (once per bar) so that your code executes as expected.

        To check the date/time with greater frequency set the CalculateOnBarClose to false.

        Comment


          #5
          It still doesn't work with daily chart...In my code I use bar changes so maybe that's the reason.Check out a better sample of my code (I try to compare yesterday's and today's highs and lows)
          Attached Files

          Comment


            #6
            Originally posted by Joleto View Post
            It still doesn't work with daily chart...In my code I use bar changes so maybe that's the reason.Check out a better sample of my code (I try to compare yesterday's and today's highs and lows)
            What does your Print() show as ouput?

            Comment


              #7
              Open window

              These are the results.For some reason the time is always the same
              Attached Files
              Last edited by Joleto; 08-10-2015, 08:23 AM.

              Comment


                #8
                Hello Joleto,

                Thanks for your reply/post and to koganam for the prompt.

                Your prints show that the time is 7:00 AM. Your time check code below the print statement will not execute until 9:30.

                Comment


                  #9
                  Originally posted by Joleto View Post
                  These are the results.For some reason the time is always the same
                  Your time says: "70000": your filter is entered between "93000" and "160000". Ergo, your filtered block is never entered, so the code cannot be executed. The lesson is that you cannot filter intraday times on a daily chart. A computer can only process data that actually exists.

                  Comment


                    #10
                    Yes but i guess that the indicator should have given results for previous dates as well.

                    Comment


                      #11
                      Aha I understand...So the indicator cannot show me result for past data,am I right?

                      Comment


                        #12
                        Hello Joleto,

                        Thanks for your reply.

                        On a closer look at your code, you are using ToTime(Time[0]) which will only provide the end time of the bar. So on daily bars it will show the end time of that daily bar. What you would need to do is to test for the current time. If you use DateTime.Now() that would provide a realtime time check.

                        Print (DateTime.Now.ToString()+" "+ToDay(Time[0])+ " "+ ToTime(Time[0]));

                        Comment


                          #13
                          Originally posted by Joleto View Post
                          Aha I understand...So the indicator cannot show me result for past data,am I right?
                          It should show prints for all the days on the chart that satisfy the filter.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          601 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          347 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          103 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          559 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          558 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X