I was trying to get this bit of code to color.
I do not understand why it is not.
Currently it just plots in blue.
Not even the default.
What am I doing wrong?
Thanks!
Carson
--------------------------------------------------------------------
function main(Length) {
if(Length == null) Length = 25;
var sum = 0;
//var LR = 0;//removed as this is now a global variable
//begin array section
if(myArray==null) myArray = new Array(3);//set the length of the array (we only need to go back 2 bars)
if(getBarState()==BARSTATE_NEWBAR){//if a new bar is created
myArray.pop();//remove the oldest element of the array
myArray.unshift(LR);//add the last computed value of LR to the array
}
//end array section
for(var i = Length; i > 0; i--){
sum += (i - (Length + 1) / 3) * close(i - Length);
}
LR = 6 / (Length * (Length + 1)) * sum;
myArray[0] = LR;//assign current value of LR to the first element of the array
//begin section to color the plot using array
if(myArray[0]>myArray[1]&&myArray[1]>myArray[2]) setBarFgColor(Color.lime);
if(myArray[0]<myArray[1]&&myArray[1]<myArray[2])setBarFgColor(Color.red);
setDefaultBarFgColor( Color.darkgrey);
//end section to color the plot
return LR;
}
I do not understand why it is not.
Currently it just plots in blue.
Not even the default.
What am I doing wrong?
Thanks!
Carson
--------------------------------------------------------------------
function main(Length) {
if(Length == null) Length = 25;
var sum = 0;
//var LR = 0;//removed as this is now a global variable
//begin array section
if(myArray==null) myArray = new Array(3);//set the length of the array (we only need to go back 2 bars)
if(getBarState()==BARSTATE_NEWBAR){//if a new bar is created
myArray.pop();//remove the oldest element of the array
myArray.unshift(LR);//add the last computed value of LR to the array
}
//end array section
for(var i = Length; i > 0; i--){
sum += (i - (Length + 1) / 3) * close(i - Length);
}
LR = 6 / (Length * (Length + 1)) * sum;
myArray[0] = LR;//assign current value of LR to the first element of the array
//begin section to color the plot using array
if(myArray[0]>myArray[1]&&myArray[1]>myArray[2]) setBarFgColor(Color.lime);
if(myArray[0]<myArray[1]&&myArray[1]<myArray[2])setBarFgColor(Color.red);
setDefaultBarFgColor( Color.darkgrey);
//end section to color the plot
return LR;
}
Comment