ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  how compare two stock in perl with chartDirector, for beginners
Posted by Felipe on Feb-15-2011 00:14
Attachments:
Hi, Peter, I download the evalution mode of your library, the perl version, in the last days, I read a lot of posts about read a csv file and others items for automate for creates a pngs files in a batch.

I read this post carefully and I do some test, but with not sucess.
http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&pattern=Finance&thread=1244750697 I try translate to perl, but I have not sucess.

I'm not a programmer, perphaps a advanced user, so sorry if my question is very basic.

i'm re-use same examples of the forum, but with not sucess.

I attach you the .pl file and and txt with the format of the both csv files.

Thanks

I think that you library is a excellent work.

Felipe
csvexamples.txt
csvexamples.txt

1.23 Kb
forumexample.pl
forumexample.pl

2.55 Kb

  Re: how compare two stock in perl with chartDirector, for beginners
Posted by Peter Kwan on Feb-15-2011 10:50
Hi Felipe,

There are many syntax errors in your code. When you run the code, your Perl interpret should tell you where are the errors. Please make sure you fix the syntax errors first. If you are not familiar with Perl, you may refer to the Perl documentation on the correct language syntax.

Some examples of the syntax errors are:

The line:

my (@dates2, @opens2 @highs2, @lows2, @closes2, @vols2, @adjcloses2);

should be:

my (@dates2, @opens2, @highs2, @lows2, @closes2, @vols2, @adjcloses2);

The line 59:

my $infile = $ARGV[1];

should be

$infile = $ARGV[1];

The line:

$m.makeChart3().merge($m2.makeChart3(), 0, 0, TopLeft, 0);

should be:

$m->makeChart3()->merge($m2->makeChart3(), 0, 0, $perlchartdir::TopLeft, 0);

Also, your code has not set up the $m and $m2 as in the code in the forum. The changes are:

The line:

$c->addIndicator(200);

should be:

my $m = $c->addIndicator(200);

The line:

c2->addMainChart(200);

should be:

my $m2 = $c2->addMainChart(200);


For the above types of error, when you try to run the program, the Perl interpreter should instantly tells you where is the error. You may use the error message the debug the code. For example, if the Perl interpreter tells you there is an error at "my (@dates2, @opens2 @highs2, @lows2, @closes2, @vols2, @adjcloses2);", you can carefully read the code to see what is the error. (In this case, it is missing a comma.)


Finally, in case you are not aware, your current code does not handle empty lines in the text file. Please make sure there is no empty line in your text file.

Hope this can help.

Regards
Peter Kwan

  Re: how compare two stock in perl with chartDirector, for beginners
Posted by Felipe on Feb-15-2011 16:42
Attachments:
Thanks Peter for your answer, I fixed my error and run ok.

if I donw write my $infile... appear one error, if I write "my $infile = $ARGV[1];" dont appear any error.

I attach you the final png file and the .pl that output this file. in this graph I dont know why the 2002 and 2004 appear in bold, I can fixed it ?.

And second I have the file1 and file2 with the historical data, that have some years, exist any way for do a graphic from some specific date ? for example I want that only a graph from 2011-01-02 I can put this variable in my script and use the entire historic file data.

The other option that I can think it prepare a individual txt file for each  period of the graph, but I prefer avoid this option if it possible.

Regards
Felipe
forumexample2.pl
forumexample2.pl

2.51 Kb
    
finalresult.png

  Re: how compare two stock in perl with chartDirector, for beginners
Posted by Felipe on Feb-15-2011 16:44
Hi Peter, again sorry for this inconvenience, I uncoment the line
$c2->addIndicator(10); and the year 2002 and 2004 are well ok.

Regards
Felipe