Jump to content
Software FX Community

HiLowClose chart


rafael_reimer

Recommended Posts

Here is a sample code:

'

'Populating the Chart from database

Dim mySelectQuery as String

mySelectQuery = "SELECT Date,High,Low,Closed From SampleFinancial2"

Dim myConnectionString as String

myConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + (App.Path) + "\ChartfxSamples.mdb;"

Dim myConnection as New ADODB.Connection

Set myConnection=New ADODB.Connection

myConnection.Open(myConnectionString)

Dim adapter as Object

Dim rs

Set rs = myConnection.Execute(mySelectQuery)

'Setting Chart Series

Chart1.DataType.Item(0) = DataType_Label

Chart1.DataType.Item(1) = DataType_Value

Chart1.DataType.Item(2) = DataType_Value

Chart1.DataType.Item(3) = DataType_Value

Chart1.AxisX.LabelsFormat.Format = AxisFormat_Date

Chart1.DataSource = rs

'

Chart1.Gallery = Gallery_HiLowClose

Chart1.Series(2).Color = RGB(0,0,128)

Chart1.AxisY.Min = 50

As for the data, the first column contains dates (DataType.Item(0) set to DataType_Label) and the other three columns contain the data that is plotted by the open-high-low chart. You can find more information in the Samples and Resource Center (under Gallery Types --> Financial). Here is a sample of the data:

SampleFinancial2

Date

High

Low

Closed

4/2/2001

54.63

55.81

56.94

4/3/2001

52.75

53.38

55.31

4/4/2001

51.06

51.94

55

4/5/2001

53.5

56.75

57.38

4/6/2001

55.06

56.19

57.19

4/9/2001

55.66

57.15

57.42

4/10/2001

57.78

59.68

60.09

Link to comment
Share on other sites

Ok, this example I saw in the Samples and Resource Center, but I need an example of setting the chart value propertie.

 Like this examle:

Chart1.Gallery = Gallery_Bar

'Populating the Chart1 with random data to get 3 series

Dim j as Integer

j = 0

Dim i as Integer

i = 0

Chart1.OpenData COD_Values, 3, 3

For i = 0 To 2

For j = 0 To 2

Chart1.Value(i, j) = (Rnd()) * 100

Next

Next

Chart1.CloseData COD_Values

Thanks,

Rafael.

Link to comment
Share on other sites

Basically, the sample code you provided will do it; just change the gallery to HighLowClose but for your convenience, I am posting my own sample below:

 Chart1.Gallery = Gallery_HiLowClose

Chart1.OpenData COD_Values, 3, 10

Dim j As Integer

j = 0

For j = 0 To 9

  Chart1.Value(0, j) = (Rnd()) * 50

Next

For j = 0 To 9

  Chart1.Value(1, j) = ((((Rnd()) * 80)) + 50)

Next

For j = 0 To 9

  Chart1.Value(2, j) = ((((Rnd()) * 100)) + 100)

Next

Chart1.CloseData COD_Values

 What you need to keep in mind is that you always need to pass three series to the chart (hence, High Low Close).

Link to comment
Share on other sites

In the OpenData() call you are specifying three series with two data points each, so having this:

Chart1.Value(0, 1) = 4000

Chart1.Value(0, 2) = 1500

Chart1.Value(0, 3) = 2500

Chart1.Value(0, 1) = 5000

Chart1.Value(0, 2) = 2250

Chart1.Value(0, 3) = 3250

is wrong. The first index indicates the series while the second index indicates the point belonging to that series. I tried the following and the chart showed as expected:

Chart1.OpenData COD_Values, 3, 2

Chart1.Value(0, 0) = 4000

Chart1.Value(0, 1) = 1500

Chart1.Value(1, 0) = 2500

Chart1.Value(1, 1) = 5000

Chart1.Value(2, 0) = 2250

Chart1.Value(2, 1) = 3250

Chart1.CloseData COD_Values

What is the problem that you are having? Are you receiving any errors? If so, provide me with a screenshot.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...