How would I go about modifying/adding code to displace an indicator forward by one or more bars? For example, below is part of the code for the Keltner channel efs. What changes would be required?
function main(nInputLength, nConst) {
if(nInputLength == null)
nInputLength = 20;
if(nInputLength <= 0)
nInputLength = 20;
var Factor = 2.5;
if (nConst != null) Factor = nConst;
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[i] + vLow[i] + vClose[i]) / 3;
vHminL += vHigh[i] - vLow[i];
}
vHLC3 /= nInputLength;
vHminL /= nInputLength;
vHminL *= Factor;
return new Array(vHLC3 + vHminL, vHLC3, vHLC3 - vHminL);
}
function main(nInputLength, nConst) {
if(nInputLength == null)
nInputLength = 20;
if(nInputLength <= 0)
nInputLength = 20;
var Factor = 2.5;
if (nConst != null) Factor = nConst;
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[i] + vLow[i] + vClose[i]) / 3;
vHminL += vHigh[i] - vLow[i];
}
vHLC3 /= nInputLength;
vHminL /= nInputLength;
vHminL *= Factor;
return new Array(vHLC3 + vHminL, vHLC3, vHLC3 - vHminL);
}
Comment