Announcement

Collapse
No announcement yet.

on script load

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

  • on script load

    Hi,
    Is there a call to tell the script that it is just being loaded and then perform a task (based on the fact that it's just this moment been loaded)...?
    I was sure i'd read something in one of the postings in the past but can't find it now.

    Thanks,

  • #2
    Chris747
    You can use BARSTATE_ALLBARS. For the complete syntax see this article in the eSignal KnowledgeBase
    Alex

    Comment


    • #3
      Hi Alex and thanks,
      It seems to me that that should in fact work but it does not, what I'm trying to do is fairly straight forward.... at midnight and/or on a reload of the script i wish to erase a bunch of text generated from the previous days trading. If vBarMinutes and vBarHours arn't being set on re-load, they are coming from a global which is working fine.

      if ( getBarState( ) == BARSTATE_ALLBARS )
      {
      vBarMinutes = 0
      vBarHour = 0;
      gCleaned = 0;
      }

      if (vBarMinutes == 0){
      var gCleaned=0;
      }

      if (vBarHour==0 && vBarMinutes==0 && gCleaned==0)
      {
      var nit = 1500;
      while( nit < 25500 )
      {
      removeText(nit);
      nit = nit + 1500;
      }
      gCleaned=1;
      }


      the gCleaned variable is just to make sure it only runs once. If i replace the first loop (ALLBARS) with hardcoding vBarMinutes = 0 , then it runs fine on script load (obviously not after though).
      Any ideas where i might be missing something here ?

      Thanks,
      Chris

      Comment


      • #4
        Hello Chris,

        A simpler alternative would be to look for the first bar of each day using the following routine, which will only execute once for each new day found. See if this does the trick.

        PHP Code:
        if (getDay(0) != getDay(-1) && getBarState() == BARSTATE_NEWBAR) {
          ...
        your formula code

        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