Drawing Fibonacci lines on a OHLC chart

Discussion about JFreeChart related to stockmarket charts.
Locked
gmsc
Posts: 2
Joined: Fri Jul 07, 2006 4:40 pm
Location: Scotland

Drawing Fibonacci lines on a OHLC chart

Post by gmsc » Fri Jul 07, 2006 5:00 pm

Hi all,

I am attempting to create a chart that offers the ability to to draw fibonacci lines from user selected points on a OHLC chart. Has anyone done this or knows how to do this? I am quite new to Java any help with coding examples or any tips would be welcome.

Thanks in advance!

LP302
Posts: 1
Joined: Fri Jan 26, 2007 7:00 pm

Drawing Fibonacci Lines

Post by LP302 » Fri Jan 26, 2007 7:09 pm

Hi.

I hope I am doing this right as this is my first time on this system.

I am very interested in your work on creating a program to allow users to draw their own Finonacci lines on a chart. Unfortunately I do not know how to help you program this.

I can tell you what I would be most interested in. I would like to be able to determine the high and low points through which the lines will be drawn, and I would like to be able to choose from the high/low for a single day or the high/low for any number of days I choose. I would also like to be able to draw lines from any high or low close.

Probably the most unusual aspect of what I would like to see is the ability to input my own Fibonacci numbers, which may be different from the standary Fibonacci numbers.

As you progress on your system I would be most interested in learning of your progress. GOOD LUCK!

--LP302

develop
Posts: 296
Joined: Wed Mar 23, 2005 10:01 pm

Post by develop » Fri Jan 26, 2007 10:40 pm

what lines are you trying to draw. fibbonacci fan lines or retracements.

you can annotations in jfreechart to draw lines, which i have done already.

hope this helps

williamt
Posts: 13
Joined: Thu Dec 14, 2006 1:22 pm

Post by williamt » Fri Mar 16, 2007 5:50 pm

Hi,
I did the same thing you want to do, and I did this:
Created a mouseListener class that extended MouseAdapter class, and implemented MouseMotionListener interface.
on mousePress method, you have to get the coords from mouseClick and translate the coords to axis values, using the java2DToValue method of both domain and range axis. (The Java2D coords you can get from the MouseEvent class).
While moving (mouseDragged method/event) and on mouse release (mouseReleased), you need to get again the coords in axes value. Now you should have 2 points, one with the start and one with the end point.
Since you are using OHLC chart, that extends XYLineChart, you can use XYLineAnnotation and draw the lines.
I think that the "catch" to do that is that you have to use XYLineAnnotation, so you can still see your fibonnaci series lines after zooming in or out, and that you have to translate the java2d coords in the MouseEvent to axes value.
After that, you just need to add the listener class you created to your chartPanel.

William

raghavan_26
Posts: 59
Joined: Fri Oct 13, 2006 11:35 am
Contact:

Post by raghavan_26 » Wed Apr 11, 2007 9:08 am

Hi williamt ,

Can you please Post a sample code how you have implemented it

Thanks in advance
raghavan

Locked