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
Asked
Active
Viewed 652 times
2 Answers
1
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 kwarg addplot
to add it to the candelstick chart. Something like this:
ap = mpf.make_addplot( ta_data, kwargs, ... )
mpf.plot( df, type='candle', addplot=ap )
...
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 ask pandas_ta
to plot both your candlestick chart and the technical analysis.

Daniel Goldfarb
- 6,937
- 5
- 29
- 61
0
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()

r-beginners
- 31,170
- 3
- 14
- 32
-
OMG thank you so much. You are a life saver. I will study how you did because damn, it sucks not knowing what im doing. Really appreciate your help. – Andrethebeginner May 08 '22 at 09:37