PDA

View Full Version : Cluster data points to levels on graph



s5804
01-05-2010, 09:40 AM
Dear all, I have googled and tried many things. Right now I am stuck and looking for suggestions, ideas on where to look further.

I am looking for a strategy to automatically determine the support/resistance (S/R) levels in a graphical price chart.

Please see picture. The S/R lines is an example of what I like to achieve.

To simplify matter are horizontal S/R lines fully sufficient.

I have tried to find a line with the smallest square error. But ultimately, who to determine, which data points shall belong to which S/R line.
Further I have tried k-means clustering to somehow cleverly group data points to their S/R line with the shortest distance. But it clusters data points more around a radius than along a line.

Grateful for suggestions
s5804

http://i919.photobucket.com/albums/ad38/s5804/Trading%20Images/cluster.gif

ZbuffeR
01-05-2010, 04:15 PM
These support/resistance levels sound highly unscientific, the king of things able to bring economic crysis easily, if you see what I mean :whistle:

Did you read these 2 pages ?
http://en.wikipedia.org/wiki/Support_and_resistance
http://en.wikipedia.org/wiki/Pivot_point_calculations
The "pivot points" page seem to provides ways to compute these levels.

s5804
01-06-2010, 01:31 AM
Yep, for trading decision it is very unscientific.
But for charting presentation it is a nice challenge.

Unfortunately the above wiki formulas are to simple.

The more interesting task is to figure out how the human brain clusters and categorizes data points in to something like the image above.

david_m
01-06-2010, 11:39 AM
Hi,

For this type of thing the important consideration is that the points in the graph are generated at different points in time. All points are not equal, the graph really does start at the left and go to the right. Things that you tried like least squares ignore this fact and so offer no hope in providing the answer. Here is one method to generate an s/r line.

1.) Pick a minimum time step (I don't know what would be reasonable for the economics world.)
2.) A s/r line exists where price levels are relatively unchanged (in some sense) for at least the minimum time step.
3.) Start at the left end of the plot, and sequentially determine if each point is the start of an s/r line, and if so, the extent of the line.

Notice that this is a sequential method, you can't consider all points simultaneously. Also, picking a reasonable time step is critical.

Hope this helps in getting started.
David