r"""Determine those values of the dataframe that are below the moving average. Parameters ---------- f : pandas.DataFrame Dataframe containing the column ``c``. c : str, optional Name of the column in the dataframe ``f``. pfast : int, optional The per
(f, c='close', pfast = 20, pslow = 50)
| 1609 | # |
| 1610 | |
| 1611 | def xmaup(f, c='close', pfast = 20, pslow = 50): |
| 1612 | r"""Determine those values of the dataframe that are below the |
| 1613 | moving average. |
| 1614 | |
| 1615 | Parameters |
| 1616 | ---------- |
| 1617 | f : pandas.DataFrame |
| 1618 | Dataframe containing the column ``c``. |
| 1619 | c : str, optional |
| 1620 | Name of the column in the dataframe ``f``. |
| 1621 | pfast : int, optional |
| 1622 | The period of the fast moving average. |
| 1623 | pslow : int, optional |
| 1624 | The period of the slow moving average. |
| 1625 | |
| 1626 | Returns |
| 1627 | ------- |
| 1628 | new_column : pandas.Series (bool) |
| 1629 | The array containing the new feature. |
| 1630 | |
| 1631 | References |
| 1632 | ---------- |
| 1633 | *In the statistics of time series, and in particular the analysis |
| 1634 | of financial time series for stock trading purposes, a moving-average |
| 1635 | crossover occurs when, on plotting two moving averages each based |
| 1636 | on different degrees of smoothing, the traces of these moving averages |
| 1637 | cross* [WIKI_XMA]_. |
| 1638 | |
| 1639 | """ |
| 1640 | sma = ma(f, c, pfast) |
| 1641 | sma_prev = sma.shift(1) |
| 1642 | lma = ma(f, c, pslow) |
| 1643 | lma_prev = lma.shift(1) |
| 1644 | new_column = (sma > lma) & (sma_prev < lma_prev) |
| 1645 | return new_column |
| 1646 | |
| 1647 | |
| 1648 | # |