Moving Average .XScreenToValue

TeeChart for ActiveX, COM and ASP
Post Reply
Rossmc
Newbie
Newbie
Posts: 27
Joined: Wed Jul 28, 2004 4:00 am
Location: South Africa

Moving Average .XScreenToValue

Post by Rossmc » Mon May 23, 2005 8:05 am

Sorry to seem lazy but I am pressed for time.
I plot a price line which has 751 points. Of which 250 are visible at any one time to user.
I add a 21 day moving average.
As user moves mouse pointer (the requirement is to be able to do this WITHOUT a cursor) I need to update a 'data window' to show the Y values at the current mouse point.
I use .Series(SeriesIndex).XScreenToValue(X) to determine the index value to pass to .YValues
This works fine for the main line, but when I use the same logic for the moving average it is out by the period (ie, 21).
As there may be many series plotted is there a way to write a generic piece of code that will return the value for the series relative to the pointer? Thanks again.

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

Post by Narcís » Mon May 23, 2005 9:44 am

Hi Rossmc,

You could use something like:

Code: Select all

Private Sub TChart1_OnMouseMove(ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
    Dim ValuesStr As String

    If TChart1.Series(0).Clicked(X, Y) <> -1 Then
        ValuesStr = "X: " + CStr(TChart1.Series(0).XValues.Value(TChart1.Series(0).Clicked(X, Y))) _
                + ", Y: " + CStr(TChart1.Series(0).YValues.Value(TChart1.Series(0).Clicked(X, Y)))
    
        TChart1.Header.Text.Clear
        TChart1.Header.Text.Add (ValuesStr)
    Else
        TChart1.Header.Text.Clear
        TChart1.Header.Text.Add ("")
    End If
End Sub
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

Post Reply