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

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 arvidvanstaey, Today, 02:19 PM
                    4 responses
                    11 views
                    0 likes
                    Last Post arvidvanstaey  
                    Started by samish18, 04-17-2024, 08:57 AM
                    16 responses
                    60 views
                    0 likes
                    Last Post samish18  
                    Started by jordanq2, Today, 03:10 PM
                    2 responses
                    9 views
                    0 likes
                    Last Post jordanq2  
                    Started by traderqz, Today, 12:06 AM
                    10 responses
                    18 views
                    0 likes
                    Last Post traderqz  
                    Started by algospoke, 04-17-2024, 06:40 PM
                    5 responses
                    47 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X