Announcement

Collapse
No announcement yet.

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 Hwop38, 05-04-2026, 07:02 PM
            0 responses
            160 views
            0 likes
            Last Post Hwop38
            by Hwop38
             
            Started by CaptainJack, 04-24-2026, 11:07 PM
            0 responses
            307 views
            0 likes
            Last Post CaptainJack  
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            244 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            348 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            178 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Working...
            X