Announcement

Collapse
No announcement yet.

Color of line

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

  • Color of line

    I am using this study, but would like to do some improvements. Is it possible to change the color of the 50 line based on the price. F.ex. when price is above a 50 EMA, i would like the color to change to green, and when price is below, change to red.
    Can anyone please help me whit this
    finhan.
    Attached Files

  • #2
    finnhan
    To do what you are trying to accomplish you need to first declare the EMA study where you have declared all your other studies
    PHP Code:
    var vSMA50 = new MAStudy(500"Close"MAStudy.EXPONENTIAL); 
    Then inside the main function add the following section of code just before the return statement
    PHP Code:
    if(close(0) > vSMA50.getValue(MAStudy.MA))
            
    setBarFgColor(Color.lime5);
        else if(
    close(0) < vSMA50.getValue(MAStudy.MA))
            
    setBarFgColor(Color.red5);
        else 
            
    setBarFgColor(Color.yellow5); 
    The color is assigned to the appropriate plot by the series index parameter ie the number that is in the setBarFgColor() command (see the link to the EFS KnowledgeBase for the description and syntax).
    Alex

    Comment


    • #3
      Thank you Alex

      Thank you very much for your help

      Comment


      • #4
        finnhan
        You are most welcome
        Alex

        Comment

        Working...
        X