building text based point and figure charts in Matlab or R

tdzidic

Newbie
Messages
4
Likes
0
I am wondering if anybody has some advice how to program point and figure on your own. I know that I shoud use array, and I know how to export it to ascii file, but algorithm for building that array just eludes me.

My goal is to produce charts like this
110 .X.........................
105 OXO........................
100 OXO........................
095 O.O........................


I would appreciate any help and pointers to solution.

Thank you.

Tom
 
finished in R

I will post it tomorrow.
Now I need methodology for backtesting (pattern recognition).

Thanks.

T.
 
asking for answers clarifies thinking

This is what I came up with, written for R (www.r-project.org).
Any suggestions and questions welcome.
Of course tips on developing backtesting engine for testing signals and optimizations are also welcome.

T.
 

Attachments

  • PnF.txt
    2 KB · Views: 977
I am wondering if anybody has some advice how to program point and figure on your own. I know that I shoud use array, and I know how to export it to ascii file, but algorithm for building that array just eludes me.

My goal is to produce charts like this
110 .X.........................
105 OXO........................
100 OXO........................
095 O.O........................


I would appreciate any help and pointers to solution.

Thank you.

Tom

Not sure I understand but is this the sort of thing you're trying to do ?

dd
 

Attachments

  • OXO.txt
    31.2 KB · Views: 1,031
Yes, exactly. I have almost usable solution, (prev. post) but if you have something better (polished) I would appreciate it.

T.

I did it using Visual Basic.

Same as you I used a 2 dimension string array and set each value in the array to a single empty space ( I see you used a period ???? ). All I did then was to plot the P+F chart within the array by overwriting the empty spaces with X's or 0's. After that it's just a simple matter or printing the result out to a txt file in a series of horizontal strips ( strings ).

The complex part is calculating the plot from the original price data.

I suppose it would be better to create a csv file then you could open it with Excel. That way you could draw lines and use conditional formating to add colour to the chart.

dd

[edit] thinking about it, if you used a macro in Excel you could just output the X's and 0's straight into the empty cells on a spread sheet. I wonder if P+F is available as a chart in Excel ? Never thought of that ! I'll go check.
 
Last edited:
VB Code

dd,
I've been trying to look for an excel based P&F charting system, no luck yet! Have you come across one yet?
Cheers'
A

I did it using Visual Basic.

Same as you I used a 2 dimension string array and set each value in the array to a single empty space ( I see you used a period ???? ). All I did then was to plot the P+F chart within the array by overwriting the empty spaces with X's or 0's. After that it's just a simple matter or printing the result out to a txt file in a series of horizontal strips ( strings ).

The complex part is calculating the plot from the original price data.

I suppose it would be better to create a csv file then you could open it with Excel. That way you could draw lines and use conditional formating to add colour to the chart.

dd

[edit] thinking about it, if you used a macro in Excel you could just output the X's and 0's straight into the empty cells on a spread sheet. I wonder if P+F is available as a chart in Excel ? Never thought of that ! I'll go check.
 
Thanks dd,

Would it be possible for you to send me the code which you used to create the OXO.txt file? I will try to modify that to create a P&F module in excel/VBA.
[email protected]

Cheers
A

I knew someone was going to ask me that. I think it got lost when my old desktop PC had a stroke. I'll see if I can find a backup copy on a disk.

Failing that, if I get a spare moment I'll have a go at building a simple macro in excel.

The original code was written in a old version Visual Basic Editor ( not excel ) so the code wouldn't have worked in a macro anyway.

dd
 
I knew someone was going to ask me that. I think it got lost when my old desktop PC had a stroke. I'll see if I can find a backup copy on a disk.

Failing that, if I get a spare moment I'll have a go at building a simple macro in excel.

The original code was written in a old version Visual Basic Editor ( not excel ) so the code wouldn't have worked in a macro anyway.

dd

Hehe..
Thanks for looking. Don't worry about re-writing the code if you don't have it handy. I know the algorithm, I can get someone to convert it to a VBA code.
And apologies for the delay in the response...
Cheers
AB
 
Hi All,
If you've still got unresolved issues regarding Excel and P&F charts, it might be worth contacting DaveJB - as he's something of an expert in this field. He doesn't post much these days, but he does look in from time to time.
Tim.
 
Hi,
saw this as I was browsing... my program is/was thousands of lines of Visual Basic code, not something that would be convertible to Excel, or any other program. As a general idea I stored price data in a whole bunch of arrays - O,H,L,C,Date for the price data, an array held info on what the columns of X's and O's should be like - primarily info such as 'date column started, is it X or O, price of lowest box in the column, price of highest box in column... and so forth.

This was quite memory hungry, it would never have worked on a ZX81!

