Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JimNinjaTrader Customer Service

    Comment


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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geddyisodin, 04-25-2024, 05:20 AM
      8 responses
      61 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by jxs_xrj, 01-12-2020, 09:49 AM
      4 responses
      3,287 views
      1 like
      Last Post jgualdronc  
      Started by Option Whisperer, Today, 09:55 AM
      0 responses
      5 views
      0 likes
      Last Post Option Whisperer  
      Started by halgo_boulder, 04-20-2024, 08:44 AM
      2 responses
      22 views
      0 likes
      Last Post halgo_boulder  
      Started by mishhh, 05-25-2010, 08:54 AM
      19 responses
      6,189 views
      0 likes
      Last Post rene69851  
      Working...
      X