Announcement

Collapse
No announcement yet.

Simple StdDev ?

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

  • Simple StdDev ?

    new EFS user would like to know how I can take the standard deviation of the last 30 closes? I have tried to find the math function/format for this but seem to be unable to this point.

    just trying to code this calculation in the simplest way possible:

    HistVol = StdDev(Close,30)

    thanks,

  • #2
    c_13:

    You can add the following function to your EFS script and then call it as needed:

    myStdDev = StdDev( 30 );

    will give you the standard deviation of the last 30 closes.

    Chris


    PHP Code:
    //== calculate standard deviation
    function StdDevPeriod ) {
    var 
    x         0;
    var 
    nAvg     0;
    var 
    nSumAvg 0;

        while( 
    x<Period ) {
            
    nAvg += close(-x);
            
    x++;
        }
        
        
    nAvg /= Period;
        
        
    nSumAvg 0;
        
    x=0;
        while( 
    x<Period ) {
            
    nSumAvg += ( close(-x) - nAvg ) * ( close(-x) - nAvg );
            
    x++;
        }
        
    nSumAvg /= Period;
        
        return( 
    Math.sqrtnSumAvg ) );


    Comment


    • #3
      thanks for posting that Chris. From the looks of things EFS is going to be a real challenge to learn -- but worth it.

      c_13

      Comment


      • #4
        I have tried unsuccessfully to merge the Sdtev calc into my indicator. Is it necessary to group the returned values or can this Stdev remain on its own? The indicator returns HH & LL but I wanted to use the Stdev calc with the HH & LL to modify the final outputs. Is this a matter of pasting the Stdev calc previous to function preMain?

        thank you
        Last edited by c_13; 02-24-2004, 09:22 AM.

        Comment


        • #5
          c_13:

          Try the attached. It is a simple example that demonstrates the usage of the StdDev function.

          Chris
          Attached Files

          Comment

          Working...
          X