Math::Business::MACD - Technical Analysis: Moving Average Convergence/Divergence


NAME

Math::Business::MACD - Technical Analysis: Moving Average Convergence/Divergence


SYNOPSIS

  use Math::Business::MACD;
  # WARNING: To clear up any confusion, Appel used 12-26-9 rather
  # than the 26,12,9 shown here -- that is, he used
  # fast-slow-trigger instead of slow-fast-trigger as used below.
  my ($slow, $fast, $trigger) = (26, 12, 9);
  my $macd = new Math::Business::MACD;
     $macd->set_days( $slow, $fast, $trigger );
  # alternatively/equivelently
  my $macd = new Math::Business::MACD( $slow, $fast, $trigger );
  # or to just get the recommended model ... (26,12,9)
  my $macd = Math::Business::MACD->recommended;
  my @closing_values = map { 3+ int rand 27 } 1 .. $slow+$fast;
  # choose one:
  $macd->insert( @closing_values );
  $macd->insert( $_ ) for @closing_values;
  print "       MACD: ", scalar $macd->query,    "\n",
        "Trigger EMA: ", $macd->query_trig_ema,  "\n",
        "   Fast EMA: ", $macd->query_fast_ema,  "\n",
        "   Slow EMA: ", $macd->query_slow_ema,  "\n";
        "  Histogram: ", $macd->query_histogram, "\n";
  my @macd = $macd->query;
  # $macd[0] is the MACD
  # $macd[1] is the Fast
  # $macd[2] is the Slow
  # $macd[3] is the Trigger
  # $macd[4] is the Histogram


RESEARCHER

The MACD was designed by Gerald Appel in the 1960s.

MACD graphs usually show:

    1. The MACD=ema[fast]-ema[slow] -- query()
    2. The signal=ema[trig]         -- query_trig_ema()
    3. The histogram=MACD-signal    -- query_histogram()

Appel designed the MACD to spot tend changes.

It is believed that when the MACD crosses the signal line on the way up, it signals a buy condition and when the MACD crosses the signal line on the way down, it's time to sell. The histogram can help to visualize when a crossing is going to occur.

A upward crossing of the MACD through the zero-line indicates a bullish situation and vice versa.


Thanks

David Perry


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.

I normally hang out on #perl on freenode, so you can try to get immediate gratification there if you like. irc://irc.freenode.net/perl

There is also a mailing list with very light traffic that you might want to join: http://groups.google.com/group/stockmonkey/.


COPYRIGHT

Copyright (c) 2008 Paul Miller -- LGPL [Software::License::LGPL_2_1]

    perl -MSoftware::License::LGPL_2_1 \
         -e '$l = Software::License::LGPL_2_1->new({
             holder=>"Paul Miller"});
             print $l->fulltext' | less


SEE ALSO

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

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