Announcement

Collapse
No announcement yet.

Modified MACD

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

  • Modified MACD

    Is anyone aware of an EFS in the forums for MACD which uses double or triple smoothed EMAs instead of the standard EMAs? Or how I can modify the existing eSignal EFS for MACD to do this? I've had a search of the forums but have been unable to find anything. Many thanks.

  • #2
    Re: Modified MACD

    Originally posted by eurotrader1
    Is anyone aware of an EFS in the forums for MACD which uses double or triple smoothed EMAs instead of the standard EMAs? Or how I can modify the existing eSignal EFS for MACD to do this? I've had a search of the forums but have been unable to find anything. Many thanks.
    Here is the MACD with double smoothed EMAs:

    PHP Code:
    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain() {

        
    setPriceStudy(false);
        
    setShowCursorLabel(false);
        
    setShowTitleParametersfalse );
        
        
    setStudyTitle("Modified MACD");
        
    setCursorLabelName("Zero"0);
        
    setCursorLabelName("MACD"1);
        
    setCursorLabelName("MACDSig"2);
        
    setCursorLabelName("MACDHist"3);        

        
    setDefaultBarFgColor(Color.black0);
        
    setDefaultBarFgColor(Color.blue1);
        
    setDefaultBarFgColor(Color.red2);
        
    setDefaultBarFgColor(Color.magenta3);

        
    setPlotType(PLOTTYPE_LINE0); 
        
    setPlotType(PLOTTYPE_LINE1); 
        
    setPlotType(PLOTTYPE_LINE2); 
        
    setPlotType(PLOTTYPE_HISTOGRAM3);     

        
    setDefaultBarThickness(10);
        
    setDefaultBarThickness(11);
        
    setDefaultBarThickness(12);
        
    setDefaultBarThickness(13);    

       
        
    askForInput();
        var 
    x=0;

        
    fpArray[x] = new FunctionParameter("ViewValue"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Display Cursor Labels");
            
    setDefault(false);
        }    

        
    fpArray[x] = new FunctionParameter("ShowTitleParameters"FunctionParameter.BOOLEAN);
        
    with(fpArray[x++]){
            
    setName("Show Title Parameters");
            
    setDefault(false);
        }    
        
        
        
    fpArray[x] = new FunctionParameter("FastLength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);        
            
    setDefault(12);
        }

        
    fpArray[x] = new FunctionParameter("SlowLength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);        
            
    setDefault(26);
        }

        
    fpArray[x] = new FunctionParameter("MACDLength"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setLowerLimit(1);        
            
    setDefault(9);
        }



        
    fpArray[x] = new FunctionParameter("Thickness"FunctionParameter.NUMBER);
        
    with(fpArray[x++]){
            
    setName("Line Thickness");
            
    setLowerLimit(1);        
            
    setDefault(1);
        }


    }

    var 
    xMyMACD null;
    var 
    xMACDAvg null;
    var 
    xMACDDiff null;
    var 
    xFastMA null;
    var 
    xSlowMA null;


    function 
    main(FastLengthSlowLengthMACDLengthThicknessShowTitleParametersViewValue) {
    var 
    nMACD 0;
    var 
    nMACDAvg 0;
    var 
    nMACDDiff 0;

        if ( 
    bInit == false ) { 
            
    setDefaultBarThickness(Thickness0);
            
    setDefaultBarThickness(Thickness1);
            
    setDefaultBarThickness(Thickness2);
            
    setDefaultBarThickness(Thickness3);
            
    setShowCursorLabel(ViewValue); 
            
    setShowTitleParametersShowTitleParameters );
            
    xFastMA ema(FastLength);
            
    xSlowMA ema(SlowLength);
            
    xFastMA ema(FastLengthxFastMA);
            
    xSlowMA ema(SlowLengthxSlowMA);
            
            
    xMyMACD efsInternal("Calc_MyMACD"xFastMAxSlowMA);
            
    xMACDAvg ema(MACDLengthxMyMACD);
            
    xMACDDiff efsInternal("Calc_MACDDiff"xMyMACDxMACDAvg);
            
    bInit true
        } 

        
    nMACD xMyMACD.getValue(0);
        
    nMACDAvg xMACDAvg.getValue(0);
        
    nMACDDiff xMACDDiff.getValue(0);

        return new Array(
    nMACDnMACDAvgnMACDDiff); 
    }

    function 
    Calc_MyMACD(xFastMAxSlowMA) {
    var 
    nRes 0;

        
    nRes xFastMA.getValue(0) - xSlowMA.getValue(0);
        if (
    nRes == nullnRes 1;

        return 
    nRes;
    }

    function 
    Calc_MACDDiff(xMyMACDxMACDAvg) {
    var 
    nRes 0;
        
        
    nRes xMyMACD.getValue(0) - xMACDAvg.getValue(0);
        if (
    nRes == nullnRes 1;

        return 
    nRes;

    Comment

    Working...
    X