Page 1 of 1

Unable to add datapoints to scVolume series when scCandle

Posted: Fri Feb 20, 2009 11:50 am
by 15052496
Hi,

Am wanting to add a candle series, and a volume series. Can add either series on their own, but when try to do both at same time the candlesticks all appear in one single column on the Right hand side.

In the example below try using either the example data for candle or volume and it is fine. But try using both and chart does not align the x axis points but stacks all candles in one vertical bar, and all volume line(bars) ina vertical pile.

Code: Select all

	'Candle series
	pgChart1.AddSeries(11)	'11 = scCandle
	pgChart1.Series(0).VerticalAxis = 0 'aLeftAxis '0
	pgChart1.Axis.Left.StartPosition = 0
   	pgChart1.Axis.Left.EndPosition = 60	'percentage
   	pgChart1.Axis.Left.Labels.ValueFormat = svbFormat

	
	'Volume series
	pgChart1.AddSeries(14)		'14 = scVolume
	pgChart1.Series(1).asVolume.UseYOrigin = False
	pgChart1.Series(1).VerticalAxisCustom = pgChart1.Axis.AddCustom(False)
	pgChart1.Axis.Custom(0).StartPosition = 60
	pgChart1.Axis.Custom(0).EndPosition = 100
	pgChart1.Axis.Custom(0).Title.Caption = "Volume"
	pgChart1.Axis.Custom(0).Title.Angle = 90

	'Example Volume values		
	pgChart1.Series(1).AddXY 0, 20,"", vbBlue
	pgChart1.Series(1).AddXY 1, 10,"", vbBlue
	pgChart1.Series(1).AddXY 2, 30,"", vbBlue

	'Example OHLC candle values	
	pgChart1.Series(0).asCandle.AddCandle DateValue("1997-11-02"), 120, 135, 112, 115
	pgChart1.Series(0).asCandle.AddCandle DateValue("1997-11-03"), 215, 224, 202, 221
	pgChart1.Series(0).asCandle.AddCandle DateValue("1997-11-04"), 235, 244, 232, 241
Please advise correct way to have candle and volume on one chart, in particular the correct way to add data to both series

Thanks
p.s. The documentation is shockingly poor. Doing a function reference dump is not adequate addition to the *tutorial*. Docs need alot of work.

Posted: Fri Feb 20, 2009 12:24 pm
by yeray
Hi user,

The problem is that you are adding 3 points with low x values (0, 1 and 2) and then three more with high x values (dates).

Adding points with a date as x, you are forcing the bottom axis to set a scale in datetimes. And the values you enter as 0, 1 and 2 correspond to the dates 30/12/1899, 31/12/1899 and 01/01/1900. So that's why the chart shows three points superposed at the left and the other three at the right. If you zoom you chart you'll the points.

To correct this, you could add your volume series with the same datetimes as x:

Code: Select all

   'Example Volume values
   TChart1.Series(1).AddXY DateValue("1997-11-02"), 20, "", vbBlue
   TChart1.Series(1).AddXY DateValue("1997-11-03"), 10, "", vbBlue
   TChart1.Series(1).AddXY DateValue("1997-11-04"), 30, "", vbBlue
Yes, the documentation is an aspect that we will try to improve for future versions.

Great - works.

Posted: Fri Feb 20, 2009 2:42 pm
by 15052496
Hi Yeray,

Thank you for your fast reply. :-) That works. Obvious now that you state it. I should have guessed that the lookup to the additional Volume series was the same lookup field I had used earlier.

What was I thinking ?? trying to use a datetime string in the candles and then an index lookup in the volume. Thanks for pointing out the obvious and making it work.

Fast reply was almost as good as a user guide!

thanks again.

p.s. you wouldn't happen to have a half dozen lines of sample to add MACD series?

Posted: Fri Feb 20, 2009 4:12 pm
by yeray
Hi user,

Well here there is a MACD example.

And you can also take a look at the Tutorial 7 - Working with Functions.

But if you still find problems with it, don't hesitate to ask about it here.