Announcement

Collapse
No announcement yet.

Indicator background color?

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

  • Indicator background color?

    I would like to be able to change the entire background color in an indicator, present as well as past values. Essentially a cross between setChartBG & setBarBgColor. The former colors the entire chart, when I only want the indicator, & the later only colors the last bar, while I would like the whole indicator to be colored. How to do this?

    Thank you,
    Greg

  • #2
    try this for starters..

    right click on an Adv Chart.
    click on Formulas
    click on Helpers
    click on MADCColor.efs

    this is a good example to show you how to color the background of an indicator.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Try using a loop in conjunction with SetBar(). The following two lines reset the bar background colors of the previous 100 bars when either condition is met.

      if(Vshort > Vlong) {for (var i=0; i<100; i++){setBar(Bar.BgColor,-i,Color.green) }}

      if(Vshort < Vlong) {for (var i=0; i<100; i++){setBar(Bar.BgColor,-i,Color.red) }}


      Mike

      Comment


      • #4
        setDefaultBarBgColor setBarBgColor

        Sometimes the simplest things get by us. Since I started using the bar background color changing ditty I suggested below I’ve been using a separate one for each chart, adjusting the 100 figure to estimated numbers of bars each chart will have at the end of the trading session since a five minute chart will have only one fifth the number of bars of a one minute chart. It just occurred to me that setting up a bar counter and sticking that in the loop is easier.

        1. Define a variable as a counter:

        var counter = 0;

        2. Within function main() { include the following line to increment the counter:

        if (getBarState() == BARSTATE_NEWBAR) {
        counter = counter +1}

        3. Then substitute the counter for the number in the loop as follows:

        if(Vshort > Vlong ) {for (i=0; i<counter; i++){setBar(Bar.BgColor,-i,Color.green) }}

        if(Vshort < Vlong ) {for (i=0; i<counter; i++){setBar(Bar.BgColor,-i,Color.red) }}


        In real time this will change the bar background color of an entire chart, including tick charts irregardless of the interval, when either condition is met.

        Mike

        Comment


        • #5
          Re: setDefaultBarBgColor setBarBgColor

          Mike
          As an alternative instead of a counter you could use the function getNumBars() or getCurrentBarCount() which will return the number of bars in a chart eg
          var NumberOfBars = getNumBars();
          if(Vshort > Vlong ) {for (var i=0; i<NumberOfBars; i++){setBar(Bar.BgColor,-i,Color.green) }}

          Alex


          Originally posted by mikejhelms
          Sometimes the simplest things get by us. Since I started using the bar background color changing ditty I suggested below I’ve been using a separate one for each chart, adjusting the 100 figure to estimated numbers of bars each chart will have at the end of the trading session since a five minute chart will have only one fifth the number of bars of a one minute chart. It just occurred to me that setting up a bar counter and sticking that in the loop is easier.

          1. Define a variable as a counter:

          var counter = 0;

          2. Within function main() { include the following line to increment the counter:

          if (getBarState() == BARSTATE_NEWBAR) {
          counter = counter +1}

          3. Then substitute the counter for the number in the loop as follows:

          if(Vshort > Vlong ) {for (i=0; i<counter; i++){setBar(Bar.BgColor,-i,Color.green) }}

          if(Vshort < Vlong ) {for (i=0; i<counter; i++){setBar(Bar.BgColor,-i,Color.red) }}


          In real time this will change the bar background color of an entire chart, including tick charts irregardless of the interval, when either condition is met.

          Mike

          Comment


          • #6
            Yeah, I missed that one too. Good suggestion. The following is pretty basic but when I started out nothing was obvious. So for the newbies even newer than me I forgot to mention that such a study only makes sense in realtime so immediately after function main() insert:

            if (getCurrentBarIndex() < 0) return;

            Mike
            Last edited by mikejhelms; 02-28-2008, 02:24 PM.

            Comment

            Working...
            X