Announcement

Collapse
No announcement yet.

efsInternal causing multiple main (ALLBARS)

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

  • efsInternal causing multiple main (ALLBARS)

    Anyone know what causes this...

    I'm writing an efsInternal function (as an addition to an otherwise working script) , but finding it difficult to debug as I'm seeing the script being restarted (main() called with gbs == ALLBARS) multiple times. It seems to process a few more bars each time , then begins again.

    Looking at the formulaoutput log I'm on the 24th ALLBARS and have got to candle 62 of 100 and it's been running 10-15 mins so far.

    Of course the debug statements are not helping the execution speed, but without them I expect I won't find it easy to debug.

    I know that, on a first load, you tend to get an ALLBARS for each series you create, but this is getting a bit much.

    All thoughts gratefully received.

    PS: ALLBARS = 31, bars = 74 another 10mins later. termination time.

    PPS: Finally, reduced bar count to 50, it completed (and the efsInternal seems to have worked as it returned a series which I passed it to an ema() to check), but with ALLBARS called 32 times (seems to be an arbitary number of extra candles processed each time from 1 to 10 or so). Not a viable outcome though, so still need help please.

    With 10.1 btw.
    Last edited by Dave180; 07-09-2008, 06:31 AM.

  • #2
    I have found what triggers this multiple ALLBAR behaviour, but don't understand what it means. Or more to the point, what is the intended purpose of arguments passed to efsInternal?

    In the code, see you can edit "bProblem = " to change the behaviour.
    In the forumla output window I see just a couple of "ALLBARS:" ..." prints when bProblem = false and many more when bProblem = true.

    Basically this example will either pass a varying number as an argument to efsInternal, or a fixed number. Does this mean that efs records the parameters and may even generate a new series for each different value? That's what it seems. If so then perhaps the documentation for efsInternal etc should be made clear to those of just trying to get to grips with it what the parameter issue is all about.

    And in case anyone wondering, my efsInternal is meant to be returning values that are based on data not derived solely from the normal series (like close(0) etc), so I'm trying to work out how the efsInternal relates to other code in main.

    PHP Code:
    //
    //
    //  It appears that if a varying number is passed as an argument to efsInternal then the calling main()
    //  will be called multiple times with getBarState() = BARSTATE_ALLBARS
    //
    //  In this example see the difference between the number of "ALLBAR" debug prints depending on whether 
    //  the function parameter is  "On" or not.
    //  
    //  This will likely be a considerable overhead
    //
    //  So what are you meant to pass to efsInternal (apart from a series for setting context)?
    //
    var aFPArray = new Array(); 

    function 
    preMain() {
        
    setPriceStudy(false);
        
    setStudyTitle("efsInternal Multiple ALLBARS prob - see code ");

         
    setShowTitleParametersfalse ); 

    }


    var 
    mnCount 0;
    var 
    mnAllBars 0;

    function 
    TimeAsValue(nHour,nMinute,nSecond) { // Generate data based on time, for testing
        
    return (nHour 6) +nMinute/100  +  nSecond 10000
    }

    function 
    main() {//sProblem) {
        
    var nBSChart getBarState();
        
        var 
    bProblem true// ---------------------->>>> EDIT HERE TO CHANGE BEAVIOR <<<< --------------------------------
        
        
    mnCount++;
        if ( 
    nBSChart == BARSTATE_ALLBARS ) {
            
    debugPrint(" ALLBARS: Problem = " bProblem ", ALLBARS COUNT " mnAllBars ", Prev Main Count: " mnCount " ---------------------------------------------\n");
            
    mnAllBars++;
            
    mnCount 0;
        }
        var 
    bPrintCallsDebug = ( nBSChart == BARSTATE_NEWBAR ); // have as true, just as NEWBAR or none ....
        
    bPrintCallsDebug false// comment out for more verbose output
        
        
    var null;
        if (
    bProblem) {
            
    TimeAsValuehour(0), minute(0) ,  second(0)); // v will vary with each bar (but not each tick)
        
    } else {
            
    1;
        }
        var 
    typeof v;
        if (
    bPrintCallsDebug ) {
            
    debugPrint("\n");
            
    debugPrint("Call efsI : " getCurrentBarIndex() + ", "  " = " "\n");
        }
        var 
    n1 efsInternal("StaticForEfsInternal",v);  // arg is fixed or varyable
        
    var = new Array(vn1.getValue(0) * 1.1sma(5,n1));  // passed value, series return and a simple series of the series return
        
    if (bPrintCallsDebugdebugPrint("Return :                      " a[0] + ", " a[1] + ", " a[2] + "\n");
        return 
    a;
    }


    function 
    StaticForEfsInternal(p1){  // p1 is ignored in sample
        
    return TimeAsValuehour(0), minute(0) ,  second(0)) * 2;  // just a value

    Comment


    • #3
      Dave180

      Does this mean that efs records the parameters and may even generate a new series for each different value?
      If the parameter that is being passed is not a series object or a constant then the efs engine creates a new instance of the series object each time the value of the parameter changes. If you want to pass a parameter that is not a constant then this needs to be a series object which can be a price series ie high(), low(), etc or a builtin study series ie sma(), rsi(), etc or a custom series.

      ...my efsInternal is meant to be returning values that are based on data not derived solely from the normal series (like close(0) etc),...
      Just to clarify close(0) is not a series but a single value. The series would be close()
      Alex


      Originally posted by Dave180
      I have found what triggers this multiple ALLBAR behaviour, but don't understand what it means. Or more to the point, what is the intended purpose of arguments passed to efsInternal?

      In the code, see you can edit "bProblem = " to change the behaviour.
      In the forumla output window I see just a couple of "ALLBARS:" ..." prints when bProblem = false and many more when bProblem = true.

      Basically this example will either pass a varying number as an argument to efsInternal, or a fixed number. Does this mean that efs records the parameters and may even generate a new series for each different value? That's what it seems. If so then perhaps the documentation for efsInternal etc should be made clear to those of just trying to get to grips with it what the parameter issue is all about.

      And in case anyone wondering, my efsInternal is meant to be returning values that are based on data not derived solely from the normal series (like close(0) etc), so I'm trying to work out how the efsInternal relates to other code in main.

      PHP Code:
      //
      //
      //  It appears that if a varying number is passed as an argument to efsInternal then the calling main()
      //  will be called multiple times with getBarState() = BARSTATE_ALLBARS
      //
      //  In this example see the difference between the number of "ALLBAR" debug prints depending on whether 
      //  the function parameter is  "On" or not.
      //  
      //  This will likely be a considerable overhead
      //
      //  So what are you meant to pass to efsInternal (apart from a series for setting context)?
      //
      var aFPArray = new Array(); 

      function 
      preMain() {
          
      setPriceStudy(false);
          
      setStudyTitle("efsInternal Multiple ALLBARS prob - see code ");

           
      setShowTitleParametersfalse ); 

      }


      var 
      mnCount 0;
      var 
      mnAllBars 0;

      function 
      TimeAsValue(nHour,nMinute,nSecond) { // Generate data based on time, for testing
          
      return (nHour 6) +nMinute/100  +  nSecond 10000
      }

      function 
      main() {//sProblem) {
          
      var nBSChart getBarState();
          
          var 
      bProblem true// ---------------------->>>> EDIT HERE TO CHANGE BEAVIOR <<<< --------------------------------
          
          
      mnCount++;
          if ( 
      nBSChart == BARSTATE_ALLBARS ) {
              
      debugPrint(" ALLBARS: Problem = " bProblem ", ALLBARS COUNT " mnAllBars ", Prev Main Count: " mnCount " ---------------------------------------------\n");
              
      mnAllBars++;
              
      mnCount 0;
          }
          var 
      bPrintCallsDebug = ( nBSChart == BARSTATE_NEWBAR ); // have as true, just as NEWBAR or none ....
          
      bPrintCallsDebug false// comment out for more verbose output
          
          
      var null;
          if (
      bProblem) {
              
      TimeAsValuehour(0), minute(0) ,  second(0)); // v will vary with each bar (but not each tick)
          
      } else {
              
      1;
          }
          var 
      typeof v;
          if (
      bPrintCallsDebug ) {
              
      debugPrint("\n");
              
      debugPrint("Call efsI : " getCurrentBarIndex() + ", "  " = " "\n");
          }
          var 
      n1 efsInternal("StaticForEfsInternal",v);  // arg is fixed or varyable
          
      var = new Array(vn1.getValue(0) * 1.1sma(5,n1));  // passed value, series return and a simple series of the series return
          
      if (bPrintCallsDebugdebugPrint("Return :                      " a[0] + ", " a[1] + ", " a[2] + "\n");
          return 
      a;
      }


      function 
      StaticForEfsInternal(p1){  // p1 is ignored in sample
          
      return TimeAsValuehour(0), minute(0) ,  second(0)) * 2;  // just a value

      Comment


      • #4
        Thanks Alexis, I wish there was more documentation to make these things a bit clearer; when learning it is easy to "try things out" without realising the consequences. Once you get the implications of how the series you create will be accessed by other series that manipulate it the, err, stupidity, of pasing varying numbers becomes apparent.

        Comment

        Working...
        X