Announcement

Collapse
No announcement yet.

Help with setComputeOnClose()

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

  • Help with setComputeOnClose()

    Due to the complicated calculation the EFS file is taking all of my CPU and there is no need to calculate on every tick only on new candle, therefore I’m using setComputeOnClose() in preMain() but of course this way I have to wait for the first candle to close on market open to get the correct trendlines of my study. I’m using 60,30,13,8,5,3,1 Min Charts which means I would have to wait 60,30,13,8,5,3,1 minutes until I get the correct lines.

    Is there a way to get the EFS study to update once upon market open and then on every new Candle not tick by using setComputeOnClose() or something else?

    Thank you

    Keto

  • #2
    Hello Keto,

    You could check for the bar state of BARSTATE_NEWBAR instead.
    For example,

    PHP Code:
    var vData null;

    function 
    main() {
        var 
    nState getBarState();
        
        if (
    nState == BARSTATE_NEWBAR) {
            
    // execute this code
            // vData = your data
            
    return vData;
        } else {
            return 
    vData;
        }

    If you make your return variable a global variable, this example will only update the value for vData at the beginning of each new bar. For every trade after that during the interval, just return the last valid calculation for vData. Let me know if 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
      Hello Jason

      Thank you very much works great

      Comment

      Working...
      X