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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        52 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        38 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        99 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        60 views
        0 likes
        Last Post PaulMohn  
        Working...
        X