Announcement

Collapse
No announcement yet.

Macd Signal Line

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

  • Macd Signal Line

    Good Afternoon to everybody,

    Could somebody please tell me how can I specify that
    I want a simple moving average on the macd signal line
    on my EFS study?

    I don't see a parameter for it here.

    macdSignal( fastLength, slowLength, smoothing [, source | sym() | inv()] [, barIndex] )

    Have a great day,

    Jaime

  • #2
    Re: Macd Signal Line

    Originally posted by jaimeog
    Good Afternoon to everybody,

    Could somebody please tell me how can I specify that
    I want a simple moving average on the macd signal line
    on my EFS study?

    I don't see a parameter for it here.

    macdSignal( fastLength, slowLength, smoothing [, source | sym() | inv()] [, barIndex] )

    Have a great day,

    Jaime
    Part 1:

    PHP Code:

    To Create a Series 

    var myStudy1 null
    var 
    myStudy2 null
    var 
    myStudy3 null
    var 
    bInit false

    function 
    main() { 
    var 
    myVar1
    var 
    myVar2
    var 
    myVar3

       if ( 
    bInit == false ) { 
           
          
    myStudy1 macd1226); 
          
    myStudy2 macdSignal1226); 
          
    myStudy3 macdHist1226); 

          
    bInit true

       } 

       
    //retrieve the current values 
       
    myVar1 myStudy1.getValue(0); 
       
    myVar2 myStudy2.getValue(0); 
       
    myVar3 myStudy3.getValue(0); 

       return new Array( 
    myVar1myVar2myVar3 ); 

    Now myVar2 is the macd signal line.

    Part 2:


    PHP Code:
    smasignal smamyVar220) ;  // sma(20) of macd signal line. 

    There may be a better way but I think this gets you what you want.

    HTH.

    Comment


    • #3
      simple moving average

      Good Afternoon to everybody,

      Could somebody please tell me how can I specify that
      I want a simple moving average on the macd signal line
      on my EFS study?

      I don't see a parameter for it here.

      macdSignal( fastLength, slowLength, smoothing [, source | sym() | inv()] [, barIndex] )

      Have a great day,

      Jaime

      Comment


      • #4
        jaimeog
        The efs2 version of the MACD uses only exponential averages which is why there is no parameter to set the type of average used for the MACD or Signal lines.
        A workaround is to calculate the MACD using the builtin function and then compute a simple moving average of the MACD series as shown in the example enclosed below which is a revision of the basicMACD.efs that is provided in the EFS2 Basic folder of Formulas.
        Alex

        PHP Code:
        function preMain() {
            
        setPriceStudy(false);
            
        setStudyTitle("MACD");
            
        setCursorLabelName("MACD",0);
            
        setCursorLabelName("MACDSig",1);
            
        setCursorLabelName("MACDHist",2);
            
        setDefaultBarFgColor(Color.blue,0); 
            
        setDefaultBarFgColor(Color.red,1);
            
        setDefaultBarFgColor(Color.magenta,2); 
            
        setPlotType(PLOTTYPE_LINE,0);
            
        setPlotType(PLOTTYPE_LINE,1);
            
        setPlotType(PLOTTYPE_HISTOGRAM,2); 
            
        setDefaultBarThickness(1,0);
            
        setDefaultBarThickness(1,1);
            
        setDefaultBarThickness(1,2);
        }

        var 
        myMACD null;
        var 
        mySignal null;

        function 
        main(){

            if(
        myMACD==nullmyMACD macd(12,26,9);
            if(
        mySignal==nullmySignal sma(9,myMACD);
            
            if(
        myMACD.getValue(0)==null||mySignal.getValue(0)==null) return;
            
            var 
        myHist myMACD.getValue(0)-mySignal.getValue(0);

            return new Array (
        myMACD.getValue(0),mySignal.getValue(0),myHist);


        Comment

        Working...
        X