Page 1 of 1

Candlestick related Problem! Please help

Posted: Sat Mar 14, 2009 12:43 pm
by Ken1984
hello everyone, i got a project that will be due next week and i still have some problems regarding the display of the dates foe the candlestick chart. I have a .txt file while i read in all the highs, lows, open, close, volume and the respective dates. However, the code given by JFreeChart uses something like a manual input for every single day which i have already replace by my codes below:

public static OHLCDataset createDataset() {

int j = 245;
Date[] date = new Date[j];
double[] high = new double[j];
double[] low = new double[j];
double[] open = new double[j];
double[] close = new double[j];
double[] volume = new double[j];
int[] actualdate = new int[j];

int i =0;
int mnth = 9;

try {
File f = new File("data.txt");
Scanner input = new Scanner(f);

while (input.hasNextLine()) {

high = input.nextDouble();
low = input.nextDouble();
open = input.nextDouble();
close = input.nextDouble();
volume = input.nextDouble();
actualdate = input.nextInt();
date = DateUtilities.createDate(2007, mnth, 3+i, 12, 0);

i++;
}
}

catch (IOException ex) {
System.err.println(ex);
}

return new DefaultHighLowDataset("Candlestick", date, high, low, open,
close, volume);

}


As we can see from the above code, the dates add on everyday, without taking into consideration of the weekends. How is it possible to plot the candlesticks with respect to my dates? (which are stored under actualdates) Please help, any kind soul!! thanks thanks..really appreciated for any help

Re: Candlestick related Problem! Please help

Posted: Sat Mar 14, 2009 2:27 pm
by skunk
To remove the weekends you will need to call this method on the DateAxis

Code: Select all

public void setTimeline(Timeline timeline)
You will probably need (at least) this static method defined in org.jfree.chart.axis.SegmentedTimeline

Code: Select all

public static SegmentedTimeline newMondayThroughFridayTimeline()

Re: Candlestick related Problem! Please help

Posted: Mon Mar 16, 2009 3:28 am
by Ken1984
hey skunk, thanks for ur reply. But i dun really know how to do what u have said cos i am very new in programming, is it possible for you to in cooperate what you said into my codes? maybe tell when where i should call and where i should include the lines? thanks man, i owe you one.

Regards,

Ken