NAME

Finance::Shares::historical_highs - Report periods since last as high

SYNOPSIS

Two examples of how to specify an historical highs line, one showing the minimum required and the other illustrating all the possible fields.

    use Finance::Shares::Model;
    use Finance::Shares::historical_highs;

    my @spec = (
	...
	lines => [
	    ...
	    minimal => {
		function => 'historical_highs',
	    },
	    full = {
		function => 'historical_highs',
		graph    => 'Stock Prices',
		gtype    => 'price',
		line     => 'some_line',
		smallest => 10,
		grain    => 5,
		key      => 'highs of 10 days or more',
		style    => { bars => {} },
		shown    => 1,
		order    => -99,
	    },
	    ...
	],

	samples => [
	    ...
	    one => {
		lines => ['full', 'minimal'],
		...
	    }
	],
    );

    my $fsm = new Finance::Shares::Model( @spec );
    $fsm->build();

DESCRIPTION

This module calculates how many periods it has been since a line was as high as its current position.

To be any use, there must be a Finance::Shares::Model specification lines entry that has a function field declaring the module's name. Then the entry's tag must be used by a sample in some way. This may be either directly in a line field, or by referring to it within a test.

The other main fields are line, grain and smallest. This line is presented on the 'level' graph and is best shown as a bar chart. i.e. with style holding a bars entry as in the SYNOPSIS example.

OPTIONS

function

Required. Must be historical_highs.

graph

If present, this should be a tag declared as a charts resource. It identifies a particular graph within a chart page. A gtype is implied. (No default)

gtype

Required, unless graph is given. This specifies the type of graph the function lines should appear on. It should be one of price, volume, analysis or level. (Default: price)

line

Identifies the line whose data is to be averaged. (Default: 'close')

grain

This is the range which is considered to be 'the same' for this calculation. (Default: 1)

[This is only provided for cases where the range is very narrow. For example, if 11.5 and 11.75 are considered different, then this should be set to 0.05.]

smallest

Often the small ups and downs are not significant. Gaps of less than this value will not be reported. (Default: 1)

key

Most functions generate suitable (if lengthy) entries. This provides the opportunity to identify the line in the Key panel, next to the style.

order

The entries on the graph are sorted according to this value, which defaults to the order required for calculation. A large integer will bring the line to the front and a negative number will put it behind all the rest.

Examples

-1

The line goes behind the data.

0.5

In front of the data, but only just.

999

Probably the top line.

shown

1 for the line to be shown, 0 hides it. (Default: 1)

style

This is normally a hash ref defining the data's appearance. See PostScript::Graph::Style for full details, or "Lines" in Finance::Shares::Model for an example.

BUGS

Please let me know when you suspect something isn't right. A short script working from a CSV file demonstrating the problem would be very helpful.

AUTHOR

Chris Willmot, chris@willmot.org.uk

LICENCE

Copyright (c) 2002-2003 Christopher P Willmot

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy can be found at http://www.gnu.org/copyleft/gpl.html

SEE ALSO

Finance::Shares::Overview provides an introduction to the suite, and fsmodel is the principal script.

Modules involved in processing the model include Finance::Shares::Model, Finance::Shares::MySQL, Finance::Shares::Chart. Chart and file details may be found in PostScript::File, PostScript::Graph::Paper, PostScript::Graph::Key, PostScript::Graph::Style.

All functions are invoked from their own modules, all with lower-case names such as Finance::Shares::moving_average. The nitty-gritty on how to write each line specification are found there.

The quote data is stored in a Finance::Shares::data object. For information on writing additional line functions see Finance::Share::Function and Finance::Share::Line. Also, Finance::Share::test covers writing your own tests.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 214:

Expected text after =item, not a number