Change individual candle bar color

TeeChart for ActiveX, COM and ASP
Post Reply
dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Change individual candle bar color

Post by dcurrier » Thu Jul 24, 2008 7:15 pm

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

Yeray
Site Admin
Site Admin
Posts: 9534
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Post by Yeray » Mon Jul 28, 2008 8:21 am

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply