Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get Open, High, Low, Close values on uncompleted bar if Calculate.OnBarClose?

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

    How to get Open, High, Low, Close values on uncompleted bar if Calculate.OnBarClose?

    Hello.

    If indicator (or strategy) work with Calculate = Calculate.OnBarClose, but need High and Low prices of very last uncompleted bar - how can it be accessed?

    In NT7 it was simple: High[-1], Low[-1].
    But, NT8 generate exception.
    So, what is correct way?

    High.GetValueAt( CurrntBar+1) ?
    Last edited by fx.practic; 08-11-2017, 11:12 AM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    Thanks for opening the thread.

    Since Calculate.OnBarClose iterates OnBarUpdate() after the bar has closed, there would not be an iteration happening while the bar is developing and you would not be able to reference the bar while it is developing.

    The advised solution would be to use Calculate.OnEachTick to get the value of the developing bar.

    You could use logic to in OnBarUpdate() to make the NinjaScript perform certain actions on each tick, and you can also restrict your logic to perform on the first tick of a bar.

    Using Calculate.OnEachTick with IsFirstTickOfBar can give you effectively the same results as Calulcate.OnBarClose if you look at the previous bar on that first tick of a new bar.

    Code:
    protected override void OnBarUpdate()
    {
        // Only process entry signals on a bar by bar basis (not tick by tick)
        // This can mimic Calculate.OnBarClose
        if (IsFirstTickOfBar)
        {
            Print(Close[1]);
        }
    
        // All other code will process witch each tick
        Print(Close[0]);
    }
    IsFirstTickOfBar - https://ninjatrader.com/support/help...ttickofbar.htm

    Please let me know if I can be of further help.

    Comment


      #3
      Thank You.
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      576 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      334 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
      553 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      551 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X