ichimoku data is calculated with pandas_ta and i want to add them to ETH chart with mplfinance.
import pandas as pd
import pandas_ta as ta
import mplfinance as mpl
import matplotlib.pyplot as plt
df=pd.read_csv('.../ETH-USD.csv',index_col=0,parse_dates=True)
df_org=df.copy()
new_names = {
'ISA_9': 'tenkan_sen',
'ISB_26': 'kijun_sen',
'ITS_9': 'senkou_span_a',
'IKS_26': 'senkou_span_b',
'ICS_26': 'chikou_span'
}
ich= ta.ichimoku(df['High'], df['Low'], df['Close'],senkou=True)[0].rename(columns=new_names)
df=pd.concat([df,ich]).drop(columns=['senkou_span_a','senkou_span_b'])
The problem is that when i add the ichimoku to the chart with mpl.plot
method, the result would't be satisfied because the (tenkan_sen,kijun_sen and chikou_span) data is shifted to the right.
fig=mpl.figure(figsize=(12,5))
ax = fig.add_subplot(1,1,1)
apds =[mpl.make_addplot(df.tenkan_sen,color='blue',ax=ax),
mpl.make_addplot(df.kijun_sen,color='r',ax=ax),
mpl.make_addplot(df.chikou_span,color='green',ax=ax),]
mpl.plot(df,type='candle',style='yahoo',addplot=apds,ax=ax)
image_result (mplfinance chart)
i think the problem is with the Null value
with the shifted ichimoku data. i would appreciate for anyone who helps me to fix this issue....
I used matplotlib and it can handle thenull value
in plotting, But the goal is to plot the data into mplfinance.....