Backtesting - this depends on what you want your tests to be like, I wanted to simulate actual trading so it got rather involved, but if you just want to know if the column continued up after a double top (say) then you can do that very easily by comparing the top prices in alternate columns (ie compare one X column with the previous X column).

Programming this got very complex, but much of that was due to trying to make it handle all markets - if you only want FTSE or USA you don't have to put so many extras in to handle huge price ranges, and if you are happy with a single method of box sizing that again simplifies it rather.

Dave
 
Hi,
saw this as I was browsing... my program is/was thousands of lines of Visual Basic code, not something that would be convertible to Excel, or any other program. As a general idea I stored price data in a whole bunch of arrays - O,H,L,C,Date for the price data, an array held info on what the columns of X's and O's should be like - primarily info such as 'date column started, is it X or O, price of lowest box in the column, price of highest box in column... and so forth.

This was quite memory hungry, it would never have worked on a ZX81!

Backtesting - this depends on what you want your tests to be like, I wanted to simulate actual trading so it got rather involved, but if you just want to know if the column continued up after a double top (say) then you can do that very easily by comparing the top prices in alternate columns (ie compare one X column with the previous X column).

Programming this got very complex, but much of that was due to trying to make it handle all markets - if you only want FTSE or USA you don't have to put so many extras in to handle huge price ranges, and if you are happy with a single method of box sizing that again simplifies it rather.

Dave


That's great Dave, thanks for sharing the info & logic.

I am currently in the early stages building this application. I am working on the first stage of constructing the P&F charts. (On that note, I have attached a basic EasyLanguage code for plotting P&F charts. I wouldn't mind if you have the time to skim through the logic to confirm that I am on the right track!) However, over the next few weeks, I intend to develop this into a full-fledged P&F application. I would be greatly benefited if you could possibly advise me regarding the kind of functionalities you incorporated in your trading simulation application. Also, let me know if there is any documentation you could share regarding this application.

If you have the time I would like to be in touch with you on a regular basis to get your feedback/advice on my progress with this application (using perosnal email if you prefer).

Thanks. Let me know.
My personal email is [email protected]
Regards
AB
 

Attachments

  • P&F Easy Language program.docx
    13.7 KB · Views: 815
Hi,
I've emailed you one of the docs I used to supply with my program so you can get a feel for what was included - you'll note that it did candlecharts and various sorts of pattern finding on candle/bar charts as well as locating a couple of dozen P&F signals.

The backtesting was pretty involved, so a second email has the relevant manual attached so you can see how that went. This allowed different filters to be selected for entry and exit conditions, and worked by replaying each share, 1 day at a time, until entry/exit were signalled based on the price data that would be visible at the relevant close and open.

Whilst I don't mind the odd question I am not going to read code or be a consultant - I'm not being grumpy here but this program was a tremendous amount of work (60 hrs a week for several years) and I cannot conceive of being able to make a meaningful input that wouldn't involve me in a great deal of time and effort... I have a busy life and my current career already fills enough of my spare time up, I really don't have time to do more than pass the odd comment.

I will say that if you limit the scope to being functional rather than pretty, and only program it to do what you want yourself, the job isn't too huge... if you start thinking about releasing it to a wider audience (at which point you have to devote time to removing unsightly bits and fixing that routine that makes the chart go upside down on Tuesdays etc) then it's a whole new ball game...so if that's an aim email me and I'll explain some of the stuff that isn't immediately apparent when a good idea pops up.

I recommend the Carol Aby book for P&F charting, by the way.

Dave
 
Hi,

this may be a little late, but you might try the new R-package rpnf from here.

It is able to produce Point & Figure Charts (with downloaded data from yahoo or your own data). Additional it identifies sophisticated Buy and Signals like Double/Triple Top/Bottom, Bullish/Bearish Signal for you. Furthermore it can be used to create Relative Strength Charts as well as Bullish Percent Charts.

Examples

A PNG-Plot can be seen here.

A text plot looks like:
Code:
Point & Figure Plot DAX30 (log) 
--------+-----------------------
 7954.90|                      X
 7648.94|                      X
 7354.75|    X X               X
 7071.88|    XOXO            X X
 6799.88|    XOXO            XOX
 6538.35|    XOXO            XOX
 6286.87|X X XO O          X XOX
 6045.07|XOXOX  OX X       XOXOX
 5812.57|XOXOX  OXOXOX     XOXO 
 5589.01| O O   OXOXOXOX X XOX  
 5374.05|       O O OXOXOXOXOX  
 5167.35|           O OXOXOXO   
 4968.61|             OXO O     
 4777.51|             O         
--------+-----------------------
       Y|22222222222222222222222
       Y|00000000000000000000000
       Y|11111111111111111111111
       Y|00000111111111111111122
        |                       
       M|00000000000000000111100
       M|45678338888889999001147
        |                       
       D|00200130111130122000220
       D|57152512015815527461933
 
Top