File Name: QCharts_Keltner.efs
Description:
This is the Keltner study with the same parameter options as the Keltner study from QCharts with the exception of the Volume source.
Formula Parameters:
Length: 8
Source: AvgHLC
__ [Open, High, Low, Close, AvgHL, AvgHLC, AvgOHLC, AvgOC, AvgHLC]
Exponential: true
Bands Color: blue
Bands Thickness: 1
Bands Multiplier: 1.3
Basis Color: red
Basis Thickness: 1
Display Basis Line: true
Notes:
The bands are based on the average of the High-Low for the same number of periods as specified by the Length parameter multiplied by the Bands Multiplier.
Download File:
QCharts_Keltner.efs
EFS Code:
Description:
This is the Keltner study with the same parameter options as the Keltner study from QCharts with the exception of the Volume source.
Formula Parameters:
Length: 8
Source: AvgHLC
__ [Open, High, Low, Close, AvgHL, AvgHLC, AvgOHLC, AvgOC, AvgHLC]
Exponential: true
Bands Color: blue
Bands Thickness: 1
Bands Multiplier: 1.3
Basis Color: red
Basis Thickness: 1
Display Basis Line: true
Notes:
The bands are based on the average of the High-Low for the same number of periods as specified by the Length parameter multiplied by the Bands Multiplier.
Download File:
QCharts_Keltner.efs
EFS Code:
PHP Code:
/*****************************************
Provided By : eSignal. (c) Copyright 2006
******************************************/
function preMain() {
setPriceStudy(true);
setStudyTitle("QCharts Keltner");
setShowTitleParameters(false);
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
var fp1 = new FunctionParameter("nLength", FunctionParameter.NUMBER);
fp1.setName("Length");
fp1.setLowerLimit(1);
fp1.setDefault(8);
var fp2 = new FunctionParameter("Source", FunctionParameter.STRING);
fp2.setName("Source");
fp2.addOption("Open");
fp2.addOption("High");
fp2.addOption("Low");
fp2.addOption("Close");
fp2.addOption("AvgHL");
fp2.addOption("AvgHLC");
fp2.addOption("AvgOHLC");
fp2.addOption("AvgOC");
fp2.setDefault("AvgHLC");
var fp3 = new FunctionParameter("bExp", FunctionParameter.BOOLEAN);
fp3.setName("Exponential");
fp3.setDefault(true);
var fp4 = new FunctionParameter("cBands", FunctionParameter.COLOR);
fp4.setName("Bands Color");
fp4.setDefault(Color.blue);
var fp5 = new FunctionParameter("nBandThick", FunctionParameter.NUMBER);
fp5.setName("Bands Thickness");
fp5.setLowerLimit(1);
fp5.setDefault(1);
var fp6 = new FunctionParameter("nMult", FunctionParameter.NUMBER);
fp6.setName("Bands Multiplier");
fp6.setLowerLimit(0);
fp6.setDefault(1.3);
var fp7 = new FunctionParameter("cBasis", FunctionParameter.COLOR);
fp7.setName("Basis Color");
fp7.setDefault(Color.red);
var fp8 = new FunctionParameter("nBasisThick", FunctionParameter.NUMBER);
fp8.setName("Basis Thickness");
fp8.setLowerLimit(1);
fp8.setDefault(1);
var fp9 = new FunctionParameter("bDisplay", FunctionParameter.BOOLEAN);
fp9.setName("Display Basis Line");
fp9.setDefault(true);
}
var bInit = false;
var xKeltner = null;
function main(nLength, Source, bExp, cBands, nBandThick, nMult, cBasis, nBasisThick, bDisplay) {
if (bInit == false) {
xKeltner = efsInternal("calcKeltner", nLength, Source, bExp, nMult);
setStudyTitle("QCharts Keltner ("+ nLength + ", " + Source + ", " + bExp + ", " + nMult + ")");
setDefaultBarFgColor(cBands, 0);
setDefaultBarFgColor(cBasis, 1);
setDefaultBarFgColor(cBands, 2);
setDefaultBarThickness(nBandThick, 0);
setDefaultBarThickness(nBasisThick, 1);
setDefaultBarThickness(nBandThick, 2);
bInit = true;
}
var nUpper = getSeries(xKeltner, 0);
var nBasis = getSeries(xKeltner, 1);
var nLower = getSeries(xKeltner, 2);
if (bDisplay == false) nBasis = nBasis.toFixed(2);
return new Array(nUpper, nBasis, nLower);
}
var xSource = null;
var xBasis = null;
var xBands = null;
var xBandSrc = null;
function calcKeltner(nLen, src, b, n) {
var nU, nB, nL, nAvgR
if (xSource == null) {
switch (src) {
case "Open":
xSource = open();
break;
case "High":
xSource = high();
break;
case "Low":
xSource = low();
break;
case "Close":
xSource = close();
break;
case "AvgHL":
xSource = hl2();
break;
case "AvgOHLC":
xSource = ohlc4();
break;
case "AvgOC":
xSource = efsInternal("calcOC");
break;
default:
xSource = hlc3();
}
}
if (xBasis == null) {
xBandSrc = efsInternal("calcAvgRange");
if (b) {
xBasis = ema(nLen, xSource);
xBands = ema(nLen, xBandSrc);
} else {
xBasis = sma(nLen, xSource);
xBands = sma(nLen, xBandSrc);
}
}
nAvgR = xBands.getValue(0);
nB = xBasis.getValue(0);
if (nB == null || nAvgR == null) return;
nU = nB + (n * nAvgR);
nL = nB - (n * nAvgR);
return new Array(nU, nB, nL);
}
function calcOC() {
return (open(0) + close(0)) / 2;
}
function calcAvgRange() {
return (high(0) - low(0));
}