r"""Calculate the Plus Directional Movement (+DM). Parameters ---------- f : pandas.DataFrame Dataframe with columns ``high`` and ``low``. Returns ------- new_column : pandas.Series (float) The array containing the new feature. References ----------
(f)
| 336 | # |
| 337 | |
| 338 | def dmplus(f): |
| 339 | r"""Calculate the Plus Directional Movement (+DM). |
| 340 | |
| 341 | Parameters |
| 342 | ---------- |
| 343 | f : pandas.DataFrame |
| 344 | Dataframe with columns ``high`` and ``low``. |
| 345 | |
| 346 | Returns |
| 347 | ------- |
| 348 | new_column : pandas.Series (float) |
| 349 | The array containing the new feature. |
| 350 | |
| 351 | References |
| 352 | ---------- |
| 353 | *Directional movement is positive (plus) when the current high minus |
| 354 | the prior high is greater than the prior low minus the current low. |
| 355 | This so-called Plus Directional Movement (+DM) then equals the current |
| 356 | high minus the prior high, provided it is positive. A negative value |
| 357 | would simply be entered as zero* [SC_ADX]_. |
| 358 | |
| 359 | .. [SC_ADX] http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:average_directional_index_adx |
| 360 | |
| 361 | """ |
| 362 | c1 = 'upmove' |
| 363 | f[c1] = net(f, 'high') |
| 364 | c2 = 'downmove' |
| 365 | f[c2] = -net(f, 'low') |
| 366 | new_column = f.apply(gtval0, axis=1, args=[c1, c2]) |
| 367 | return new_column |
| 368 | |
| 369 | |
| 370 | # |