I would like to have the color of a study bar be a specific color when it passes thru a certain value. For example, if the PercentR passes from below -50 to above -50, I would like that specific bar to be lime. I can get the next bar to be lime but not that bar. It seems that you can only control the next bar color as in the below example.
function preMain() {
setStudyTitle("%R Color Line");
setCursorLabelName("%R", 0);
var fp1 = new FunctionParameter("nInputLength", FunctionParameter.NUMBER);
fp1.setName("RSI Length");
fp1.setLowerLimit(1);
fp1.setDefault(14);
}
var vValue = null;
function main(nInputLength) {
if (vValue == null) {
vValue = efsExternal("/library/WilliamsPercentR.efs", nInputLength);
}
if(vValue.getValue(-1) < -50 && vValue.getValue(0) > -50) {
setBarThickness(2);
setBarFgColor(Color.lime);
} else {
setBarThickness(2);
setBarFgColor(Color.red);
}
return (vValue.getValue(0));
function preMain() {
setStudyTitle("%R Color Line");
setCursorLabelName("%R", 0);
var fp1 = new FunctionParameter("nInputLength", FunctionParameter.NUMBER);
fp1.setName("RSI Length");
fp1.setLowerLimit(1);
fp1.setDefault(14);
}
var vValue = null;
function main(nInputLength) {
if (vValue == null) {
vValue = efsExternal("/library/WilliamsPercentR.efs", nInputLength);
}
if(vValue.getValue(-1) < -50 && vValue.getValue(0) > -50) {
setBarThickness(2);
setBarFgColor(Color.lime);
} else {
setBarThickness(2);
setBarFgColor(Color.red);
}
return (vValue.getValue(0));
Comment