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

Is it always CurrentBar == Count - 2 ?

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

    Is it always CurrentBar == Count - 2 ?

    When COBC = true:

    Is it safe to assume and to condition logic to if CurrentBar == Count - 2 when COBC = true? in other words, is it possible that OBU() will fire in a situation where CurrentBar is not Count - 2 ?

    Btw, I don't care about the initial iteration of the historical bars by OBU().

    #2
    Originally posted by savekad View Post
    When COBC = true:

    Is it safe to assume and to condition logic to if CurrentBar == Count - 2 when COBC = true? in other words, is it possible that OBU() will fire in a situation where CurrentBar is not Count - 2 ?

    Btw, I don't care about the initial iteration of the historical bars by OBU().
    I find it hard to see what you are getting at. CurrentBar is always the last bar on the chart after the chart loads. What does it matter about Count - 2?

    Comment


      #3
      I meant the following:

      If you set COBC to true, and you want OBU to evaluate only the last possible bar and to to skip all historical bars, you can code OBU with:

      if (CalculateOnBarClose && CurrentBar != Count - 2) { return; }

      And by that insure that OBU will evaluate the most recent closed bar and skip all others.

      I'm asking if there could be any problems with the code I suggested.

      Comment


        #4
        Hello savekad,
        In a single series indicator (i.e. the code does not contains any secondary bar series) if you scroll back the chart and press F5, then the Current bar will print the LastVisibleBar value and not the Bars.Count - 2 value.

        I would suggest using the Print function and Print out the values and see what the values are and then use an appropriate method.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Originally posted by savekad View Post
          I meant the following:

          If you set COBC to true, and you want OBU to evaluate only the last possible bar and to to skip all historical bars, you can code OBU with:

          if (CalculateOnBarClose && CurrentBar != Count - 2) { return; }

          And by that insure that OBU will evaluate the most recent closed bar and skip all others.

          I'm asking if there could be any problems with the code I suggested.
          If you want to skip historical bars, then why not just use what already is:

          Code:
          if (Historical) return;

          Comment


            #6
            the reason i want to use this test is for being able to run the indicator when COBC is true.

            so what is the best way to have an indicator logic evaluation start from the most recent bar and further in order to avoid unnecessary processing of past bars?

            * COBC = true, of course.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by bortz, 11-06-2023, 08:04 AM
            47 responses
            1,604 views
            0 likes
            Last Post aligator  
            Started by jaybedreamin, Today, 05:56 PM
            0 responses
            8 views
            0 likes
            Last Post jaybedreamin  
            Started by DJ888, 04-16-2024, 06:09 PM
            6 responses
            18 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by Jon17, Today, 04:33 PM
            0 responses
            4 views
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            13 views
            0 likes
            Last Post Javierw.ok  
            Working...
            X