Paul Miller > stockmonkey-2.9405 > Math::Business::ParabolicSAR

Download:
stockmonkey-2.9405.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

Math::Business::ParabolicSAR - Technical Analysis: Stop and Reversal (aka SAR)

SYNOPSIS ^

  use Math::Business::ParabolicSAR;

  my $sar = new Math::Business::ParabolicSAR;
     $sar->set_alpha(0.02, 0.2);

  # alternatively/equivilently
  my $sar = new Math::Business::ParabolicSAR(0.02, 0.2);

  # or to just get the recommended model ... (0.02, 0.2)
  my $sar = Math::Business::ParabolicSAR->recommended;

  my @data_points = (
      ["35.0300", "35.1300", "34.3600", "34.3900"],
      ["34.6400", "35.0000", "34.2100", "34.7400"],
      ["34.6900", "35.1400", "34.3800", "34.7900"],
      ["35.2900", "35.7900", "35.0800", "35.5200"],
      ["35.9000", "36.0600", "35.7500", "36.0600"],
      ["36.1300", "36.7200", "36.0500", "36.5800"],
      ["36.4100", "36.6400", "36.2600", "36.6100"],
      ["36.3500", "36.5500", "35.9400", "35.9700"],
  );

  # choose one:
  $sar->insert( @data_points );
  $sar->insert( $_ ) for @data_points;

  my $sar = $sar->query;
  print "SAR: $sar\n";

  # Briefly, the SAR is below the price data when you're meant to
  # be holding stocks (long) and above it when you're meant to be
  # on margin (short).

  print "The SAR is long  today.\n" if $sar->long;
  print "The SAR is short today.\n" if $sar->short;

RESEARCHER ^

The Parabolic Stop and Reversal was designed by J. Welles Wilder Jr circa 1978.

The SAR is meant to be used to "stop loss" on a position. It assumes you always have a position in the market (long if you're holding stocks and short when you're on margin). When the SAR crosses the price data, it signals a sell (when you're long) or a buy (when you're short).

Wilder himself felt the SAR was particularly vulnerable to "whipsaws" and recommended only using the SAR when the ADX is above 30 -- that is, when there is a strong trend going.

THANKS ^

Gustav <gustavf@gmail.com>

AUTHOR ^

Paul Miller <jettero@cpan.org>

I am using this software in my own projects... If you find bugs, please please please let me know. There is a mailing list with very light traffic that you might want to join: http://groups.google.com/group/stockmonkey/.

COPYRIGHT ^

Copyright © 2013 Paul Miller

LICENSE ^

This is released under the Artistic License. See perlartistic.

SEE ALSO ^

perl(1), Math::Business::StockMonkey, Math::Business::StockMonkey::FAQ, Math::Business::StockMonkey::CookBook

http://en.wikipedia.org/wiki/Parabolic_SAR

The Encyclopedia of Technical Market Indicators - Page 495

syntax highlighting: