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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            574 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            332 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