Announcement

Collapse
No announcement yet.

How to set multiple chart background colors?

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

  • How to set multiple chart background colors?

    I'd like to set the chart background color different for different price ranges. For example, I'd like 1290-1295 to be blue, 1296-1300 to be yellow, ... I'm using setDefaultBarBgColor with its yMin and yMax parameters, one for each price range. However, it seems that only the last setDefaultBarBgColor sticks. What am I doing wrong?

  • #2
    almerger
    In order to use multiple background colors on the same bar you need to have more than one item in the return statement so as to assign each background color to a different seriesIndex. The elements of the return array can also be strings (which will not plot on the chart)
    Alex

    Comment


    • #3
      I'm trying this in main():

      var mkt = close(0);
      setDefaultBarBgColor(Color.blue,0,mkt+5,mkt+10);
      setDefaultBarBgColor(Color.red,1,mkt-10,mkt-4);
      setDefaultBarBgColor(Color.yellow,2,mkt-4,mkt+4);
      return ("A","B","C");

      but only the blue portion is painting. Do you know why? Thanks.

      Comment


      • #4
        almerger
        That is because you are not returning an array.
        Replace return ("A","B","C") with return new Array ("A","B","C") and it will work
        Alex

        Comment


        • #5
          That did it, thanks!

          Comment

          Working...
          X