Announcement

Collapse
No announcement yet.

DiNapoli MACD Histogram

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

  • DiNapoli MACD Histogram

    Can anybody please help me to add a histogram to the built-in DiNapoli MACD indicator?

    Thanks, Steven

  • #2
    .
    Here you go:

    PHP Code:

    /***************************
    Copyright © eSignal, a division of Interactive Data Corporation. 2003. All rights reserved. 
    This sample eSignal Formula Script (EFS) may be modified and saved under a new 
    filename; however, eSignal is no longer responsible for the functionality once modified.
    eSignal reserves the right to modify and overwrite this EFS file with each new release.
    ******************************/
    function preMain() {
        
    setStudyTitle("DiNapoli MACD");
        
    setDefaultBarFgColor(Color.red0); // MACD EMA
        
    setDefaultBarFgColor(Color.green1); // Signal Line
        
    setDefaultBarFgColor(Color.magenta2); // histogram
     
        
    setCursorLabelName("DiNapoli MACD"0);
        
    setCursorLabelName("Signal Line"1);
        
    setCursorLabelName("Histogram"2);   // histogram


        
    setPlotType(PLOTTYPE_HISTOGRAM ,2);  // histogram
        
    setDefaultBarThickness(3,2); // histogram


    }

    var 
    ema1 0;
    var 
    ema2 0;
    var 
    ema1_prev 0;
    var 
    ema2_prev 0;
    var 
    macd1 0;
    var 
    macd1_prev 0;
    var 
    macdema 0;
    var 
    macdema_prev 0;
    var 
    SLine 0;

    var 
    sf1 .213;
    var 
    sf2 .108;
    var 
    sf3 .199;

    var 
    length1 8;
    var 
    length2 18;
    var 
    length3 9;

    var 
    cntr 0;
    var 
    0;

    function 
    ema(nClosenEmanSF){
        var 
    val 0;
        if(
    nClose == null){
            return;
        }
        
    val = (nClose nEma) * nSF nEma;    
        return 
    val;
    }

    function 
    main() {
        var 
    nState getBarState();
        
    cntr cntr 1;
        var 
    P1 getValue("Close");
        var 
    P2 getValue("Close", -11);

        if (
    cntr == 18) {
            var 
    sum 0;
            var 
    price getValue("Close"0, -length1);
            
            
    // get ema1;        
            
    if(price == null){
                return;
            } else {
                for(
    0length1i++) {
                    
    sum += price[i];
                }
                
    ema1 sum length1;
            }
            
    ema1_prev ema1;
            
            
    sum 0;
            
    price getValue("Close"0, -length2);
            
            
    // get ema2;        
            
    if(price == null) {
                return;
            } else {
                for(
    0length2i++) {
                    
    sum += price[i];
                }
                
    ema2 sum length2;
            }
            
    ema2_prev ema2;        
        } else if (
    cntr 18) {
            if (
    nState == BARSTATE_NEWBAR) {
                
    ema1_prev ema1;
                
    ema2_prev ema2;
                
    macd1_prev macd1;
                
    macdema_prev macdema;
            }
            
    ema1 ema(P1ema1_prevsf1);
            
    ema2 ema(P1ema2_prevsf2);
            
    macd1 ema1 ema2;
            
    macdema ema(macd1macdema_prevsf3);
            
            
    SLine = (macd1 macd1_prev) * sf3 macd1_prev;
            
            
    xDiff SLine -  macdema // histogram

            
    addBand0PS_SOLID1Color.black ,"HorzLine1") ; // histogram

            
    return new Array(macdemaSLinexDiff); // histogram
        
    } else {
            return;
        }

    Last edited by buzzhorton; 08-09-2006, 01:31 PM.

    Comment


    • #3
      Thank you so much for the efs.

      Just one thing, the Histogram is inverted on the efs you sent. It was a simple change to fix... but I though you should know.

      Thanks, Steven

      Comment

      Working...
      X