Announcement

Collapse
No announcement yet.

EMA of STDDEV

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

  • EMA of STDDEV

    Does anyone have any ideas on how best to get the EMA of the standard deviation indicator below? I don't want to plot an EMA over stddev, but create a formula to give me the EMA of stddev.
    In other words, how best to adapt the ema.efs formula in the Library folder so that it gives the ema not of the close, but of stddev below?



    Here's my formula for stddev:

    function main(nInputLength) {
    if(nInputLength == null)
    nInputLength = 13;

    var nLength = nInputLength;
    var i;
    var j;
    var vSum = 0.0;
    var vSuma = 0.0;
    var vSumAvg;
    var vValue;
    var stdev;
    var period;
    var vSumaprev;
    var test;

    period = 0;

    vValue = close(period, -nLength);

    if(vValue == null) {
    return;
    }

    for(i = 0; i < nLength; i++) {
    vSum += vValue[i];
    }

    vSumAvg = vSum/nLength;

    // return (vSum / nLength);

    for(j = 0; j < nLength; j++) {
    vSuma += ((vValue[j] - vSumAvg)*(vValue[j] - vSumAvg))/nLength;

    }

    stdev = Math.sqrt(vSuma);

    return stdev;
    }

  • #2
    You can set up an EMA study in the same efs using the variable representing STDEV in place of close and assigning it another variable name. Then return the emastd along with the other variables you want to chart over price.

    Comment


    • #3
      Hi BrookeElise, long time since I saw a post from you.

      What I would do is take the ema.efs code and where it does a call to getValue("Close", 0, -nInputLength) I would sub in:

      callFunction("path/myStdDevFunction");

      I suspect that would be the easiest way of doing this.

      Let me know if you have q's.

      Garth
      Garth

      Comment

      Working...
      X