I do apologize for this question but I am seriously struggling. Below is my code so far. Im 2 months into python and here Ive been sitting for a whole day trying to figure this out. Please can someone take a look and maybe provide a comment on it. https://colab.research.google.com/drive/1aah4KDMIBLtNVHXwvEeW0TDKMdBL2tvz?usp=sharing
How do i add my ta indicator to my mplfinance candlstick chart?
1k views Asked by Andrethebeginner At
2
There are 2 answers
1
On
Looking at the code in your question, I see that the error is at the end where the indicator is added with plotly, so I will also add a graph using plotly as an example.
import plotly.graph_objects as go
import pandas as pd
fig = go.Figure()
fig.add_trace(go.Candlestick(x=df.index,
open=df['Open'],
high=df['High'],
low=df['Low'],
close=df['Close'],
name='EURUSD=X'
))
fig.add_trace(go.Scatter(x=df.index,
y=df['Final Lowerband'],
mode='lines',
line=dict(color='green'),
name='Final Lowerband'
))
fig.add_trace(go.Scatter(x=df.index,
y=df['Final Upperband'],
mode='lines',
line=dict(color='red'),
name='Final Upperband'
))
fig.update_layout(xaxis_rangeslider_visible=False)
fig.show()
There are a number of mplfinance tutorials listed here.
Recommend you read the Adding Your Own Technical Studies to Plots tutorial.
The basic idea is to call
mpf.make_addplot()
to generate the information needed to display your TA on the candlestick chart, and then use kwargaddplot
to add it to the candelstick chart. Something like this:...
P.S. I am not very familiar with
pandas_ta
, but i do know that it uses mplfinance under the hood, and there should be, I believe, a way to simply askpandas_ta
to plot both your candlestick chart and the technical analysis.