KeltnerArEmaAdj.efs

ICE Data Services -

KeltnerArEmaAdj.efs  

File Name: KeltnerArEmaAdj.efs

Description:
Keltner study with a 20 period exponential moving average of the basis line and bands based on 2.5 * Average Range.

Formula Parameters:

  • nInputLength: Default is 20
  • nRangeFactor: Default is 2.5

Notes:
NA

Download File:
KeltnerArEmaAdj.efs



EFS Code:

/*****************************************************************
Provided By : eSignal. (c) Copyright 2003
*****************************************************************/

function preMain() {
    setPriceStudy(true);
    
    /* Set the title that will appear in the study pane */
    setStudyTitle("Keltner");

    /* Set the label that will appear in the cursor window */
    setCursorLabelName("K-Upper", 0);
    setCursorLabelName("K-Basis", 1);
    setCursorLabelName("K-Lower", 2);

    setDefaultBarFgColor(Color.blue, 0); // upper
	setDefaultBarFgColor(Color.red, 1); // basis
	setDefaultBarFgColor(Color.blue, 2); // lower
}


function main(nInputLength, nRangeFactor) {
	if(nInputLength == null)
		nInputLength = 20;
	if(nInputLength <= 0)
		nInputLength = 20;

	if(nRangeFactor == null)
		nRangeFactor = 2.5;
	if(nRangeFactor <= 0)
		nRangeFactor = 2.5;

	var dHigh = high(0, -nInputLength);
	var dLow = low(0, -nInputLength);
	var dKeltnerBasis= call("/Library/KeltnerEMA.efs", nInputLength);

	if(dHigh == null || dLow == null || dKeltnerBasis == null)
		return;

	var dHminL = 0;
	var i;

	for(i = 0; i < nInputLength; i++) {
		dHminL += dHigh[i] - dLow[i];
	}

	dHminL /= nInputLength;

	return new Array(dKeltnerBasis + (nRangeFactor * dHminL), dKeltnerBasis, dKeltnerBasis - (nRangeFactor * dHminL));
}