Can someone help me add the lines necessary so that i can have the flexibility to adjust the colors of both the 'atr bands' & 'basis' independently. Currently i can override the color but it makes all 3 lines the same color. I would like to be able to bring up the color palette for each line.
Thanks
scott
Heres the current code:
function preMain() {
setPriceStudy(true);
setStudyTitle("Keltner (ATR Bands) ");
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 ATR(nInputLength) {
var dSum = 0;
var dH = high(0, -nInputLength);
var dL = low(0, -nInputLength);
var dC = close(-1, -nInputLength);
if (dH == null || dL == null || dC == null) {
return;
}
for (i = 0; i < nInputLength; ++i) {
var vTrueHigh = Math.max(dH[i], dC[i]);
var vTrueLow = Math.min(dL[i], dC[i]);
var vTrueRange = (vTrueHigh - vTrueLow);
dSum += vTrueRange;
}
dSum /= nInputLength;
return dSum;
}
var BarCntr = 0;
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;
if (getBarState() == BARSTATE_NEWBAR)
BarCntr += 1;
if (BarCntr < nInputLength) {
return;
} else {
var dKeltnerBasis= call("/Library/KeltnerEMA.efs", nInputLength);
var dATR = ATR(nInputLength);
return new Array(dKeltnerBasis + (nRangeFactor * dATR), dKeltnerBasis, dKeltnerBasis - (nRangeFactor * dATR));
}
}
Thanks
scott
Heres the current code:
function preMain() {
setPriceStudy(true);
setStudyTitle("Keltner (ATR Bands) ");
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 ATR(nInputLength) {
var dSum = 0;
var dH = high(0, -nInputLength);
var dL = low(0, -nInputLength);
var dC = close(-1, -nInputLength);
if (dH == null || dL == null || dC == null) {
return;
}
for (i = 0; i < nInputLength; ++i) {
var vTrueHigh = Math.max(dH[i], dC[i]);
var vTrueLow = Math.min(dL[i], dC[i]);
var vTrueRange = (vTrueHigh - vTrueLow);
dSum += vTrueRange;
}
dSum /= nInputLength;
return dSum;
}
var BarCntr = 0;
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;
if (getBarState() == BARSTATE_NEWBAR)
BarCntr += 1;
if (BarCntr < nInputLength) {
return;
} else {
var dKeltnerBasis= call("/Library/KeltnerEMA.efs", nInputLength);
var dATR = ATR(nInputLength);
return new Array(dKeltnerBasis + (nRangeFactor * dATR), dKeltnerBasis, dKeltnerBasis - (nRangeFactor * dATR));
}
}
Comment