Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetBar

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

    GetBar

    Hi I want the opening price at 9:30 for ES

    will this do:

    Bars.GetBar(ToTime(Time[0] == ToTime(9, 30, 00))

    #2
    Hello calhawk01,

    Thank you for your post.

    If you wanted the bars ago index of the 9:30 AM bar you would use the following:
    Code:
    int barsAgo = CurrentBar - Bars.GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 30, 0));
    And then use Open[barsAgo] to pull the Open price of the 9:30 AM bar.

    For information on GetBar() please visit the following link: http://www.ninjatrader.com/support/h...nt7/getbar.htm

    Please let me know if I may be of further assistance.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello calhawk01,

      Thank you for your post.

      If you wanted the bars ago index of the 9:30 AM bar you would use the following:
      Code:
      int barsAgo = CurrentBar - Bars.GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 9, 30, 0));
      And then use Open[barsAgo] to pull the Open price of the 9:30 AM bar.

      For information on GetBar() please visit the following link: http://www.ninjatrader.com/support/h...nt7/getbar.htm

      Please let me know if I may be of further assistance.
      Thank you for the reply.

      would I be adding that code in the ''protected override void Initialize()'' or is that a private int?

      Comment


        #4
        Hello calhawk01,

        Thank you for your response.

        That would actually be added to the OnBarUpdate() method.

        My full OnBarUpdate() method to check this is the following:
        Code:
                protected override void OnBarUpdate()
                {			
        			int barsAgo = CurrentBar - Bars.GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 6, 30, 0));
        			
        			Print(Time[barsAgo] + " " + Open[barsAgo]);
        		}
        Please let me know if I may be of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello calhawk01,

          Thank you for your response.

          That would actually be added to the OnBarUpdate() method.

          My full OnBarUpdate() method to check this is the following:
          Code:
                  protected override void OnBarUpdate()
                  {            
                      int barsAgo = CurrentBar - Bars.GetBar(new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 6, 30, 0));
                      
                      Print(Time[barsAgo] + " " + Open[barsAgo]);
                  }
          Please let me know if I may be of further assistance.
          perfect, thank you

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          672 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          379 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          111 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          577 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          582 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X