MAofROC.efs

ICE Data Services -

MAofROC.efs  

File Name: MAofROC.efs

Description:
Moving Average of Rate of Change oscillator.

Formula Parameters:

  • rocLength: Default is 21
  • rocPriceSource: Default is "Close"
  • valid inputs: Open, High, Low, Close, HL/2, HLC/3 and OHLC/4

Notes:
NA

Download File:
MAofROC.efs



EFS Code:

/*********************************************************
Alexis C. Montenegro © December 2004                      
Use and/or modify this code freely. If you redistribute it
please include this and/or any other comment blocks and a 
description of any changes you make.                      
**********************************************************/

var fpArray = new Array();

function preMain() {
    setStudyTitle("MAofROC");
    setCursorLabelName("ROC", 0);
    setCursorLabelName("MAofROC", 1);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarFgColor(Color.red, 1);
    setDefaultBarThickness(1,0);
    setDefaultBarThickness(1,1);
    var x=0;
    fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(10);
    }
	fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING);
	with(fpArray[x++]){
        addOption("open"); 
        addOption("high");
        addOption("low");
        addOption("close");
        addOption("hl2");
        addOption("hlc3");
        addOption("ohlc4"); 
        setDefault("close"); 
    }
    fpArray[x] = new FunctionParameter("Symbol", FunctionParameter.STRING);
    with(fpArray[x++]){
        setDefault();
	}
	fpArray[x] = new FunctionParameter("Interval", FunctionParameter.STRING);
	with(fpArray[x++]){
        setDefault();
    }
    fpArray[x] = new FunctionParameter("MAType", FunctionParameter.STRING);
    with(fpArray[x++]){
        addOption("sma");
        addOption("ema");
        addOption("wma");
        setDefault("sma");
    }
	fpArray[x] = new FunctionParameter("MALength", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(10);
    }
    fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);
	with(fpArray[x++]){
        setName("Color1");
        setDefault(Color.blue);
    }
	fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);
	with(fpArray[x++]){
        setName("Color2");
        setDefault(Color.red);
    }
    fpArray[x] = new FunctionParameter("Params", FunctionParameter.BOOLEAN);
	with(fpArray[x++]){
        setName("Show Parameters");
        setDefault(false);
    }
}

var bInit = false;
var xROC = null;
var xMAofROC = null;

function main(Length,Source,Symbol,Interval,MAType,MALength,LineColor1,LineColor2,Params) {
    if(bInit == false){
        if(Symbol == null) Symbol = getSymbol();
        if(Interval == null) Interval = getInterval();
        var vSymbol = Symbol+","+Interval;
        xROC = getSeries(roc(Length,eval(Source)(sym(vSymbol))));
        xMAofROC = getSeries(eval(MAType)(MALength,roc(Length,eval(Source)(sym(vSymbol)))));
        setDefaultBarFgColor(LineColor1,0);
        setDefaultBarFgColor(LineColor2,1);
        setShowTitleParameters(eval(Params));
        bInit = true;
    }
    return new Array (xROC,xMAofROC);
}