Quinn-Curtis Forums
Quinn-Curtis Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Tools for Java
 QCChart2D for Java
 Dynamic update of time and OHLC data

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
ilhany Posted - 01 Jan 2014 : 10:17:35
Hello,

based on the example code in FinCandlestickPlot.java, I try to write a chart application. I want to dynamically update the time data and OHLC Data, keeping the number of candlesticks constant.

I tried this:

		
		for(int i=0; i<nNumPnts; i++)
		{
			xValues[i].setTime(new Date(Times.get(i)));
			stockPriceData[0][i] = O.get(i); //o
			stockPriceData[1][i] = H.get(i); //h
			stockPriceData[2][i] = L.get(i); //l
			stockPriceData[3][i] = C.get(i); //c
		}
		Dataset1.setTimeXData(xValues);
		Dataset1.setGroupData(stockPriceData);
		pTransform1.autoScale(Dataset1,ChartConstants.AUTOAXES_FAR,  ChartConstants.AUTOAXES_FAR);
		xAxis1.calcAutoAxis();
		yAxis1.calcAutoAxis();
		updateDraw();
		repaint();


While the axis boundaries are calculated correctly, the chart looks very weird. I narrowed the problem to "Dataset1.setTimeXData(xValues);", if I comment this out, the chart looks ok, beside that the time axis is not correct. Please give me a hint.

Thank you,
Ilhan
6   L A T E S T    R E P L I E S    (Newest First)
ilhany Posted - 01 Jan 2014 : 18:38:30
That was the solution.

Thank you.
quinncurtis Posted - 01 Jan 2014 : 16:10:40
The times look OK. But with a separation of 10 seconds, I would guess that you are specifying an incorrect width parameter for the CandlestickPlot, or OHLCPLot object. For data spaced 10 seconds apart you should be using a 5 second width, calculated using the ChartCalendar.getCalendarWidthValue utility method.

CandlestickPlot thePlot2 = new CandlestickPlot(pTransform1, Dataset1, ChartCalendar.getCalendarWidthValue(Calendar.SECOND,5),  defaultattrib, fillattrib);



What value or expression are you using to set the width value? If you change the data so that the data points are much closer together, you must also change the width value.

thePlot2.setBarWidth(ChartCalendar.getCalendarWidthValue(Calendar.SECOND,5));


ilhany Posted - 01 Jan 2014 : 15:37:47
Times is of type LongBuffer. I made some debug strings.

SimpleDateFormat df = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss.SSS");
Date newDate = new Date(Times.get(i));
xValues[i].setTime(newDate);
...
textArea.append(df.format(xValues[i].getTime())+", o: " + sO+", h: " + sH+", l: " + sL+", c: " + sC + "\n");


result:

2007.03.30 16:00:00.000, o: 1.33757, h: 1.33757, l: 1.33757, c: 1.33757
2007.03.30 16:00:10.000, o: 1.33787, h: 1.33787, l: 1.33787, c: 1.33787
2007.03.30 16:00:20.000, o: 1.33786, h: 1.33786, l: 1.33786, c: 1.33786
2007.03.30 16:00:30.000, o: 1.33751, h: 1.33751, l: 1.33723, c: 1.33723
2007.03.30 16:00:40.000, o: 1.3372, h: 1.3372, l: 1.3372, c: 1.3372
2007.03.30 16:00:50.000, o: 1.33716, h: 1.33716, l: 1.33716, c: 1.33716
2007.03.30 16:01:10.000, o: 1.3374, h: 1.3374, l: 1.3374, c: 1.3374
2007.03.30 16:01:20.000, o: 1.3374, h: 1.3376, l: 1.3374, c: 1.3375
2007.03.30 16:01:30.000, o: 1.3375, h: 1.3375, l: 1.33715, c: 1.33725
2007.03.30 16:01:40.000, o: 1.3373, h: 1.33745, l: 1.3372, c: 1.33745
2007.03.30 16:01:50.000, o: 1.3375, h: 1.3376, l: 1.33745, c: 1.3375
2007.03.30 16:02:00.000, o: 1.3375, h: 1.3376, l: 1.33745, c: 1.3375
...


The output is what I expected because my tick data stored in a file starts at 2007.03.30, 16:00.
quinncurtis Posted - 01 Jan 2014 : 14:38:34
It looks like your dates are invalid. Something is going wrong in the conversion you identify:

xValues[i].setTime(new Date(Times.get(i)));


break it into two steps:

Date newdate = new Date(Times.get(i));
     xValues[i].setTime(newdate);


and look at the values of newdate using the debugger. See that it is a proper date, in the current era (i.e. > 1971).

What type of object, or value, is returned by Times.get(i) ?
ilhany Posted - 01 Jan 2014 : 12:48:26
Chart ok, wrong time data (setTimeXData commented out):

http://s7.directupload.net/file/d/3489/bfmzq8or_png.htm

Chart weird:

http://s1.directupload.net/file/d/3489/wahcde6i_png.htm

quinncurtis Posted - 01 Jan 2014 : 10:23:22
We don't know what your chart looks like. Try and include a picture in your post. You can do that uploading it to some server (a free picture posting site will work, or your own company server) and use the Insert Image icon. If you can't do that, send us the picture in an e-mail to support@quinn-curtis.com.


Quinn-Curtis Forums © 2000-07 Quinn-Curtis, Inc. Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07