Announcement

Collapse
No announcement yet.

getPreviousTRadingDay returns null?!

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

  • getPreviousTRadingDay returns null?!

    I have a loop that generates a sequence of previous trading days:

    PHP Code:
    var currentTime getValue"rawtime");

    for(var 
    0nLengthi++) { 
    prevTime getPreviousTradingDay(currentTime); 
    var 
    firstPrevBar getFirstBarIndexOfDay(prevTime);
    //do some stuff here
    currentTime prevTime;

    Usually this works fine, generating a sequence of trading days. However, if I increase nLength beyond a certain point, getPreviousTradingDay returns null. For example if nLength is 13 on a 15-minute chart the function doesn't fail; increased to 14, it fails.

    Does anyone have an idea about why this is happening?

  • #2
    Hello Miami,

    The error occurs because the value of currentTime becomes null once the loop reaches the end of the data that is loaded in the chart. What you need to do is add some null checks for the currentTime and prevTime variables. Try the following.



    Make note of the else statement associated with the null check for prevTime. This isn't required, however, it will speed up the routine a bit by exiting the loop the first time a null value is encountered.
    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 should have thought of that. I was focused on ways to force all the data to load. I tried a time template set to the nLength period (which represents a moving average length) but that did not work. So far the only thing that guarantees loading all the data is to manually scroll over and reloading the efs.

      Is there anyway to force enough data to load before running the efs?

      Comment


      • #4
        Hello Miami,

        EFS does not have control over the data that is loaded by the Advanced Chart. This is strictly determined by the time template settings.
        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