BaşlayınÜcretsiz Başlayın

Calculate the ADX

The average directional movement index (ADX) was developed by J. Welles Wilder as an indicator of trend strength. It combines two other indicators, the plus directional index (+DI) and minus directional indicator (-DI), and is obtained using lengthy calculations. However, with Python, you can calculate it with one line of code. In this exercise, you will implement your first ADX indicator using daily price data of the Tesla stock.

The historical daily price data has been loaded in stock_data. Also, talib has been imported for you.

Bu egzersiz

Financial Trading in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Calculate the ADX using the appropriate function from talib, and the High, Low and Close columns in the stock_data. Save it in a new column ADX_14.
  • Calculate the ADX . This time change the default time period to 21, and save it in a new column ADX_21.
  • Print the last five rows of stock_data.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Calculate the ADX with the default time period
stock_data['ADX_14'] = ____(stock_data['____'],
                            stock_data['____'], 
                            stock_data['____'])

# Calculate the ADX with the time period set to 21
stock_data['ADX_21'] = ____

# Print the last five rows
print(stock_data.____())
Kodu Düzenle ve Çalıştır