强度指标:ADX

Python 中的金融交易

Chelsea Yang

Data Science Instructor

什么是 ADX?

  • "平均趋向指数"(Average Directional Movement Index)
  • 由 J. Welles Wilder 提出
    • 《New Concepts in Technical Systems》(1987)

Wells Wilder 书籍

  • 衡量趋势强度
    • 在 0 到 100 之间波动
    • ADX <= 25:无明显趋势
    • ADX > 25:有趋势
    • ADX > 50:强趋势
Python 中的金融交易

ADX 如何计算?

  • 来自 +DI 与 -DI 差值的平滑均值
    • +DI(正向指标):量化上升趋势
    • -DI(负向指标):量化下降趋势

 

  • 计算所需输入:
    • 各周期的最高价、最低价、收盘价
Python 中的金融交易

在 Python 中实现 ADX

# Calculate ADX
stock_data['ADX'] = talib.ADX(stock_data['High'], stock_data['Low'], stock_data['Close'],
                              timeperiod=14)

# Print the last five rows print(stock_data.tail())
             Open   High    Low  Close   ADX
Date                                        
2020-11-24 540.40 559.99 526.20 555.38 21.16
2020-11-25 550.06 574.00 545.37 574.00 23.92
2020-11-27 581.16 598.78 578.45 585.76 26.82
2020-11-30 602.21 607.80 554.51 567.60 28.25
2020-12-01 597.59 597.85 572.05 584.76 29.58
Python 中的金融交易

绘制 ADX

import matplotlib.pyplot as plt

# Create subplots
fig, (ax1, ax2) = plt.subplots(2)

# Plot ADX with the price ax1.set_ylabel('Price') ax1.plot(stock_data['Close']) ax2.set_ylabel('ADX') ax2.plot(stock_data['ADX']) ax1.set_title('Price and ADX') plt.show()

上方为价格图,下方为 ADX 图

Python 中的金融交易

让我们练习!

Python 中的金融交易

Preparing Video For Download...