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

Bars.GetDayBar Question

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

    Bars.GetDayBar Question

    Hi
    I wrote this code - expecting to see the Bars.GeDayBar(1) return data from the prior day.

    if (Bars.GetDayBar(1) != null)
    {
    writeit1 =
    "Today : "+Time[0].DayOfWeek+" "+Time[0].Date.ToShortDateString()+" "+Time[0].TimeOfDay.ToString()
    +
    ";" +Bars.GetDayBar(1).Time.ToLongDateString()
    +
    ";" +Bars.GetDayBar(1).Open.ToString()
    +
    ";" +Bars.GetDayBar(1).High.ToString()
    +
    ";" +Bars.GetDayBar(1).Low.ToString()
    +
    ";" +Bars.GetDayBar(1).Close.ToString()
    +
    ";" +Bars.GetDayBar(1).Volume.ToString()
    +
    ";" +Bars.GetDayBar(1).FirstBarOfSession.ToString()
    +Environment.NewLine;

    Print (writeit1);



    Instead - it appears that Bars.GetDayBar(1) is returning data from 3 days prior. Here is the output to the output window:

    Today : Tuesday 3/5/2013 00:00:00;Friday, March 01, 2013;1500.75;1513;1494;1510.75;8886;False
    Today : Wednesday 3/6/2013 00:00:00;Friday, March 01, 2013;1500.75;1513;1494;1510.75;8886;False
    Today : Thursday 3/7/2013 00:00:00;Monday, March 04, 2013;1507.25;1520.5;1505.25;1520.5;12829;False
    Today : Friday 3/8/2013 00:00:00;Tuesday, March 05, 2013;1526.75;1537.25;1526.5;1532;36076;False




    #2
    The code you have here appears to be working correctly on my end.

    Have you ensured the data is available on the chart being used? When you right click the chart -> reload historical data does this resolve the issue?

    Who is your data provider?

    What instrument are you testing?

    What session template are you using?
    LanceNinjaTrader Customer Service

    Comment


      #3
      Lance - I have attached a .JPG of the chart and the data series settings
      Instrument ES0613
      Provider Zenfire
      Session Template Default 24*7

      There should be plenty of data in the chart (see .jpg) -- I tried reloading historical data and got the same result
      Thanks
      Attached Files

      Comment


        #4
        I'm loaded up Zen-Fire with the same chart as you and receive the following when running the following script


        Code:
        if (Bars.GetDayBar(1) != null) 
        			{
        				writeit1 =
        				"Today : "+Time[0].DayOfWeek+" "+Time[0].Date.ToShortDateString()+" "+Time[0].TimeOfDay.ToString()
        				+"; Yesterday:  " +Bars.GetDayBar(1).Time.ToLongDateString()
        				+";" +Bars.GetDayBar(1).FirstBarOfSession.ToString();
        
        				Print (writeit1);
        			}
        Output:
        Today : Thursday 3/21/2013 22:00:00; Yesterday: Wednesday, March 20, 2013;False
        Today : Friday 3/22/2013 22:00:00; Yesterday: Thursday, March 21, 2013;False
        Today : Monday 3/25/2013 22:00:00; Yesterday: Friday, March 22, 2013;False
        Today : Tuesday 3/26/2013 22:00:00; Yesterday: Monday, March 25, 2013;False
        Today : Wednesday 3/27/2013 22:00:00; Yesterday: Tuesday, March 26, 2013;False
        Today : Thursday 3/28/2013 22:00:00; Yesterday: Wednesday, March 27, 2013;False
        If you're not getting this please try posting the exact script you're using or see how my script differs from yours.
        Located in (MY)Documents\NinjaTrader 7\bin\Custom\ indicator/strategy
        LanceNinjaTrader Customer Service

        Comment


          #5
          Lance
          I repaired the DB, reset the DB and reset the instrument list
          The problem has gone away!
          Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          31 responses
          817 views
          1 like
          Last Post NinjaTrader_Adrian  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          5 responses
          14 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by swestendorf, Today, 11:14 AM
          2 responses
          6 views
          0 likes
          Last Post NinjaTrader_Kimberly  
          Started by Mupulen, Today, 11:26 AM
          0 responses
          7 views
          0 likes
          Last Post Mupulen
          by Mupulen
           
          Started by Sparkyboy, Today, 10:57 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X