Announcement

Collapse
No announcement yet.

EFS invoked on each close?

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

  • EFS invoked on each close?

    Has anyone else had problems with an EFS NOT being invoked on each close?

    I've wrote a small EFS to maintain a tic for the forex markets. I get some of the calls for each close over the course of the time frame for the bar, but the formula does not get called for every close. now I'm interpreting the doc, that the formula will be invoked each time that a lot has been bought/sold, not on a bid/ask changing. It seems very close to doing this, but there are calls to the formula not made. It's a small number of calls that are not made, lets say over the course of a minute, the volume (as shown by the volume study of the advanced chart) there are 80 lots that are sold, the formula may only be called say, 73 times.

    Both an internal counter that I inserted into the formula, and the performance monitor support the fact that the formula is not being invoked every time there is a close. This ocurrs no matter which currency is being watched. One other thing that was interesting about this bug, is that, there were never any tics that were unchanged. I.E. last price = current price. That counter never changed, the up tick, down tick counters were being updated, but there were never any unchanged tics. Which is highly improbable. So i'm curious if the internal logic in e-signal doesn't invoke a formula if the current close = last close. This may have been done in order to save processing time, but it sure would mess up any form of average that was attemtped to be computed.

    Thank anyone for their thoughts and help, as technical support, kept saying it was the script itself that I wrote which had the error, such is not the case.

    I really like e-signal, and want to write more scripts, but want to be able to believe the data that is produced.

    Jay Ice

  • #2
    Hello Jay,

    I'd be happy to look into this further. Please post your formula and let me know what specific symbols, intervals and time templates you are using.
    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
      Hello Jason,

      thank you for your time to look into this matter. I constructed a little piece of code to demonstrate the error. This is not the script I wrote, I just pulled out all the unnescary code to show the problem.

      Code begins:

      /************************************************** **************************************************
      Code to demo the problem
      ************************************************** ************************************************** */


      var numCalls = 0;
      var crMin = 0;
      var svMin = 0;

      function preMain() {
      setStudyTitle("Bug Demo (BD)");
      setCursorLabelName("Num Calls",0);
      setShowCursorLabel(true);
      setStudyMin(0);

      /*

      */
      setDefaultBarStyle(PS_SOLID);
      setDefaultBarFgColor(Color.blue);
      setDefaultBarThickness(2);
      setPlotType(PLOTTYPE_HISTOGRAM);

      }

      /*

      */
      function main() {
      crMin = getMinute();
      if (crMin != svMin) {
      svMin = crMin;
      numCalls = 0;
      }
      numCalls ++;
      return numCalls;
      }

      end of code

      As you can see there is nothing to showing the situation, if you load this on an advanced chart, displaying a currency (eur a0-fx), with the time frame set for a minute chart, you will see the discrepency between the number of calls displayed, and the volume for the currency. I.E. open a pane using the volume from the basic studies. Another way to do it, is to open the performance monitor for scripts and look at the number of calls that it displays, it will also show the same results.

      Again thank you for your time in this matter.

      Jay

      Comment


      • #4
        Hello Jay,

        An EFS formula does execute whenever there is an update to the chart. In the case of eur a0-fx, there are some updates where the actual volume number increments by a value greater than 1. So counting executions of the EFS will not match the volume number. Try the formula below. This uses the volume() function to return a number that matches the volume study update-by-update. When the volume increments by a value greater than 1, you will see a message printed out in the Formula Output Window (Tools-->EFS). If you need further assistance with a particular routine you're trying to code that's affected by this, describe what you need and I'll try to help provide a solution.

        PHP Code:
        var numCalls 0;
        var 
        crMin 0;
        var 
        svMin 0;

        function 
        preMain() {
            
        setStudyTitle("Bug Demo (BD)");
            
        setCursorLabelName("Num Calls",0); 
            
        setShowCursorLabel(true);
            
        setStudyMin(0);

            
        setDefaultBarStyle(PS_SOLID);
            
        setDefaultBarFgColor(Color.blue);
            
        setDefaultBarThickness(2);
            
        setPlotType(PLOTTYPE_HISTOGRAM);

        }

        var 
        curVol null;
        var 
        lastVol null;

        function 
        main() {
            
            
        lastVol curVol;
            
        curVol volume();
            if (
        lastVol == null) return;
            
            if (
        getBarState() == BARSTATE_NEWBAR) {
                
        numCalls 0;
            }
            
            
        numCalls ++;

            if ((
        curVol lastVol) > 1) {
                if (
        getCurrentBarIndex() == 0) {
                    
        debugPrintln("on update " numCalls ", volume was " + (curVol lastVol));
                }
            }
            
            return 
        curVol;

        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
          Hello Jason,

          thank you for the explanation of the differential between counted calls and volume(). That makes sense, and is quite helpfull. What I am curious about at this point is, does the formula get invoked when there is no change in price, but there is a new transaction? I.E. one trade at 1.2580 (irrespective of the lot size), and then the next trade is at 1.2580. Does the formula get invoked in this instance?

          Again, thank you for your time and help.

          Jay

          Comment


          • #6
            Hello Jay,

            It most cases, yes. Your original code example demonstrates one instance where it does not. If two trades occur at virtually the same time, there may only be one update sent to the chart. One thing you can try that I discovered recently is a raw tick interval. For example, instead of using a 1-minute interval, use 60s. This interval type will receive an update for each trade. Give that a try and let me know if that gives you the solution you're looking for.
            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