Announcement

Collapse
No announcement yet.

line color problem

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

  • line color problem

    I am having difficulty with the color of the line as it is being painted during the current bar. I want the line to be red if it ends below a certain level and green if it ends above that level.

    I have defined the line type as:
    setPlotType(PLOTTYPE_INSTANTCOLORLINE,4)

    In the
    if (getBarState() == BARSTATE_NEWBAR){

    section of the code, I define the line color by:
    if(Stoch1<=R201 && Stoch>R20 || Stoch1<=R801 && Stoch>R80){setDefaultBarFgColor(Color.green,4)}
    if(Stoch1>=R201 && Stoch<R20 || Stoch1>=R801 && Stoch<R80){setDefaultBarFgColor(Color.red,4)}

    On the current bar, the color is sometimes misassigned, I suppose due to the end point moving back and forth across the trigger level. Reloading the indicator fixes the problem.

    How can I get the color to be assigned correctly?

  • #2
    ronblack
    Is Stoch1 the value of the Stochastic one bar ago and Stoch that of the current Stochastic?
    If so then the problem may be due to the fact that the section of code is enclosed in a BARSTATE_NEWBAR which means it would register the value of the Stochastic at the time a new bar is created rather than using the value of the bar that just closed.
    This may explain why when you reload the efs it then paints the plot correctly.
    Just an idea (assuming I even understood the issue correctly)
    Also you may want to use setBarFgColor() rather than setDefaultBarFgColor()
    Alex

    Comment

    Working...
    X