Announcement

Collapse
No announcement yet.

BARSTATE_NEWBAR vs bar index

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • BARSTATE_NEWBAR vs bar index

    Right now, I have EOD but am moving to real-time later. I have setPriceStudy(true) and setComputeOnClose(), and realized that for studies using an interval of less than daily, getCurrentBarIndex() never gets to zero. It stops at -1. It does result in zero for daily, weekly and monthly charts. The popup on the price chart, however, does show the first bar to have an index of zero regardless of interval, and high(...) does return a value for the "zero" bar.

    With BARSTATE_NEWBAR, I have to check for interval first and then the bar index equal 0 or -1 before executing some code after the chart is initially loaded and after subsequent new bars. Is this correct? Something doesn't seem right.

    Thanks.

  • #2
    Hello AssetHound,

    The setComputeOnClose() function does not take affect on daily, weekly or monthly intervals. If you are using a formula on both daily and intraday intervals you can check for the daily and higher intervals with isDWM().

    You should be able to look at bar index of 0, for example close(0), regardless of the use of setComputeOnClose(). close(0) etc will refer to the current bar that is being processed. When setComputeOnClose() is used the formula does not process bar 0 because bar 0 is not a completed bar until it becomes the new bar -1. 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


    • #3
      That explains it and matches what I found out. Thanks for letting me know about isDWM(). That's helpful and I missed it.
      -----------

      Originally posted by JasonK
      Hello AssetHound,

      The setComputeOnClose() function does not take affect on daily, weekly or monthly intervals. If you are using a formula on both daily and intraday intervals you can check for the daily and higher intervals with isDWM().

      You should be able to look at bar index of 0, for example close(0), regardless of the use of setComputeOnClose(). close(0) etc will refer to the current bar that is being processed. When setComputeOnClose() is used the formula does not process bar 0 because bar 0 is not a completed bar until it becomes the new bar -1. Hope this helps.

      Comment


      • #4
        You're most welcome.
        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

        Working...
        X