Announcement

Collapse
No announcement yet.

moving average of the difference of two moving averages

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

  • moving average of the difference of two moving averages

    what's the efs program code for this metastock formula:

    MOV( MOV(C,3,S) - MOV(C,13,S), 3, S)

    where C=close()
    S=simple Mov Avg

    thanks

  • #2
    fx9
    There are several ways in which it could be written. The simplest is to use the dsDiffSeries() function which is included in the dsFunctions.efsLib function library programmed by Chris Kryza and available here together with its User Guide.
    If you used that function then you would first call the library and then in main you would simply create a moving average of the function
    PHP Code:
    var myLib addLibrary("dsFunctions.efsLib");
    var 
    myStudy null;

    function 
    main(){
        if(
    myStudy==nullmyStudy sma(3myLib.dsDiffSeries(sma(3), sma(13)));
        
    //rest of your code 
    Then use myStudy.getValue(0) for your return statement
    Alex

    Comment


    • #3
      Execllent!
      This does the job quite elegantly.

      Thank you

      Comment


      • #4
        fx9
        You are most welcome
        Alex

        Comment

        Working...
        X