Announcement

Collapse
No announcement yet.

inv() triggers multiple executions of main()?

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

  • inv() triggers multiple executions of main()?

    I just found out that if an efs uses inv() to access data in another time frame, main() is called twice on each new tick. For example, in the attached efs, inv("D") is called. If it is applied to $VIX,5 chart, in the output window, on each new $VIX tick, main() is called twice in very short period (less than 1 millisecond. Moreover the first tick is old data ($VIX is sent out every 15 seconds). I think in older esignal version, it did not behave in this way. If an efs access data in multiple time frame but of the same symbol, main() is called only once for each tick because $VIX,5 and $VIX,D are the same in realtime streaming. Now the problem is not only main() is called multiple times for each new tick, some calls are based on delayed data (in $VIX example, it is delayed 15 seconds). Did esignal change anything recently causing this issue?
    Attached Files

  • #2
    the rows with k=27 and 28 are printed out almost at the same time but the vix value printed out in row k = 28 is 15 seconds old.
    Attached Files

    Comment


    • #3
      replacing inv() with getValueAbsolute("Close", 0, -1, getSymbol()+",D") results in the same result.

      I think such design is problematic because it unnecessarily increased the number of calling of main().



      var k;

      function preMain()
      {
      setPriceStudy(true);
      }

      function main()
      {
      if ( getBarState() == BARSTATE_ALLBARS ) {
      k = 0;
      }
      if ( getCurrentBarIndex() == 0 ) {
      //var dBBUp = upperBB(20, 2, inv("D"), -1);
      //var dBBDn = lowerBB(20, 2, inv("D"), -1);
      var dailyClose = getValueAbsolute("Close", 0, -1, getSymbol() + ",D");
      dailyClose = dailyClose[0];

      k = k + 1;
      var T = new Date();
      debugPrintln(getSymbol() + " T = " + T.getSeconds() +"." + T.getMilliseconds() + " k = " + k + " c = " + close(0) + " daily C = " + dailyClose);
      }

      }

      Comment


      • #4
        Hello Clearpicks,

        Thank you for reporting your findings and code examples. You are correct. There is an extra execution of main() being triggered. We'll get this fixed as soon as possible.

        The problem is specifically related to multiple interval studies where the same symbol is being referenced. Studies that are only referencing external symbols (regardless of interval) are not affected.
        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