Originally posted by PKJR
Here is the chart from ESignal- clearly it is not the same not mentioning that you CANNOT adjust factor like 1.5, 2 or etc.
A
Here is one I modified that you can adjust:
function preMain() {
setPriceStudy(true);
/* Set the title that will appear in the study pane */
setStudyTitle("KeltnerM");
/* 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.cyan, 1); // basis
setDefaultBarFgColor(Color.blue, 2); // lower
}
function main(nInputLength, nMult) {
if(nInputLength == null)
nInputLength = 20;
if(nInputLength <= 0)
nInputLength = 20;
if(nMult ==null)
nMult = 1;
var vHigh = getValue("High", 0, -nInputLength);
var vLow = getValue("Low", 0, -nInputLength);
var vClose = getValue("Close", 0, -nInputLength);
if(vHigh == null || vLow == null || vClose == null)
return;
var vHLC3 = 0;
var vHminL = 0;
var i;
for(i = 0; i < nInputLength; i++) {
vHLC3 += (vHigh
+ vLow + vClose) / 3;
vHminL += (vHigh - vLow)*nMult;
}
vHLC3 /= nInputLength;
vHminL /= nInputLength;
return new Array(vHLC3 + vHminL, vHLC3 - vHminL);
}