Page 1 of 1

Change individual candle bar color

Posted: Thu Jul 24, 2008 7:15 pm
by 9083183
I've been using V6 AX with VB 6 for a few years and I'd like to be able to change the color of individual candles in the midst of a series and not default to the up and down close colors.

The way I did it before was to create a second series with different colors and overlay the specific candles in the original series to give the effect of mixed colors.

This seems a bit awkward but it looks OK. Can I specify new colors (or other attributes like border width or color) per candle in V7 or 8? Is there a better way to do this?

Thanks, David

Posted: Mon Jul 28, 2008 8:21 am
by yeray
Hi David,

I've tried what you say, and I've been able to set open-close colors, up-down color and even border width and color with TeeChart AX v6.0.1.1. These are customizations for the whole series and not for individual candles, but you can use OnGetPointerStyle event to apply each setup to different points. Something as follows:

Code: Select all

Private Sub TChart1_OnGetSeriesPointerStyle(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, AStyle As TeeChart.EPointerStyle)
  If SeriesIndex = 0 Then
    With TChart1.Series(0).asCandle
      Select Case ValueIndex
        Case 0, 2, 4, 8:
          .DownCloseColor = RGB(255, 200, 100)
          .UpCloseColor = RGB(100, 100, 100)
          .Pointer.Pen.Color = vbRed
          .Pointer.Pen.Width = 2
          .CandleWidth = 7
        Case Else:
          .DownCloseColor = vbRed
          .UpCloseColor = vbWhite
          .Pointer.Pen.Color = vbBlack
          .Pointer.Pen.Width = 1
          .CandleWidth = 4
      End Select
    End With
  End If
End Sub
And with v8, you could change High-Low pen color or you could draw a gradient for up-down values:

Code: Select all

.HighLowPen.Color = vbGreen
.UpCloseGradient.Visible = True 'and other gradient properties, such as direction, colors, balance,...
.DownCloseGradient.Visible = True