Announcement

Collapse
No announcement yet.

Need help on updating last bar.

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

  • Need help on updating last bar.

    I have a few studies which I run on different time intervals including daily as well as intraday.

    When for example, I run my studies on 5 minutes charts, I want the last bar computation be done every 1 minute. Thus, I run the study without "setComputeOnClose", and reload it, using reloadEFS, every 1 minute.

    When the studies run on a few chart windows, the resulting performance is very poor.

    I wonder if it is possible to enter the study only every 1 minute, and NOT every tick, as it is done now.

    Enclosed is an example of my code.

    Thank you

    Yaniv
    Attached Files

  • #2
    Hello Yaniv,

    The best solution I can think of would be to add a check for the new bar state of the 1-minute interval at the top of main().

    Try adding the following.

    PHP Code:
    function main() {
        if (
    getBarStateInterval("1") != BARSTATE_NEWBAR) return;
        
        return;

    This will only allow the rest of your code in main() to execute at the new bar state of the 1-minute interval, which will occur at each opening trade for the respective 1-minute bars.

    This would be much more efficient than using reloadEFS(). Give this a try and let me know if this works for you.
    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