I have a custom indicator that I display in a secondary plot in an mplfinance plot. The plot uses a y axis ranging from 100 to -100. Points on the indicator above 20 and below -20 are significant, so I want to plot threshold lines for +20 and -20 on the same plot using the same y axis as the indicator. When I plot these lines they have their own y axis (shown on the right of the plot) ranging from 20 to -20. How can I get them to use the indicator’s y axis?
My code is as follows:
if __name__ == '__main__':
df = pd.read_csv('GBPUSD_MA_Crossover2.csv', index_col=0, parse_dates=True)
df.index.name = 'date'
threshold = 20
upper_threshold = [threshold] * len(df)
lower_threshold = [0-threshold] * len(df)
apds = [ mpf.make_addplot(df[['fast_ma', 'slow_ma']], panel=0, title='GBPUSD'),
mpf.make_addplot((df['dmi']),panel=1, title='DMI'),
mpf.make_addplot(upper_threshold, panel=1),
mpf.make_addplot(lower_threshold, panel=1)
]
mpf.plot(df, type= 'candle', tight_layout=True, datetime_format='%Y-%m-%d',
volume=False, show_nontrading=False, addplot=apds)
Many thanks, StuartM