Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsAgo showing Yesterday's Data

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

    BarsAgo showing Yesterday's Data

    Hello NinjaTrader Friends,

    I've been noticing a very weird behavior in my NinjaScript strategy, when access values of Bars Ago like Time[1], Time [2], High[1], High[2], High[3], it is showing me values from yesterday's last bars.

    For example, the code below, it doesn't matter at what time or OnBarUpdate of the day it executes, it shows always the same values below:

    ToTime(Time[1]).ToString() is showing: 181500
    ToTime(Time[2]).ToString() is showing: 180000
    ToTime(Time[3]).ToString() is showing: 174500

    If look at High[1], High[2], High[3]... they are also showing values from yesterday's bars , the same bars of times above.

    My strategy is running on each inconming tick (CalculateOnBarClose = false) bars period of every 15 minutes.

    I'm connected to Clear Broker order and price servers.

    I've already synchronized Timezone, that does not appear to be the problem.

    Please your assistance.

    Thanks in Advance,

    Rodrigo

    #2
    Hello,

    Thank you for the question.

    Would you be able to provide a full sample of the script you are using for better clarity on what is happening?

    Regarding your prints, I would expect this to print the last 3 bars of data, on a 15 minute chart that would be the last three 15 minute bars depending on how the strategy is programmed.

    Are you able to see the data correctly on the chart and only the Print is not working?

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Sorry, this should be in the NT8 beta section



      Probably I do have a similar observation.

      Take this


      Bars is 1 minute series.


      int n =Bars.GetBar(YesterdayHalfHourBeforeClose);


      but n is then a Bar which is the day before Yesterday!

      So there seems to be a one day too much ..

      regards
      Andreas

      Comment


        #4
        Hello,

        Thank you for the question. Because this is not the beta forum, I would ask that you re ask your question in the relevant forum as a new thread.

        rgaleote has a separate question in the process right now and this would likely confuse this thread, Our support is happy to answer your questions we just ask that you start new threads in the relevant forums when you can as to not mix NT7 and NT8 questions up.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          Thanks for you comments, regarding you questions:


          Would you be able to provide a full sample of the script you are using for better clarity on what is happening?
          Script is full trash, comments in portuguese, imagine a simple and empty OnBarUpdate with only those prints, that's exactly the same thing.

          Regarding your prints, I would expect this to print the last 3 bars of data, on a 15 minute chart that would be the last three 15 minute bars depending on how the strategy is programmed.
          Exactly , this is what I expected too, but it is showing me always the day before's last 3 bars instead.

          Are you able to see the data correctly on the chart and only the Print is not working?
          Yes, chart looks perfect, I actually found this problem because an indicator wasn't working, which led me to try to calculate the indicator in the OnBarUpdate and then I found out the problem. But when I got the chart, indicartor looks perfectly fine, prices and everything else are fine, and it is actually looking at the chart that I can match those values above with yesterday's last bars.

          Thank you,

          Rodrigo

          Comment


            #6
            Hello Guys,

            Would you have any other suggestions/ input on this one here?

            Thanks,

            Rodrigo

            Comment


              #7
              Hi Rodrigo,

              Just to double check, if you look at the time and price of the bars on the chart, these are correct?

              Start with a very simple script.

              In this script print the time and the high price.
              Print(Time[0]+" | "+High[0]);

              Do not add any conditions to this script.

              When you run this script are the prints correct?
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Hi Chelsea,

                Market has just closed around here, I'm changing my script and I'll send you tomorrow's results.

                Regards,

                Rodrigo

                Comment


                  #9
                  Hi Chelsea,

                  Please find attached two screenshots, one with the Prints Output and the other with the code you gave me plus a code that I put there where it should show one bar ago data.

                  The screenshots were taken at 12:10pm today.

                  You will notice that your code shows wrongly 08:15 for Time[0], and it shows wrongly 48180 for High[0], 48180 was the High for the 11:15 bar which was like 4 or 5 bars ago.

                  You will also notice that my code shows wrongly 18:15 for Time[1] and also wrong values for High[1] and Low[1], showing everything for yesterday's 18:15 bar.

                  One thing weird that I notice was that my chart already open from yesterday was showing all today's bars consolidated into 1 bar, even though my chart is selected to show 15 minutes bars. It was like showing just one bar for today, with min and high from all ticks since from the market opening up to now 12:10pm.

                  This thing mentions above weirdly explains the Time[0], Time[1], Time[2), looks like the system understands that Time[0] 8:15 is the first time and only bar of today, and Time[1] is the previous bar which would be yesterday's last bar.

                  After I reloaded historical data on the chart, the chart started showing ok, but the prints would still show wrong data.

                  Then I disabled and re-enable my strategy then everything started showing OK, your code and my code.

                  Looks like since the strategy code is all related to the chart, and the chart was being shown wrongly , the strategy data was also shown wrongly.

                  The question goes: why was the chart showing today's data all consolidated into one bar even though chart and strategy are configured on a 15 mins bar type? If it only shows one bar for all todays data, then the system is right to understand this single bar as Time[0] and yesterday's stuff as [1]... [2]... etc

                  Thanks in advance.

                  Rodrigo
                  Attached Files

                  Comment


                    #10
                    Hello rgaleote,

                    I cannot verify if the prints are correct or not as there is nothing to compare the print to. I do not your time zone or where you are getting this data and there is no screenshot of the chart with the databox open showing the high and time of a particular bar that we can compare with in the prints.

                    However, it sounds as if there is an issue with your chart.

                    May I have a screenshot of the chart and the Data Series window?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chelsea,

                      Please take a look at these screenshots now. They are from today around 03:40pm local time. Another very relevant data is that I opened the chart and reloaded historical data at around 11:15am local time. But did not disable/re-enabled the strategy.

                      Screenshots:

                      1- "Code Used to print output.png" - please look at the code I used to generate the ouput window data. I've added "Print (DateTime.Now)" so you can see when exactly that information was printed on output window.

                      2- "Output window.png" - take a look the prints output at exactly 3:38pm, tick by tick. Please notice how your code "Print(Time[0])" returns aways 8:15 am. And see how the High[0] always shows 49375 which is the High from the first bar of the day, not the high of current 3:38pm bar. Also notice how Time[1] and High[1] shows previous day's last bar data.

                      3- "data series.png" - this is the data series settings window you've requested.

                      4- "Chart Before Reload Historical Data at 3-43pm.png" - please see the chart screenshot at 3:43pm (windows time), the last Reload Historical Data was at around 11:15am, see how the last bar behaves, it seems to consolidate all data from 11:15am up to now 3:43pm (when the screenshot was taken) into one single bar.

                      5- "Chart After Reload Historical Data at 3-45pm.png" - at 3:45, I clicked on Reload Historical Data, then the chart was magically fixed and now it shows all the properly since from last reload (11:15am) up to now.

                      One thing that I ended missing was to disable and renable de strategy, because when I do that, it seems to get the data from the new reloaded chart and then everything gets normal.

                      Please let me know if this helps you or what else need.

                      Thanks,

                      Rodrigo
                      Attached Files

                      Comment


                        #12
                        Same thing today, please see 2 screenshot attached to this thread, one before and the other after reload historical data. Both taken right now (10:25am local time)

                        Please your assistance.
                        Attached Files

                        Comment


                          #13
                          Hi rgaleote,

                          It does appear that scripts are not updating correctly on your system.

                          Please send an email to platformsupport [at] ninjatrader [dot] com so that we may further assist.
                          Chelsea B.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Peppo, 04-13-2025, 12:59 PM
                          11 responses
                          88 views
                          0 likes
                          Last Post Peppo
                          by Peppo
                           
                          Started by michelz, 02-18-2025, 08:30 AM
                          31 responses
                          1,018 views
                          0 likes
                          Last Post rockmanx00  
                          Started by TraderYoda, 05-24-2019, 03:33 AM
                          43 responses
                          2,119 views
                          1 like
                          Last Post pwmmmm
                          by pwmmmm
                           
                          Started by jb805, 02-04-2025, 12:34 PM
                          5 responses
                          168 views
                          0 likes
                          Last Post Swagpapifrio  
                          Started by Newtrader101, Today, 11:27 AM
                          1 response
                          6 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Working...
                          X