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

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)?
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        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.
                Paul H.NinjaTrader Customer Service

                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]));
                        Paul H.NinjaTrader Customer Service

                        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 Aviram Y, Today, 05:29 AM
                          3 responses
                          10 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by algospoke, 04-17-2024, 06:40 PM
                          3 responses
                          26 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by bmartz, 03-12-2024, 06:12 AM
                          3 responses
                          30 views
                          0 likes
                          Last Post NinjaTrader_Zachary  
                          Started by gentlebenthebear, Today, 01:30 AM
                          1 response
                          8 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by cls71, Today, 04:45 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X