LoslegenKostenlos starten

Visualize the ADX

The ADX can quantify the strength of a trend, but does not suggest the bullish or bearish trend direction. Typically an ADX value above 25 indicates that a trending market is present. To better understand it, you will calculate the ADX and plot it along with the price data.

As in the previous exercise, you will use historical daily price data of the Tesla stock, which has been loaded in as stock_data. Also, talib has been imported for you, and matplotlib.pyplot has been imported as plt.

Diese Übung ist Teil des Kurses

<Kurs>Financial Trading in Python</Kurs>
Kurs ansehen

Interaktive praktische Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Calculate ADX
stock_data['ADX'] = ____(stock_data['____'], stock_data['____'], stock_data['____'])

# Create subplots
fig, (ax1, ax2) = ____(2)

# Plot ADX with the price
ax1.set_ylabel('Price')
____(stock_data['____'])
ax2.set_ylabel('ADX')
____(stock_data['____'], color='red')

ax1.set_title('Price and ADX')
plt.show()
Code bearbeiten und ausführen