Announcement

Collapse
No announcement yet.

setBarBgColor Alignment

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

  • setBarBgColor Alignment

    Hello,
    I have a question about how setBarBgColor does its alignment, and what the significance of the series index # i apply to a setBarBgColor has?



    Do you see how the background color is shifted from my squarewave line? I have tried all sorts of combinations as to which series I attatch a bg color to.

    For example, when I want to set the bgcolor between Point A on Squarewave @ Top and Point B on Squarewave @ Bottom, which series would I use as the index for the bg? the top value or bottom value?

    I have yet to find an arrangement that will aling the bg's properly.

    Thanks.

  • #2
    Im asking you guys, what makes the white background align to the center of the returned value, and the red/green background **** to the right, where the center of the bar is the left side of the background ..

    I can swith the setBg Index #, color,INDEX, between the 2 and the red then is centered and the white is shifted.

    I am so confused by this behaviour.

    Please help me.

    Comment


    • #3
      Hello madmike117,

      The issue you're dealing with has to do with the plot type assigned to the return index. The line and instantcolorline plot types color the background from the middle of the bars rather then the space between two bars.

      You can set the plot type for the return index you're using for the background coloring to any of the other plot types.

      If you need the particular return index to be a line plot type, then the other work-around you can use is to add another return element to the return array that returns and empty string or null values. Then set the plot type for this return index to squarewave and use that return index for setBarBgColor(). Here's a basic example.

      PHP Code:

      function preMain() {
          
      setPriceStudy(true);
          
      setShowCursorLabel(false);
          
      setShowTitleParametersfalse );
          
      setStudyTitle("test");
          
      setDefaultBarThickness(20);
          
      setDefaultBarThickness(21);
          
      setDefaultBarFgColor(Color.magenta0);
          
      setDefaultBarFgColor(Color.magenta1);
          
      setPlotType(PLOTTYPE_SQUAREWAVE2);
      }


      var 
      x1 null;
      var 
      x2 null;
      var 
      bInit false;

      function 
      main() {

          if (
      bInit == false) {
              
      x1 upperEnv(20true10);
              
      x2 lowerEnv(20true10);
              
      bInit true;
          }

          var 
      n1 x1.getValue(0);
          var 
      n2 x2.getValue(0);
          if (
      n1 == null || n2 == null) return;
          
          
      setBarBgColor(Color.grey2n2n1);
          
          return new Array(
      n1n2"");

      Jason K.
      Project Manager
      eSignal - an Interactive Data company

      EFS KnowledgeBase
      JavaScript for EFS Video Series
      EFS Beginner Tutorial Series
      EFS Glossary
      Custom EFS Development Policy

      New User Orientation

      Comment

      Working...
      X