Announcement

Collapse
No announcement yet.

MASS Index

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

  • MASS Index

    File Name: MassIndex.efs

    Description:
    MASS Index

    Formula Parameters:
    nSetup : 27
    nTrigger : 26.5
    nLength1 : 9
    nLength2 : 25


    Notes:
    The Mass Index was designed to identify trend reversals by measuring
    the narrowing and widening of the range between the high and low prices.
    As this range widens, the Mass Index increases; as the range narrows
    the Mass Index decreases.
    The Mass Index was developed by Donald Dorsey.


    Download File:
    MassIndex.efs



    EFS Code:
    PHP Code:
    /*********************************
    Provided By:  
        eSignal (Copyright c eSignal), a division of Interactive Data 
        Corporation. 2009. All rights reserved. This sample eSignal 
        Formula Script (EFS) is for educational purposes only and may be 
        modified and saved under a new file name.  eSignal is not responsible
        for the functionality once modified.  eSignal reserves the right 
        to modify and overwrite this EFS file with each new release.

    Description:        
        MASS Index
    Version:            1.0  04/17/2009

    Formula Parameters:                     Default:
        nSetup                              27
        nTrigger                            26.5
        nLength1                            9
        nLength2                            25
        
    Notes:
        The Mass Index was designed to identify trend reversals by measuring 
        the narrowing and widening of the range between the high and low prices. 
        As this range widens, the Mass Index increases; as the range narrows 
        the Mass Index decreases.
        The Mass Index was developed by Donald Dorsey. 
    **********************************/
    var fpArray = new Array();
    var 
    bInit false;

    function 
    preMain() {
        
    setStudyTitle("Mass Index");
        
    setCursorLabelName("MassIndex"0);
        
    setDefaultBarFgColor(Color.red0);
        var 
    0;
        
    fpArray[x] = new FunctionParameter("nSetup"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(27);
        }
        
    fpArray[x] = new FunctionParameter("nTrigger"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(26.5);
        }    
    fpArray[x] = new FunctionParameter("nLength1"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(9);
        }    
    fpArray[x] = new FunctionParameter("nLength2"FunctionParameter.NUMBER);
        
    with(fpArray[x++]) {
            
    setLowerLimit(1);
            
    setDefault(25);
        }
    }

    var 
    xMassIndex null;

    function 
    main(nSetupnTriggernLength1nLength2) {
    var 
    nBarState getBarState();
    var 
    nMassIndex 0;
        if (
    nBarState == BARSTATE_ALLBARS) {
            if (
    nSetup != nullnSetup 27;
            if (
    nTrigger != nullnTrigger 26.5;
            if (
    nLength1 != nullnLength1 9;
            if (
    nLength2 != nullnLength2 25;
        }    
        if (
    bInit == false) {
            
    addBand(nSetupPS_SOLID1Color.blue1);
            
    addBand(nTriggerPS_SOLID1Color.blue2);
            
    xMassIndex efsInternal("Calc_MassIndex"nLength1nLength2);
            
    bInit true;
        }
        
    nMassIndex xMassIndex.getValue(0);
        return 
    nMassIndex;
    }   

    var 
    bSecondInit false;
    var 
    xSmoothXAvg null;
    var 
    xEMA null;

    function 
    Calc_MassIndex(nLength1nLength2) {
    var 
    nSmoothXAvg 0;
    var 
    nRes 0;
    var 
    0;
        if (
    bSecondInit == false) {
            
    xEMA ema(nLength1efsInternal("Calc_Price"));
            
    xSmoothXAvg ema(nLength1xEMA);
            
    bSecondInit true;
        }
        if (
    xSmoothXAvg.getValue(-nLength2) == null || xEMA.getValue(-nLength2) == null) return;
        for (
    0nLength2i++) {
            
    nSmoothXAvg xSmoothXAvg.getValue(-i);
            if (
    nSmoothXAvg != 0nRes += xEMA.getValue(-i) / nSmoothXAvg;
        }
        return 
    nRes;
    }    

    function 
    Calc_Price() {
    var 
    nRes 0;
        
    nRes high(0) - low(0);
        if (
    nRes == null) return;
        return 
    nRes;

Working...
X