get Bollinger band values from mouse click

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

get Bollinger band values from mouse click

Post by dcurrier » Fri Dec 17, 2004 3:20 am

Series0 is a candle series.
Series1 is a Bollinger band function based on the series0 candles.

The bollinger band produces both an upper and lower band, 2 values.

I would like to click on a candle and return both the bollinger band y values.

What does the code look like to find these values based on the Y axis?

I couldn't seem to find this in a forum search. Maybe there is a example in the user group but I couldn't identify it.

Thanks for your help.

David

using V6.0.0.6 and VB6

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Dec 17, 2004 9:30 am

Hi David,

You can use something like:

Code: Select all

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim clicked As Long

  clicked = TChart1.Series(SeriesIndex).GetMousePoint
  Label3.Caption = "Point:" + Str(clicked)
  Label1.Caption = "Bolinger Band1 Y: " + Str(TChart1.Series(1).YValues.Value(clicked))
  Label2.Caption = "Bolinger Band2 Y: " + Str(TChart1.Series(2).YValues.Value(clicked))
End Sub
The obtained Bolinger Bands Y values will depend on the period you set for that series. If you want to get the Bollinger Bands Y values for the X value you clicked then you will have to obtain it using the candle X date value.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Fri Dec 17, 2004 3:09 pm

narcis wrote:Hi David,

You can use something like:

Code: Select all

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
Dim clicked As Long

  clicked = TChart1.Series(SeriesIndex).GetMousePoint
  Label3.Caption = "Point:" + Str(clicked)
  Label1.Caption = "Bolinger Band1 Y: " + Str(TChart1.Series(1).YValues.Value(clicked))
  Label2.Caption = "Bolinger Band2 Y: " + Str(TChart1.Series(2).YValues.Value(clicked))
End Sub
The obtained Bolinger Bands Y values will depend on the period you set for that series. If you want to get the Bollinger Bands Y values for the X value you clicked then you will have to obtain it using the candle X date value.
Thanks for your response.

When I use the Bollinger band function for series 1, it creates 2 bands on the chart. I'm pretty sure they are not split into 2 series as in your example. They are 2 values in series1 - the regular and the lower band.

I also don't want to use the onclickseries. I want to make this a part of my existing onmousedown event. This means I will have an X value when I push the mouse. Based on this, I would like to get the upper and lower Bollinger band Y values for that given x. These values are somehow associated with Series 1 in my example.

I'm just not sure how to access the value points.

Thanks, David

dcurrier
Newbie
Newbie
Posts: 32
Joined: Thu Jul 15, 2004 4:00 am

Post by dcurrier » Fri Dec 17, 2004 5:43 pm

I got it working once I figured out how to access the lower band.

Code: Select all

MultiChart.Series(4).FunctionType.asBollinger.LowBand.YValues.Value(ebbPtr)
ebbptr is the pointer for the Xvalue factoring in the null values at the beginning.

Thanks for your help.

David

Post Reply