Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to reference a bar by time?

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

    How to reference a bar by time?

    Is there a way to reference a bar by its time, not by bars ago?

    For instance, how would I reference the Open of the one minute bar that closed at 9:31 am?

    Problem:
    I wish to plot the 9:30 Open a horizontal line on a 1 minute chart on YM, but I am running a premarket session and CurrentOpen[0] plots the first opening price that appears on my chart and not the opening price of the regular session and I it is important to keep the premarket session.

    This is what I have now:

    DrawHorizontalLine("CurrentOpen", CurrentDayOHL().CurrentOpen[0], Color.White, DashStyle.Dot, 2);

    Any solutions?

    #2
    See GetBar()

    http://www.ninjatrader-support.com/H...V6/GetBar.html
    RayNinjaTrader Customer Service

    Comment


      #3
      Thanks Ray, I'm still new at this. This is what I came up with and works just the way I intended:

      if (ToTime(Time[0]) > 093000 &&
      ToTime(Time[
      0]) < 160000)
      {
      //set the time of 9:30 bar
      int barsAgo = CurrentBar - Bars.GetBar(new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 30, 0, 0));
      DrawHorizontalLine(
      "CurrentOpen", Open[barsAgo], Color.Magenta, DashStyle.Dot, 2);DrawText("TodaysOpen", "Today's Open", 2, Open[barsAgo]+1, Color.Magenta);}

      Comment


        #4
        Great. Glad you got it working Billy. If you have further questions feel free to ask them.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by einstein, Today, 06:20 PM
        0 responses
        1 view
        0 likes
        Last Post einstein  
        Started by op1031, Today, 05:51 PM
        0 responses
        3 views
        0 likes
        Last Post op1031
        by op1031
         
        Started by nighttrader99, Today, 04:34 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ShawnB  
        Started by Simon Investimens, Today, 02:51 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by Unsuitable, Today, 02:49 PM
        0 responses
        14 views
        0 likes
        Last Post Unsuitable  
        Working...
        X