Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

Financial Trading in Python

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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 bewerken en uitvoeren