Announcement

Collapse
No announcement yet.

how to tell when efs has loaded (generating too many signals on startup)

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

  • how to tell when efs has loaded (generating too many signals on startup)

    I have an efs which outputs to a file when a signal is reached. The catch is that it gives nearly all possible signals when it first loads. Is there any way to know when an efs has fully loaded and then start procesing the signals ?.

  • #2
    Hello Mike2,

    Add the following line of code to the top of main.

    if (getCurrentBarIndex() != 0) return;

    If you are using setComputeOnClose() then change the 0 to -1.
    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 for your reply, I think it has pointed me in the right direction, however I am still having difficulties.

      I tried using 'if(getCurrentBarIndex() != 0) return;' at the start of 'main()', and it worked, however it didn't provide historic signals on load, so I tried testing for 'if(getCurrentBarIndex() != 0) {' in the code, but it still produced a file for all of the previous (not current) results.

      This is the code that I'm using;

      if(a > b) {
      Strategy.doLong("Going Up", Strategy.LIMIT, Strategy.THISBAR, null, a);
      if(getCurrentBarIndex() != 0){
      var f = new File("TradeLong");
      f.open("wt");
      f.close();
      };
      };

      The goal is for it not to produce a file when first loaded, and only to show results that are current.

      The main challenge is that the external program I wrote reads the file and places an order with the broker every time I start eSignal. I use this code when I'm away from my desk and I've set my computer to restart once a day, autoloading all my programs. In other words, this is a "live" problem which can (and most likely will) cost me lots of money some time in the future.

      Comment


      • #4
        Mike2
        Try writing it as follows
        if(a > b) {
        Strategy.doLong("Going Up", Strategy.LIMIT, Strategy.THISBAR, null, a);
        if(getCurrentBarIndex() == 0){
        var f = new File("TradeLong");
        f.open("wt");
        f.close();
        }
        }

        This should execute that part of the code only on the current bar
        Alex

        Comment


        • #5
          Thanks Alexis, I haven't tried your code yet, because I got a fix, what I did is as follows;

          main(){
          noPrint = false;
          if(getCurrentBarIndex() != 0) noPrint = true;
          ...
          if(!noPrint){
          var f = new File("TradeLong");
          f.open("wt");
          //f.open("wt+");
          f.close();
          };
          }

          N.B. Thanks Alexis for pointing me toward a solution.

          Comment

          Working...
          X