Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get a specific bar and lock it.

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

    Get a specific bar and lock it.

    Hello,

    Is it possible to get a specific bar and lock it. Is there a method that allow me to choose for example bar 500 Bars.GetLow(barIndex); and lock it.
    Because if i input a specific bar in my for loop, as the bars add up in the chart, bar 500 will become bar 501 or 499 bars ago. If 500 is at 9 am i want the 9 am bar whatever it becomes bar 501 or 502 ...

    TY

    #2
    Hello frankduc,

    Thanks for your post.

    There is no way to "lock" a bar.

    Bar indexes start at 0 and increase as new bars are processed. BarsAgo indexes are the opposite. If you keep track of the bar index that you want with a variable "MyIndex," it will not matter what bar you call Bars.GetLow(MyIndex) because you are referencing the same bar index, and thus the same bar.

    We look forward to assisting.

    Comment


      #3
      Jim,

      Ok than i could use
      Code:
      MyDateTime = new DateTime(2020, 2, 10, 16, 00, 0);
      to pin point a specific bar.

      There is just one thing i dont get in proprieties parameters i only get the date to choose but i cant change the hour. What did i do wrong?

      Code:
      [NinjaScriptProperty]
      [PropertyEditor("NinjaTrader.Gui.Tools.ChartAnchorT imeEditor")]
      [Display(Name="MyDateTime")]
      public DateTime MyDateTime { get; set; }
      TY

      Comment


        #4
        Hello frankduc,

        Bars.GetBar can be used to get a bar from a specified timestamp.

        Bars.GetBar - https://ninjatrader.com/support/help...t8/?getbar.htm

        You can add a string as your User Defined Input and parse it as a DateTime object. You can look into using DateTime.ParseExact which is standard C# to convert a string to a DateTime object.

        Publicly available information on DateTime.ParseExact can be found below.

        https://docs.microsoft.com/en-us/dot...ormatProvider_

        We look forward to assisting.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        566 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        330 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        547 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        548 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X