File Name: Keltner_ATR_Band.efs
Description:
Keltner ATR Band
Formula Parameters:
Length : 50
ATRMult : 3.75
Notes:
Download File:
Keltner_ATR_Band.efs
EFS Code:
Description:
Keltner ATR Band
Formula Parameters:
Length : 50
ATRMult : 3.75
Notes:
Download File:
Keltner_ATR_Band.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:
Keltner ATR Band
Version: 1.0 10/29/2009
Formula Parameters: Default:
Length 50
ATRMult 3.75
Notes:
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain(){
setPriceStudy(true);
setShowCursorLabel(true);
setShowTitleParameters(false);
setStudyTitle("Keltner ATR Band");
setCursorLabelName("Up Band", 0);
setPlotType(PLOTTYPE_LINE, 0);
setDefaultBarFgColor(Color.red, 0);
setCursorLabelName("Dn Band", 1);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarFgColor(Color.red, 1);
var x = 0;
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(50);
}
fpArray[x] = new FunctionParameter("ATRMult", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setLowerLimit(1);
setDefault(3.75);
}
}
var xKUp = null;
var xKDn = null;
function main(Length, ATRMult) {
var nBarState = getBarState();
var nKU = 0;
var nKL = 0;
if (nBarState == BARSTATE_ALLBARS) {
if(Length == null) Length = 50;
if(ATRMult == null) ATRMult = 3.75;
}
if (bInit == false) {
xKUp = efsInternal("Calc_KeltnerBand", Length, ATRMult);
xKDn = getSeries(xKUp, 1);
bInit = true;
}
nKU = xKUp.getValue(0);
nKL = xKDn.getValue(0);
if (nKU == null || nKL == null) return;
return new Array(nKU, nKL);
}
var bSecondInit = false;
var xMA = null;
var xATR = null;
function Calc_KeltnerBand(Length, ATRMult) {
var nResUp = 0;
var nResDn = 0;
var nMA = 0;
var nATR = 0;
if (bSecondInit == false) {
xMA = sma(Length);
xATR = atr(Length);
bSecondInit = true;
}
nMA = xMA.getValue(0);
nATR = xATR.getValue(0);
if (nMA == null || nATR == null) return;
nResUp = nMA + ATRMult * nATR;
nResDn = nMA - ATRMult * nATR;
return new Array(nResUp, nResDn);
}