Announcement

Collapse
No announcement yet.

Problem using setBarFgColor

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

  • Problem using setBarFgColor

    I have the following lines in the top of my script:
    var dailyClose;
    var dailyCloseSym;
    var delta;

    Inside main, I init one of them:
    dailyCloseSym = close(sym("INTC, D"));

    Then inside my main routine, I have:

    dailyClose = dailyCloseSym.getValue(-1);
    delta = close(0) - dailyClose;

    if (delta > 0)
    setBar(Bar.FgColor, 0, 3, Color.green);
    else if (delta < 0)
    setBar(Bar.FgColor, 0, 3, Color.red);
    else
    setBar(Bar.FgColor, 0, 3, Color.blue);


    And then main returns delta as the 4th item in the Array.

    When I use -1 as the 2nd param to setBar, the cursor window looks fine with the right coloring for delta except everything is offset by one to the left, meaning it precolors the cursor item one bar ahead of where it should.

    But then if I use 0 as the bar index, the color in the cursor window stays as blue. It never changes even though delta is positive and negative as shown in the cursor window.

    Why is this happening? I think I should be using zero bar index but nothing happens if I use that.

    My intention is to display whether the current bar's price value is greater or less than yesterdays close.

  • #2
    crazytiger
    setBar() is used only to modify the properties of prior bars. To color the current bar you need to use setBarFgColor()
    Alex

    Comment


    • #3
      Thanks. I will try that. I was using setBar because I had to use it for going back upon a stochastic line and recoloring it based upon a discovered inflection point in the STO value.

      I assumed I will have to do the same for plotting a comparison of current bar value to yesterday's close. I will see if using setBarFgColor() does the job.

      Comment


      • #4
        I see a problem here. I am returning 4 values from main so I need to color only the third return value a certain way. It looks like setBarFgColor only takes a color parameter but you can specify a series index if you use setBar. Is there a way around this?

        Comment


        • #5
          crazytiger
          You may want to review the syntax for setBarFgColor() at the link I provided earlier
          Alex

          Originally posted by crazytiger
          I see a problem here. I am returning 4 values from main so I need to color only the third return value a certain way. It looks like setBarFgColor only takes a color parameter but you can specify a series index if you use setBar. Is there a way around this?

          Comment


          • #6
            Oops. I didn't notice that second parameter.
            If you type it into the editor, the editor hint only shows the first parameter.

            Thanks

            Comment

            Working...
            X