Announcement

Collapse
No announcement yet.

Plotting Standard Deviations

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

  • Plotting Standard Deviations

    I'm trying to work through creating the following study:

    Find the standard deviation of the last ten CLOSES; then, find the value for two variables and plot:

    SDHigh=High of last bar + (SD*2);

    SDLow=Low of last bar - (SD*2);

    ie, just plotting a band that's two SDs (calculated on the last ten closes) from the highs and lows of each bar respectively.

    I've found the standard deviation formula and have tried to write the output to an array, but I'm screwing up somewhere. Values don't appear on the study (or in a separate pane, either).

    Ideas? I suspect this is really simple, but I'm just not conversant enough in the EFS language to write it properly.

    Any help or insights appreciated!

  • #2
    Eric
    The easiest way to calculate the standard deviation of the last nn closes without the need of a specific function is to use the Bollinger Band functions and subtract either the basis line from the upper band band or the lower band from the basis line. So you could write what you want in the following way
    PHP Code:
    var myUpperBand high(0) + (upperBB(10,2) - middleBB(10,2));
    var 
    myLowerBand low(0) - (upperBB(10,2) - middleBB(10,2)); 
    For information on the Bollinger Band functions see this article in the EFS KnowledgeBase.
    If you instead prefer to use a separate function to calculate the standard deviation then you may want to consider using either the amFunctions library available here or the dsFunctions library available here both of which include a Standard Deviation function. The documentation for each function library is available at the corresponding links
    Alex

    Comment


    • #3
      Alexis:

      Thanks very much indeed. That's exactly what I needed.

      Thank you again!

      Eric

      Comment


      • #4
        Eric
        You are most welcome
        Alex

        Comment

        Working...
        X