Announcement

Collapse
No announcement yet.

getCurrentBarIndex() Question

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

  • getCurrentBarIndex() Question

    It appears this function returns different values for the current bar depending on the interval. Is this true? I am getting a value of 0 for daily bars and -1 for intraday bars.
    pa-kay

  • #2
    It shouldn't be. I have many EFS scripts that depend on 0 being returned for current bar, no matter what the interval. And they all work.

    Garth
    Garth

    Comment


    • #3
      gspiker,
      Do your scripts use the setComputeOnClose(true) commmand?
      pa-kay

      Comment


      • #4
        No they don't...but now that you bring it up, I do think I remember reading something about this issue with regards to setComputeOnClose().

        You might try a search and see if you can find it...

        Garth
        Garth

        Comment


        • #5
          Hello pa-kay,

          If you use setComputeOnClose(true) in your formula, it won't execute on bar 0. That's why you are seeing -1 returned by the getCurrentBarIndex() function. Your formula is being told to wait until the bar closes, before executing your formula. At that time it's bar index becomes -1. Bar 0 is present and updating at that same instance but the setComputeOnClose(true) setting prevents your formula from executing on bar 0. Hope this helps.
          Jason K.
          Project Manager
          eSignal - an Interactive Data company

          EFS KnowledgeBase
          JavaScript for EFS Video Series
          EFS Beginner Tutorial Series
          EFS Glossary
          Custom EFS Development Policy

          New User Orientation

          Comment


          • #6
            Actually, what I am seeing is a different execution (or calculation) if the script is run using intraday bars or not. Intraday charts behave as you describe, but daily charts will recognize and calculate on bar 0. At least, the getCurrentBarIndex() command will return a 0 when using daily bars and setComputeOnClose(true). This isn't such a big deal for running my script, except that I wasn't aware of it before now.
            pa-kay

            Comment

            Working...
            X