r"""Calculate the Plus Directional Indicator (+DI). Parameters ---------- f : pandas.DataFrame Dataframe with columns ``high`` and ``low``. p : int The period over which to calculate the +DI. Returns ------- new_column : pandas.Series (float) The
(f, p = 14)
| 264 | # |
| 265 | |
| 266 | def diplus(f, p = 14): |
| 267 | r"""Calculate the Plus Directional Indicator (+DI). |
| 268 | |
| 269 | Parameters |
| 270 | ---------- |
| 271 | f : pandas.DataFrame |
| 272 | Dataframe with columns ``high`` and ``low``. |
| 273 | p : int |
| 274 | The period over which to calculate the +DI. |
| 275 | |
| 276 | Returns |
| 277 | ------- |
| 278 | new_column : pandas.Series (float) |
| 279 | The array containing the new feature. |
| 280 | |
| 281 | References |
| 282 | ---------- |
| 283 | *A component of the average directional index (ADX) that is used to |
| 284 | measure the presence of an uptrend. When the +DI is sloping upward, |
| 285 | it is a signal that the uptrend is getting stronger* [IP_PDI]_. |
| 286 | |
| 287 | .. [IP_PDI] http://www.investopedia.com/terms/p/positivedirectionalindicator.asp |
| 288 | |
| 289 | """ |
| 290 | tr = 'truerange' |
| 291 | vexec(f, tr) |
| 292 | atr = USEP.join(['atr', str(p)]) |
| 293 | vexec(f, atr) |
| 294 | dmp = 'dmplus' |
| 295 | vexec(f, dmp) |
| 296 | new_column = 100 * f[dmp].ewm(span=p).mean() / f[atr] |
| 297 | return new_column |
| 298 | |
| 299 | |
| 300 | # |