Skip to content

Commit a5a1fa4

Browse files
authored
Merge pull request #1 from coding-kitties/feature/adx
Add adx
2 parents c643ace + 614052d commit a5a1fa4

File tree

8 files changed

+2780
-430
lines changed

8 files changed

+2780
-430
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pip install pyindicators
3434
* [Relative Strength Index (RSI)](#relative-strength-index-rsi)
3535
* [Relative Strength Index Wilders method (Wilders RSI)](#wilders-relative-strength-index-wilders-rsi)
3636
* [Williams %R](#williams-r)
37+
* [Average Directional Index (ADX)](#average-directional-index-adx)
3738
* [Indicator helpers](#indicator-helpers)
3839
* [Crossover](#crossover)
3940
* [Is Crossover](#is-crossover)
@@ -323,6 +324,46 @@ pd_df.tail(10)
323324

324325
![williams %R](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/willr.png)
325326

327+
#### Average Directional Index (ADX)
328+
329+
The Average Directional Index (ADX) is a trend strength indicator that helps traders identify the strength of a trend, regardless of its direction. It is derived from the Positive Directional Indicator (+DI) and Negative Directional Indicator (-DI) and moves between 0 and 100.
330+
331+
```python
332+
def adx(
333+
data: Union[PdDataFrame, PlDataFrame],
334+
period=14,
335+
adx_result_column="ADX",
336+
di_plus_result_column="+DI",
337+
di_minus_result_column="-DI",
338+
) -> Union[PdDataFrame, PlDataFrame]:
339+
```
340+
341+
Example
342+
343+
```python
344+
from investing_algorithm_framework import CSVOHLCVMarketDataSource
345+
346+
from pyindicators import adx
347+
348+
# For this example the investing algorithm framework is used for dataframe creation,
349+
csv_path = "./tests/test_data/OHLCV_BTC-EUR_BINANCE_15m_2023-12-01:00:00_2023-12-25:00:00.csv"
350+
data_source = CSVOHLCVMarketDataSource(csv_file_path=csv_path)
351+
352+
pl_df = data_source.get_data()
353+
pd_df = data_source.get_data(pandas=True)
354+
355+
# Calculate ADX for Polars DataFrame
356+
pl_df = adx(pl_df)
357+
pl_df.show(10)
358+
359+
# Calculate ADX for Pandas DataFrame
360+
pd_df = adx(pd_df)
361+
pd_df.tail(10)
362+
```
363+
364+
![ADX](https://github.com/coding-kitties/PyIndicators/blob/main/static/images/indicators/adx.png)
365+
366+
326367
### Indicator helpers
327368

328369
#### Crossover

poetry.lock

Lines changed: 125 additions & 71 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)