Announcement

Collapse
No announcement yet.

multiple symbols and reloading

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

  • multiple symbols and reloading

    I find that one of my EFS scripts works fine for a while and then it suddenly shows what appears to be a dubious reading. On clicking reload the script then shows the correct readings and everything is okay until this happens again.

    The script references external symbols and I've heard it said that this happens when the server is switched on you.

    One of the ways I was thinking of resolving this problem is to have the script reload every minute. (I believe that there is a reload() function - although I haven't looked for it yet.) Problem with this is that the reload is fairly processor intensive and I think this will become a problem reloading the script that frequently.

    Any ideas or suggestions?
    Standing on the shoulders of giants.

  • #2
    Hello Wildfiction,

    Using reloadEFS() is not the best solution in my opinion. The type of problem you're describing is usually code related. Please create an example formula that recreates the problem you are describing and post that code here. Let's try to find the source of the issue and see if there is a coding solution for you other than reloadEFS().
    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
      Before I try and create a script that will replicate this (which I believe will be almost impossible) I will tell you what is unique to this EFS that is not in any other EFS that I use and I haven't experienced this problem elsewhere.

      This EFS calls the high() low() close() functions on each tick for the main symbol and also for some external symbols. Some of those external symbols are things such as $TICK $TRIN etc. that are only available from 09:30 to 16:00 EST

      Those are the unique aspects of this script that may be causing problems. Are there any known or typical gotchas that can happen when referring to those external symbols in the manner I've described above.

      What is interesting is that prior bar values that were recently giving correct readings will suddenly be changed to incorrect readings as if the EFS had been reloaded by something anyway without a user requesting the reload. That is where my "server switched on you" comment came from.

      So say the time is now 10:30am and I'm watching a 1 minute chart and the EFS has a reading of +1.5 on the 10:07am bar. Now what will happen is that suddenly, without warning, all the bars going back to the beginning of the day will have their values changed so that the 10:07am bar for example will read something completely unrelated like -0.2 and the same will happen with all the other bars. It's as if a reloadEFS() has been called but the external symbols did not line up during that reloadEFS().
      Standing on the shoulders of giants.

      Comment


      • #4
        Hello wildfiction,

        It sounds like you may be using EFS1 logic for accessing the external symbol price data. Are you using the sym() function in the source for the calls? You need to be using the sym() function in order for the series to be properly synched.

        var myDataSeries = close(sym("INTC"));

        There has been a great deal of testing in this area. If it wasn't properly synchronizing we surely would have noticed. Check that first.
        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


        • #5
          I'm using the new sym() function but not exactly how you're using it. Here is the code that I'm using:

          ...
          // global var outside functions
          var oSymbol = "INTC";
          ...

          // In main() and other functions:
          var LL = low(0,sym(oSymbol));
          var HH = high(0,sym(oSymbol));
          var CC = close(0,sym(oSymbol));


          I've been sticking 0's in a lot of my code after hitting the getDay() -> getDay(0) problem and thought that it would be safer to explicity state what I wanted.

          Can you see anything wrong with my usage up there?
          Standing on the shoulders of giants.

          Comment


          • #6
            Hello wildfiction,

            Yes, the zeros are the problem. With data series functions in EFS2, if you specify a bar index, its going to return to you a single value. The proper way to work with data series objects when you need to access external time frames or symbols is to create the series without any specified bar index. Remove the zeros for LL, HH and CC. Then, when you need to reference the synched value from those series, use the getValue() method. For EFS2, think of the open(), high(), low() and close() functions as studies and treat them the same way you would a builtin study such as sma() or ema() etc.

            // global var outside functions
            var oSymbol = "INTC";
            ...

            // In main() and other functions:
            var LL = low(sym(oSymbol));
            var HH = high(sym(oSymbol));
            var CC = close(sym(oSymbol));

            var currentL = LL.getValue(0);
            var currentH = HH.getValue(0);
            var currentC = CC.getValue(0);
            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


            • #7
              Thanks Jason,

              Is it possible to put

              // global var outside functions
              var oSymbol = "INTC";
              var LL = low(sym(oSymbol));
              ...

              // In main() and other functions:
              var currentL = LL.getValue(0);

              so that LL is asigned once during initialization and then you are always referencing LL by using getValue(0) ?

              Or do you need to use this syntax on each tick:
              // In main() and other functions:
              var LL = low(sym(oSymbol));
              var currentL = LL.getValue(0);
              Standing on the shoulders of giants.

              Comment


              • #8
                Hello wildfiction,

                Not exactly. The open, high, low, close functions can only be called in main. The built-in study functions can be declared globally however. What you can do for the low study is declare LL as null globally and then check inside main to see if LL is null and then initialize LL.

                PHP Code:
                var oSymbol "INTC";
                var 
                LL null;

                function 
                main() {
                    if (
                LL == nullLL low(sym(oSymbol));
                    var 
                currentL =  LL.getValue(0);
                    ....

                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


                • #9
                  Okay - makes sense. Thanks for the help on this one Jason.
                  Standing on the shoulders of giants.

                  Comment

                  Working...
                  X