Announcement

Collapse
No announcement yet.

the study will not color

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • the study will not color

    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;
    }

  • #2
    Re: the study will not color

    Carson
    As far as I can see it is coloring the plot (see enclosed screenshot)
    Alex




    Originally posted by arsond
    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;
    }

    Comment

    Working...
    X