Simple Futures Moving Average

ICE Data Services -

SimpleFuturesMA.efs  
EFSLibrary - Discussion Board  

File Name: SimpleFuturesMA.efs

Description:
This Indicator plots Simple Futures Moving Average

Formula Parameters:

  • Source of moving averege: close
  • Fast length: 9
  • Slow length: 50
  • Filter length: 80

Notes:
This indicator is a common Moving Average Crossover with another parameter, the Filter added. The Filter ia a lenghty Moving Average, by default - 80. The Alert is given only in the case when the price is not equal to the Filter.

Download File:
SimpleFuturesMA.efs


EFS Code:

/*********************************

Provided By:  

    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2008. 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:        

    This Indicator plots Simple Futures Moving Average

Version:            1.0  09/25/2008

Notes:

    This indicator is a common Moving Average Crossover with another parameter,
    the Filter added. The Filter ia a lenghty Moving Average, by default - 80. 
    The Alert is given only in the case when the price is not equal to the Filter.


Formula Parameters:                     Default:

    Source of moving averege            close
    Fast length                         9
    Slow length                         50
    Filter length                       80
**********************************/

var fpArray = new Array();
var bInit = false;

function preMain() {
    setPriceStudy(true);
    setStudyTitle("Simple Futures MA");
    
    setCursorLabelName("FastMA", 0);
    setCursorLabelName("SlowMA", 1);
    setCursorLabelName("Filter", 2);

    setDefaultBarFgColor(Color.blue, 0);
	setDefaultBarFgColor(Color.red, 1); 
	setDefaultBarFgColor(Color.green, 2);
	
	askForInput();
    var x=0;
    
    fpArray[x] = new FunctionParameter("Price", FunctionParameter.STRING);
	with(fpArray[x++]){
        setName("Source of moving average");
        addOption("open"); 
        addOption("high");
        addOption("low");
        addOption("close");
        addOption("hl2");
        addOption("hlc3");
        addOption("ohlc4"); 
        setDefault("close"); 
    }    
    
    fpArray[x] = new FunctionParameter("FastAvg", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(9);
    }
    
    fpArray[x] = new FunctionParameter("SlowAvg", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(50);
    }
    
    fpArray[x] = new FunctionParameter("AvgFltr", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(80);
    }
}

var xFMA = null;
var xSMA = null;
var xFilter = null;
var xPrice = null;

function main(Price, FastAvg, SlowAvg, AvgFltr) {

    var nBarState = getBarState();
    
    if(nBarState == BARSTATE_ALLBARS) {
        if (Price == null) Price = "close";
        if (FastAvg == null) FastAvg = 9;
        if (SlowAvg == null) SlowAvg = 50;
        if (AvgFltr == null) AvgFltr = 80;
    }  

    
    if (bInit == false) {
        xPrice = eval(Price)();
        xFMA = sma(FastAvg, xPrice);
        xSMA = sma(SlowAvg, xPrice);
        xFilter = sma(AvgFltr, xPrice);
        bInit = true;
    }

    return new Array(xFMA.getValue(0), xSMA.getValue(0), xFilter.getValue(0));

}