Announcement

Collapse
No announcement yet.

Different Moving Average

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

  • Different Moving Average

    Dear sirs

    I want to create a moving average of (Close - Open) and not only the Close Price (or other parameters already offered).

    The program must offer the possibility to change the moving average "length".

    Thanks for your help !

    Kind regards,

  • #2
    Hi pbereau,

    Check out the first post in this thread which shows you how to do this using the EFS2 command efsExternal() and has several example efs's which show both an ema and a double ema of an external source (among others). These can easily be modified to do what you want by changing
    PHP Code:
    //this is the separate function that calculates the range
    function range() {

        return (
    high()-low()); //calculate the range
    }


    //change to 

    //this is the separate function that calculates the range
    function range() {

       return (
    close()-open()); //calculate the range

    Comment


    • #3
      //this should get you started in the right direction too

      var vSMA10 = new MAStudy(10, 0, "Close", MAStudy.SIMPLE);
      var vSMA10_of_Open = new MAStudy(10, 0, "Open", MAStudy.SIMPLE);
      function preMain() {
      setPriceStudy(true);
      setStudyTitle("cminusoma");
      setCursorLabelName("c", 0);
      setDefaultBarStyle(PS_SOLID, 0);
      setDefaultBarFgColor(Color.red, 0);
      setDefaultBarThickness(1, 0);
      setPlotType(PLOTTYPE_LINE, 0);
      }

      function main() {
      return (vSMA10.getValue(MAStudy.MA)/2 - vSMA10_of_Open.getValue(MAStudy.MA)/2+vSMA10.getValue(MAStudy.MA));
      }

      Comment

      Working...
      X