Announcement

Collapse
No announcement yet.

How to indicate EFS start bar

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

  • How to indicate EFS start bar

    I've got a script where I'm retrieving prior bars like this:

    f = studyMA.GetValue(MAStudy.MA,-x);

    But on my chart when I use this value for large "x" I am getting 0 when I look at the plots by scrolling back on the screen.

    So I need to indicate somehow that my script requires X number of bars before it outputs useful info.

    Now if I use a scheme like this...

    var iNewBars = 0
    .....
    If (getBarState() == BARSTATE_NEWBAR)
    iNewBars++;

    if (iNewBars < x)
    return null;
    ...

    then I have the case where 90% of my chart does not compute the indicator. However if I scroll back the chart by hand I see that eSignal has the data in that I call getOldestBarIndex() and the value keeps getting more negative as I scroll back, it is just not starting far enough back for me initially.

    Is there a way to handl this?

  • #2
    Hi crokusek,

    There are several more methods that you may find useful as follows:

    getCurrentBarCount() - the barcount of the chart, which is consistent with the cursor window barcount and is valid as the history bars are loaded
    getCurrentBarIndex() - this value starts the offset from the current bar.

    These will only provide more information to you however. Perhaps the answer for you is to load more data in your charts by modifying the time template you are using for your chart.

    Regarding your method you currently use, I would suggest the following tweak. Yours is an acceptable method, this is my preference

    PHP Code:
    // this is a global value declared outside the main and preMain functions
    var barcount 0;

      
    // these are within main
      
    if (getBarState() == BARSTATE_NEWBAR)
        
    barcount getCurrentBarCount();

      if (
    barcount x)
        return; 
    Another alternate method to check for valid values is to check the indicator for null, e.g.
    PHP Code:

      f 
    studyMA.GetValue(MAStudy.MA,-x);

    // then you check f for null
      
    if (f==null)return; 

    Comment


    • #3
      Hello crokusek,

      As Steve mentioned, the answer to your problem is to force your chart to start with a larger amount of data through the use of a custom time template. To learn more about setting this up, please review the following article from our KnowledgeBase.

      Advanced Charting - General Instructions
      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