Announcement

Collapse
No announcement yet.

Help, Please

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

  • Help, Please

    I need the last tick of the bar.

    These do NOT provide that.

    At the first tick of the new bar, the information I need is from bar(-1).

    Technically, the first tick of a new bar, could be seconds or minutes away from the bar start time.

    Do you see why that won't work?


    Originally posted by SteveH
    Don't you just want to use the getBarState() function then so that you can choose which pieces of code in your script get executed according to what state the bar processing is in?

    This is from the EFS docs:

    Code:
    function main() { 
    var nState; 
       ... 
       ... 
       nState = getBarState(); 
       if (nState == BARSTATE_ALLBARS) { 
          //the bars are being loaded by the script. This happens when a script is first loaded 
          debugPrint("Script is loading\n"); 
       } 
       else if (nState == BARSTATE_NEWBAR) { 
          //this flag is set when a new bar is coming in 
          debugPrint("The first tick of a new bar has arrived\n"); 
       } 
       else if (nState == BARSTATE_CURRENTBAR) { 
          //this flag is set as each new tick comes in 
          debugPrint("A new tick has arrived\n"); 
       } 
    
    }

  • #2
    Hello Avery,

    In general, you should be able to use getBarState() to control the execution once per bar. At BARSTATE_NEWBAR you would calculate the value based on data from bar -1. If you then wanted that result to be plotted on bar -1 rather than bar 0 you would pass the value to setBar(). The has to be done by looking for BARSTATE_NEWBAR because the EFS has no way to know which tick will be the last tick of an interval until the first tick of the new interval is received, which is the newbar state. If you want to post a code example that you're working with, we can get more specific.
    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
      Thanks Jason.

      I needed that info.

      Comment


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