Announcement

Collapse
No announcement yet.

Difference between reloadEFS() and reloading EFS by menu/mouseclick

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

  • Difference between reloadEFS() and reloading EFS by menu/mouseclick

    Does anyone know the difference between reloadEFS() and reloading your EFS by using the menu or right clicking with your mouse? Or is there no difference?

    Bart

  • #2
    Bart:

    ReloadEFS() preserves the state of any external variables when it is called (and skips the preMain() function) while right-click, Reload is equivalent to loading the script fresh from disk.

    Chris

    Comment


    • #3
      Thanks Chris.

      I seem to have a problem with the outcome of my EFS code. When I scroll to the left in my chart I eventually run into a request for data. This is of course nothing special. But if I look at the indicator and the formula output window, the outcome is wrong. When I reload my EFS with the right mouse button, the outcome is exact as I programmed it. Do you have any idea how to solve this? Do I have to dump all variables in some way?

      Bart

      Comment


      • #4
        Bart:

        It really depends on how the indicator is coded. One option which will help you to avoid the problem altogether is to use your Time Template and create Template Items for the intervals that you will be loading. You can simply create a default that will always pre-load, say, 500 bars of data. Or you could create separate template items for different intervals (e.g., force it to pre-load 800 bars when you load a Daily chart and otherwise force it to load 5-days worth of data when you load an interval chart). This approach will do away with the problem of new data coming in when you scroll to the left.

        I would need to see the actual code before I could determine if a code-fix would also solve the problem.

        Chris

        Comment


        • #5
          Chris,

          I noticed that when I reload my EFS (mouseclick) the array I use for calculating certain values has to be created again. Scrolling to the left keeps all old array elements, which are not valid anymore. I solved it with the following code:
          PHP Code:
          var bIndex//global variable

          function Premain();{
          }

          function 
          main() {

          //....
           
          if (bIndex != getOldestBarIndex()) {
              
          bIndex getOldestBarIndex();
              
          //.....dump array by array.pop()
          }


          The only problem I encounter is that when there are no more bars in history at the eSignal server and I happen to scroll to the left for the last time, the condition will not be met. The result is a wrong calculation again. Is there not some kind of function or status flag which tells whether new historical data is coming in? Something simular as getBarState() == BARSTATE_NEWBAR?

          Bart

          Comment


          • #6
            Bart:

            As far as I know there is no status flag available that tracks remaining/available data.

            In looking at your code snippet, I would think that it should work as you expect it to. So, if you scroll to the left and there is no more new data..... in that scenario your arrays should not be recalculated since there is no new historical data to deal with and, therefore, the output should not change.

            Chris

            Comment


            • #7
              Hello Bart,

              Try getBarState() == BARSTATE_ALLBARS. This occurs once at the oldest bar in the chart. You could also create a custom flag. Try this,

              PHP Code:
              var bReload false;

              function 
              main() {
                 if (
              bReload == false) {
                     
              // code
                    
              bReload true;
                 }

              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


              • #8
                As usual is the case with programming, the solution is very simple. I solved it as follows:
                PHP Code:
                //globals
                var Array1   = new Array();
                var 
                Array2   = new Array();
                var 
                Array3   = new Array();
                var 
                global1global2;

                function 
                main() {
                if (
                getBarState() == BARSTATE_ALLBARS) {
                         
                Del(Array1);
                         
                Del(Array2);
                         
                Del(Array3);
                         
                debugClear();
                         
                global1 false;
                         
                global2 false;
                }
                // ....
                }

                function 
                Del(a) {
                     if (
                a.length 0) {
                         do 
                a.pop(); while (a.length 0);
                     }

                Apparently all arrays which are globally defined, need to be removed if you're scrolling to the left. I don't know if it's necessary to reset all global variables; it won't certainly harm to do so.

                Jason and Chris, thanks for your help!

                Comment

                Working...
                X