MBA

ICE Data Services -

MBA.efs                                                                                                                               EFSLibrary - Discussion Board

File Name: MBA.efs


Description:
MBA

Formula Parameters:

Notes:

Download File:
MBA.efs




EFS 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:        
    MBA
Version:            1.0  08/26/2009
 
Formula Parameters:                     Default:
   
Notes:
    
**********************************/
var bInit = false;

function preMain(){
    setPriceStudy(false);
    setShowCursorLabel(true);
    setShowTitleParameters(false);
    setStudyTitle("MBA");
    setCursorLabelName("1", 0);
    setDefaultBarFgColor(Color.red, 0);
    setPlotType(PLOTTYPE_HISTOGRAM, 0);
    setDefaultBarThickness(2,0);        
    setCursorLabelName("2", 1);
    setDefaultBarFgColor(Color.blue, 1);
    setPlotType(PLOTTYPE_LINE, 1);
}

var xMA_MBA = null;

function main() {
var nMA_MBA = 0;
var nMA_MBA1 = 0;
	if (bInit == false) {
        xMA_MBA = sma(2, efsInternal("Calc_MBA"));
        bInit = true;
	}
    nMA_MBA = xMA_MBA.getValue(0);
    nMA_MBA1 = xMA_MBA.getValue(-1);    
    if (nMA_MBA1 == null) return;
    if (nMA_MBA > nMA_MBA1) setBarFgColor(Color.green, 0);    
    if (nMA_MBA <= nMA_MBA1) setBarFgColor(Color.yellow, 0);        
    return new Array(nMA_MBA, nMA_MBA);
}

var bSecondInit = false;
var xMACD = null;
var xStoch = null;
var xRSI = null;
var xMoment = null;

function Calc_MBA() {
var nRes = 0;
var nMACD = 0;
var nStoch = 0; 
var nRSI = 0;
var nMoment = 0;
	if (!bSecondInit) {
        xMACD = macd(12, 26, 9);
        xStoch = stochK(9, 2, 1);
        xRSI = rsi(9);
        xMoment = mom(9);
        bSecondInit = true;
	}
    nMACD = xMACD.getValue(0);
    nStoch = xStoch.getValue(0) * 1000;
    nRSI = xRSI.getValue(0);
    nMoment = xMoment.getValue(0) + 100;
    if (nMACD == null || nStoch == null || nRSI == null || nMoment == null) return;
    if (nMoment != 0) {
        nRes = nStoch * (nMACD + nRSI) / nMoment;	
    } else {
        nRes = 0;
    }    
    return nRes;
}