Announcement

Collapse
No announcement yet.

Is it possible to dynamically change a builting function parameter?

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

  • Is it possible to dynamically change a builting function parameter?

    Normally function definitions such as:

    " vstochK = stochK(Length,3,3)"

    are defined within the bInit (execute once) portion of a EFS routine and executed once per EFS invocation.

    Once defined the values generated by the stochK() function are retrieved via the vstochK.getValue(-1) call.

    Is it possible to alter the Length value within the EFS outside of the bInit section to pass different values to the stochK function. For example for one bar passing a 14 and another bar passing 21, etc?

    When I place the function definition outside the bInit loop the EFS backtest takes a very long time and frequently runs out of memory or crashes eSignal.

    Has anyone tried doing this?

    thanks very much,

    Glen
    Last edited by demarcog; 03-21-2009, 07:31 PM.
    Glen Demarco
    [email protected]

  • #2
    Re: Is it possible to dynamically change a builtin function parameter?

    Glen
    It is possible however for each new set of paramaters the efs engine will create a new instance of the series object that will remain in memory for the life of the formula and will eventually fill up the available memory
    Alex


    Originally posted by demarcog
    Normally function definitions such as:

    " vstochK = stochK(Length,3,3)"

    are defined within the bInit (execute once) portion of a EFS routine and executed once per EFS invocation.

    Once defined the values generated by the stochK() function are retrieved via the vstochK.getValue(-1) call.

    Is it possible to alter the Length value within the EFS outside of the bInit section to pass different values to the stochK function. For example for one bar passing a 14 and another bar passing 21, etc?

    When I place the function definition outside the bInit loop the EFS backtest takes a very long time and frequently runs out of memory or crashes eSignal.

    Has anyone tried doing this?

    thanks very much,

    Glen

    Comment


    • #3
      Alex,

      Thanks for the response it sounds like that is exactly what I am seeing happening.

      Would another alternative be to include the code for stochK() inline then just modify that one variable rather then generate the entire series each time?

      Is the code for the buildin functions generally available as I don't recall seeing the EFS code for the stochastics calculation?

      If you know of a file share that has a close approximation I would appreciate you letting me know. I thought I recalled you posting the William Blau's version in an EFS somewhere. I ran some back tests awhile ago comparing the crossovers between Lane and Blau's and was surprised that there was not a significant difference.


      Here is Lane's formula:

      Stochastics Formula
      A momentum or price velocity indicator that was developed by George C. Lane. It represents a fixed period-to-period moving calculation that is very susceptible to instability and false signals since it is possible for the indicator to fluctuate wildly by simply removing data from the oldest period.


      K = (C -L)
      _____ * 100
      ( H - L )

      K = Lane's Stochastics
      C = the latest closing price of the stock or contract
      L = n-period low price of the stock or contract
      H = n-period high price of the stock or contract
      n = any number (Lane recommends a range of 5 to 21)
      SK or %K = three-period simple moving average of K
      SD or %D = three-period simple moving average of SK

      Source: The Encyclopedia of Technical Market Indicators, Colby and Meyers


      Thanks again Alex,

      Glen
      Last edited by demarcog; 03-21-2009, 08:16 PM.
      Glen Demarco
      [email protected]

      Comment


      • #4
        Glen

        Would another alternative be to include the code for stochK() inline...
        Not sure what you mean by "inline".
        If you mean retrieving the value of the stochK() directly [ie stochK(lengthK, smoothK, smoothD, 0)] then this will also create a new instance of the series object each time you pass a new set of parameters.
        If instead you mean using a custom stochastic function that you call as required then that could be an alternative.
        Enclosed below is an old Stochastic%K formula I had that you may want to use
        Alex

        PHP Code:
        function main(lengthK,smoothK) {
            if(
        lengthK == nulllengthK 14;
            if(
        smoothK == nullsmoothK 1;
            var 
        nCount,Close,LL,HH,percentK;
            var 
        nSum 0;
            for(var 
        0smoothKi++) {
                
        nCount i;
                
        Close getValue("Close",-nCount);
                
        LL StochasticLL(lengthK,nCount);
                
        HH StochasticHH(lengthK,nCount);
                if(
        Close == null || LL == null || HH == null) return;
                if((
        HH-LL)!=0percentK = ((Close-LL)/(HH-LL))*100;
                
        nSum += percentK;
            }
            
        nSum /= smoothK;
            return 
        nSum;
        }
        function 
        StochasticLL(inputLength,inputCount) {
            var 
        LL 0;
            var 
        Low getValue("Low",-inputCount,-inputLength);
            if(
        Low == null) return;
            for(var 
        0inputLengthi++) {
                if(
        == 0) {
                    
        LL Low[i];
                } else {
                    
        LL Math.min(LL,Low[i]);
                }
            }
            return 
        LL;
        }
        function 
        StochasticHH(inputLength,inputCount) {
            var 
        HH 0;
            var 
        High getValue("High",-inputCount,-inputLength);
            if(
        High == null) return;   
            for(var 
        0inputLengthi++) {
                if(
        == 0) {
                    
        HH High[i];
                } else {
                    
        HH Math.max(HH,High[i]);
                }
            }
            return 
        HH;


        Originally posted by demarcog
        Alex,

        Thanks for the response it sounds like that is exactly what I am seeing happening.

        Would another alternative be to include the code for stochK() inline then just modify that one variable rather then generate the entire series each time?

        Is the code for the buildin functions generally available as I don't recall seeing the EFS code for the stochastics calculation?

        If you know of a file share that has a close approximation I would appreciate you letting me know. I thought I recalled you posting the William Blau's version in an EFS somewhere. I ran some back tests awhile ago comparing the crossovers between Lane and Blau's and was surprised that there was not a significant difference.


        Here is Lane's formula:

        Stochastics Formula
        A momentum or price velocity indicator that was developed by George C. Lane. It represents a fixed period-to-period moving calculation that is very susceptible to instability and false signals since it is possible for the indicator to fluctuate wildly by simply removing data from the oldest period.


        K = (C -L)
        _____ * 100
        ( H - L )

        K = Lane's Stochastics
        C = the latest closing price of the stock or contract
        L = n-period low price of the stock or contract
        H = n-period high price of the stock or contract
        n = any number (Lane recommends a range of 5 to 21)
        SK or %K = three-period simple moving average of K
        SD or %D = three-period simple moving average of SK

        Source: The Encyclopedia of Technical Market Indicators, Colby and Meyers


        Thanks again Alex,

        Glen

        Comment

        Working...
        X