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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        70 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        152 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        100 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        288 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X