Announcement

Collapse
No announcement yet.

Sine Wave Moving Average

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

  • Sine Wave Moving Average

    Could someone please convert the following MetaStock code to EFS.

    Sine-Wave Weighted Moving Average

    PI:=3.1415926;
    SD:=180/6;
    S1:=Sin(1*180/6)*C;
    S2:=Sin(2*180/6)*Ref(C,-1);
    S3:=Sin(3*180/6)*Ref(C,-2);
    S4:=Sin(4*180/6)*Ref(C,-3);
    S5:=Sin(5*180/6)*Ref(C,-4);
    Num:=S1+S2+S3+S4+S5;
    Den:=Sin(SD)+Sin(2*SD)+Sin(3*SD)+Sin(4*SD)+Sin(5*S D);
    Num/Den

    Here is the web page with a graph of the MA.


    I have attempted the script but the MA does not look like the one at the above web address.

    Thanks
    Attached Files

  • #2
    whatever
    Enclosed is the efs equivalent
    Alex




    PHP Code:
    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("SineMA");
        
    setCursorLabelName("SineMA");

    }
    function 
    main() {

    var 
    SD Math.PI/6;
    var 
    S1 Math.sin(SD)*close();
    var 
    S2 Math.sin(2*SD)*close(-1);
    var 
    S3 Math.sin(3*SD)*close(-2);
    var 
    S4 Math.sin(4*SD)*close(-3);
    var 
    S5 Math.sin(5*SD)*close(-4);
    var 
    Num S1+S2+S3+S4+S5;
    var 
    Den Math.sin(SD)+Math.sin(2*SD)+Math.sin(3*SD)+Math.sin(4*SD)+Math.sin(5*SD);

    return 
    Num/Den;

    Comment


    • #3
      Thank you Alexis

      Comment


      • #4
        Whatever:

        I posted a SineWeightedMA version about a week ago that uses the same logic but also allows you to change the period.

        You can find it here:

        http://share.esignal.com/groupconten...us&groupid=114

        Chris

        Comment

        Working...
        X