Announcement

Collapse
No announcement yet.

Adx

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

  • Adx

    Hi, i have a code, that draws the ADX in several mybgcolour: Red above 30, lime between 30-40 and below 30
    I would like, that the ADX isn t drawn, if it`S below 30. Do you know, how to change the "else if"?
    Regards



    function preMain() {

    setPriceStudy(true);
    setStudyTitle("ADX5");




    }






    var bFlash = true;

    var myColor = Color.white;

    var mybgColor = Color.green;



    function main() {

    var myValue = ((adx(14,14)).toFixed(0));

    mybgColor = Color.white;



    if (bFlash == false) {

    if (myValue>=30) {

    //myColor = Color.black;

    mybgColor = Color.red;



    } else if (myValue>30 && myValue <= 40) {

    //myColor = Color.gray;

    mybgColor = Color.lime;

    } else if (myValue<30) {

    //myColor = Color.white;

    mybgColor = Color.navy;


    }

    bFlash = true;

    } else if (bFlash == true) {

    bFlash = false;

    }





    drawTextRelative(0, BelowBar4, myValue , Color.lightgrey, mybgColor, Text.LEFT | Text.BOLD, null, 10, "text" );



    return;




    }

  • #2
    Re: Adx

    Bugeleisen
    Enclose the drawTextRelative() command in a conditional statement that checks if myValue is greater than 30 eg.
    PHP Code:
    if(myValue>30){
        
    drawTextRelative(0, , , , "text");

    If when myValue is 30 or less you also want to remove the text that would remain on the chart at the last bar in which that condition was true then modify the conditional statement to the following
    PHP Code:
    if(myValue>30){
        
    drawTextRelative(0, , , , "text");
    }else{
        
    removeText("text");

    Also you are missing a Text.PRESET flag in the drawTextRelative() command which is required when using the location flag such as AboveBar1, BelowBar2, etc
    Alex


    Originally posted by Bügeleisen
    Hi, i have a code, that draws the ADX in several mybgcolour: Red above 30, lime between 30-40 and below 30
    I would like, that the ADX isn t drawn, if it`S below 30. Do you know, how to change the "else if"?
    Regards



    function preMain() {

    setPriceStudy(true);
    setStudyTitle("ADX5");




    }






    var bFlash = true;

    var myColor = Color.white;

    var mybgColor = Color.green;



    function main() {

    var myValue = ((adx(14,14)).toFixed(0));

    mybgColor = Color.white;



    if (bFlash == false) {

    if (myValue>=30) {

    //myColor = Color.black;

    mybgColor = Color.red;



    } else if (myValue>30 && myValue <= 40) {

    //myColor = Color.gray;

    mybgColor = Color.lime;

    } else if (myValue<30) {

    //myColor = Color.white;

    mybgColor = Color.navy;


    }

    bFlash = true;

    } else if (bFlash == true) {

    bFlash = false;

    }





    drawTextRelative(0, BelowBar4, myValue , Color.lightgrey, mybgColor, Text.LEFT | Text.BOLD, null, 10, "text" );



    return;




    }

    Comment

    Working...
    X