Announcement

Collapse
No announcement yet.

MACDColorHist.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MACDColorHist.efs

    File Name: MACDColorHist.efs (MACD Colored Histogram)

    Description:
    Colors MACD histogram green when rising, red when falling. All inputs to MACD are configurable including histogram color. The display of the MACD histogram, Signal, MACD and MACD drop-lines can be turned on/off individually. The color of the drop-lines will match the up/down colors of the histogram up/down color settings. When the MACD is positive, the drop-down lines will be the up color and down color when the MACD is negative.

    Formula Parameters:
    Fast Length: Default is 12
    Slow Length: Default is 26
    Smoothing Length: Default is 9
    Price Source: Default is Close, [Open, High, Low, Close, HL/2, HLC/3, OHLC/4]
    MA Type: Default is SMA, [SMA, EMA]
    MACD Hist Up Color: Default is green
    MACD Hist Down Color: Default is red
    MACD Color: Default is red
    MACD Sig Color: Default is blue
    Display Histogram: Yes, [Yes, No]
    Display MACD: Yes, [Yes, No]
    Display Signal: Yes, [Yes, No]
    Display Drop Lines: Yes, [Yes, No]

    Notes:


    Download File:
    MACDColorHist.efs




    EFS Code:
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    *********************************/

    /***  Updated 12/1/2003  ***
        
    *Added FunctionParameter objects for user defined inputs.
    *Added drop-down lines to the MACD where the color will 
     match the up/down colors of the histogram up/down color 
     settings.  When MACD is positive, drop-down lines will be 
     the up color and down color when the MACD is negative.
    *Added options to enable/disable MACD histogrram, Signal, 
     MACD and MACD drop-lines.
        
        
    ***************************/

    function preMain() {
        
    setStudyTitle("Color MACD Histogram ");
        
    setCursorLabelName("MACD"0);
        
    setCursorLabelName("MACD"1);
        
    setCursorLabelName("MACD Sig"2);
        
    setCursorLabelName("MACD Hist"3);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.blue1);
        
    setDefaultBarFgColor(Color.red2);
        
    setDefaultBarFgColor(Color.magenta3);
        
    setDefaultBarThickness(43);
        
    setPlotType(PLOTTYPE_LINE0);
        
    setPlotType(PLOTTYPE_HISTOGRAM1);
        
    setPlotType(PLOTTYPE_LINE2);
        
    setPlotType(PLOTTYPE_HISTOGRAM3);
        
        
    addBand(0PS_SOLID1Color.black"zero");
        
        var 
    fp1 = new FunctionParameter("nFast"FunctionParameter.NUMBER);
        
    fp1.setName("Fast Length");
        
    fp1.setLowerLimit(1);
        
    fp1.setDefault(12);
        
        var 
    fp2 = new FunctionParameter("nSlow"FunctionParameter.NUMBER);
        
    fp2.setName("Slow Length");
        
    fp2.setLowerLimit(1);
        
    fp2.setDefault(26);

        var 
    fp3 = new FunctionParameter("nSmoothing"FunctionParameter.NUMBER);
        
    fp3.setName("Smoothing Length");
        
    fp3.setLowerLimit(1);
        
    fp3.setDefault(9);

        var 
    fp4 = new FunctionParameter("PriceSource"FunctionParameter.STRING);
        
    fp4.setName("Price Source");
        
    fp4.addOption("Open");
        
    fp4.addOption("High");
        
    fp4.addOption("Low");
        
    fp4.addOption("Close");
        
    fp4.addOption("HL/2");
        
    fp4.addOption("HLC/3");
        
    fp4.addOption("OHLC/4");
        
    fp4.setDefault("Close");

        var 
    fp5 = new FunctionParameter("nType"FunctionParameter.STRING);
        
    fp5.setName("MA Type");
        
    fp5.addOption("SMA");   //true
        
    fp5.addOption("EMA");   //false
        
    fp5.setDefault("SMA");
        
        var 
    fp6 = new FunctionParameter("nColorUp"FunctionParameter.COLOR);
        
    fp6.setName("MACD Hist Up Color");
        
    fp6.setDefault(Color.green);
        
        var 
    fp7 = new FunctionParameter("nColorDn"FunctionParameter.COLOR);
        
    fp7.setName("MACD Hist Down Color");
        
    fp7.setDefault(Color.red);
        
        var 
    fp8 = new FunctionParameter("cMACD"FunctionParameter.COLOR);
        
    fp8.setName("MACD Color");
        
    fp8.setDefault(Color.red);

        var 
    fp9 = new FunctionParameter("cMACDsig"FunctionParameter.COLOR);
        
    fp9.setName("MACD Sig Color");
        
    fp9.setDefault(Color.blue);

        var 
    fp10 = new FunctionParameter("bHist"FunctionParameter.STRING);
        
    fp10.setName("Display Histogram");
        
    fp10.addOption("Yes");
        
    fp10.addOption("No");
        
    fp10.setDefault("Yes");

        var 
    fp11 = new FunctionParameter("bMACD"FunctionParameter.STRING);
        
    fp11.setName("Display MACD");
        
    fp11.addOption("Yes");
        
    fp11.addOption("No");
        
    fp11.setDefault("Yes");

        var 
    fp12 = new FunctionParameter("bSignal"FunctionParameter.STRING);
        
    fp12.setName("Display Signal");
        
    fp12.addOption("Yes");
        
    fp12.addOption("No");
        
    fp12.setDefault("Yes");

        var 
    fp13 = new FunctionParameter("bDropLines"FunctionParameter.STRING);
        
    fp13.setName("Display Drop Lines");
        
    fp13.addOption("Yes");
        
    fp13.addOption("No");
        
    fp13.setDefault("Yes");
    }

    var 
    study null;
    var 
    vColor null;
    var 
    vColorUp null;
    var 
    vColorDn null;
    var 
    vHist null;
    var 
    vHist1 null;
    var 
    bEdit true;

    function 
    main(nFastnSlownSmoothingPriceSourcenTypenColorUpnColorDn
                    
    cMACDcMACDsigbHistbMACDbSignalbDropLines) {
        if (
    study == null || bEdit == true) {
            if (
    nFast == nullnFast 12;
            if (
    nSlow == nullnSlow 26;
            if (
    nSmoothing == nullnSmoothing 9;
            if (
    PriceSource == nullPriceSource "Close";
            if (
    nType == null) {
                
    nType false;
            } else if (
    nType == "SMA") {
                
    nType true;
            } else {
                
    nType false;
            }
            if (
    nColorUp == null) {
                
    vColorUp Color.green;
            } else {
                
    vColorUp nColorUp;
            }
            if (
    nColorDn == null) {
                
    vColorDn Color.red;
            } else {
                
    vColorDn nColorDn;
            }
            
    study = new MACDStudy(nFastnSlownSmoothingPriceSourcenType);
            
    setDefaultBarFgColor(cMACD0);
            
    setDefaultBarFgColor(cMACD1);
            
    setDefaultBarFgColor(cMACDsig2);
            
    setDefaultBarFgColor(cMACDsig3);
            
    bEdit false;
        }
        
        if (
    getBarState() == BARSTATE_NEWBAR && vHist != null) {
            
    vHist1 vHist;
        }
        
        
    vHist study.getValue(MACDStudy.HIST);
        if (
    vHist == null)
            return;
        var 
    vMACD study.getValue(MACDStudy.MACD);
        if (
    vMACD == null)
            return;
        var 
    vSig study.getValue(MACDStudy.SIGNAL);
        if (
    vSig == null)
            return;
        
        if (
    vHist1 != null && vHist >= vHist1) {
            
    vColor vColorUp;
        } else if (
    vHist1 != null && vHist vHist1) {
            
    vColor vColorDn;
        }
        
        if (
    vMACD 0setBarFgColor(nColorDn1);
        if (
    vMACD >= 0setBarFgColor(nColorUp1);
        if (
    vColor != null) {
            
    setBarFgColor(vColor3);
        }
        var 
    vHdisplay vHist.toFixed(2)*1;
        if (
    bHist == "No"vHdisplay vHdisplay+"";
        var 
    vMdisplay vMACD.toFixed(2)*1;
        if (
    bMACD == "No"vMdisplay vMdisplay+"";
        var 
    vMdisplay1 vMACD.toFixed(2)*1;
        if (
    bDropLines == "No"vMdisplay1 vMdisplay1+"";
        var 
    vSdisplay vSig.toFixed(2)*1;
        if (
    bSignal == "No"vSdisplay vSdisplay+"";
        
        return new Array(
    vMdisplayvMdisplay1vSdisplayvHdisplay);

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X