Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Search for a bar by its time

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

    #16
    Hello Stanfillirenfro,

    Thanks for your reply.

    Whew, glad that is working!

    The difference is that the script you just ran print on every historical bar and TestforStan waits for a real time bar to close before it will print. So on the 1 minute chart of NQ 06-21, please add the indicator bar timer and then add the indicator TestforStan, when you see the time gets to zero you should expect to see prints.

    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Paul, many thanks one more time. But what happened in between? I have just repeated the procedure this time with the file you posted in #8 and it is working also now? WHat happened in betwen?

      Many thanks fir your help.
      I will revert to you after improving my entire code.

      Comment


        #18
        Hello Stanfillirenfro,

        Thanks for your reply.

        I can only surmise that it was just a matter of waiting for a bar close to occur.

        It is critical though that you be able to send prints to the output window because using prints is a key part of debugging and should be your first step when the code is not working as expected.

        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Hi Paul!
          Let's imagine that I have a long code, not just few linnes, let's say with loops etc... Would I have any problem printing something if the condition in the code in #8 in place not direct a the beginning of protected override void OnBarUpdate()? Where should I place " if(State == State.Historical)" in "protected override void OnBarUpdate()"in order to print properly?

          Comment


            #20
            Hello Stanfillirenfro,

            Thanks for your reply.

            Good questions.

            The code if(State == State.Historical) return; is used to skip over historical bars. The reason I used that was that I wanted to be sure that for the purposes of your for loop that enough bars were present before your code was run. Also it looked like if your code ran on every historical bar and it may take some time so using the historical check was just a quick way to get the prints going.

            You do not need to use that code.

            Paul H.NinjaTrader Customer Service

            Comment


              #21
              Hi Paul,

              I could not carry out the last test with both indicators on the chart as you have specified above. My platfom stops working since app. 1 hour. I have just sent a massage to the support center.

              I will revert to you as soon as the issue will have been resolved.

              Comment


                #22
                Hi Paul!

                I have the two indicators on the chart.
                On the output1, I have on the bottom line the following:"16.04.2021 22:01:00" Other numbers are integers starding with 200, than 300, than 400... up to 220100.
                Does this 200 represent the time of a bar? I think no, otherwise it should have six digits. Right?
                Why is the bottom line different from othe rest?

                Comment


                  #23
                  Hello Stanfillirenfro,

                  Thanks for your reply.

                  200 would likely be 2 minutes after midnight, 300 = 3 minutes, etc.

                  The indicator TestforStan will print the integer value of time from the bar, this is from your use of ToTime() which converts the datetime of the bar to an integer value representing time

                  The indicator TesforStan2 will print the date and time of the bar in a date-time format.

                  You may want to review this educational sample on working date time: https://ninjatrader.com/support/help...me_objects.htm


                  Paul H.NinjaTrader Customer Service

                  Comment


                    #24
                    Many thanks Paul for all your help.
                    I proceed with the code and will revert to you soon.

                    Tx again!

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by gbajaj, Today, 03:35 PM
                    2 responses
                    7 views
                    0 likes
                    Last Post gbajaj
                    by gbajaj
                     
                    Started by space_trader, Today, 03:19 PM
                    2 responses
                    8 views
                    0 likes
                    Last Post space_trader  
                    Started by max1ci6, Today, 02:02 AM
                    4 responses
                    27 views
                    0 likes
                    Last Post joromero  
                    Started by Johnny, Today, 02:38 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_Tyler  
                    Started by M_ichel, Today, 02:26 PM
                    1 response
                    5 views
                    0 likes
                    Last Post NinjaTrader_Tyler  
                    Working...
                    X