Yvar
Yvar

Reputation: 155

Print two points with mpf.plot mplfinance

I would like to print out some Pivot Points in a chart. But I have trouble with time variables.

two_points =[(lastDate,lastPivot),(yesterday,lastPivot)]
mpf= mpf.plot(dfnew_plot,type='candle',alines= two_points)

But the time variable lastDate and yesterday do not have the same format: lastDate = 2021-01-15 00:00:00
yesterday= 2021-01-30

lastDate = 2021-01-15 00:00:00
yesterday= 2021-01-30

How can I format lastDate and yesterday correct?

The end result plot is the following. Actualy sometimes the code is working and sometimes not:

mpf.plot(dfnew_plot,volume=True,style='starsandstripes',datetime_format=' %d-%m',alines= 
two_points,addplot=apdict\
,xrotation=45,title=(stock),type='candle',\
ylabel='ROC5= '+(ROC5) +' ' +'ROC20= '+(ROC20)+ ' ' +'ROCmean= '+(ROCmean),figscale=1.5)

enter image description here

Upvotes: 0

Views: 460

Answers (1)

Yvar
Yvar

Reputation: 155

The problem was on weekends. The variable yesterday was bigger than the last index date. Therefore the last plotting date (lastDate) was smaller then the date (yesterday). Thanks a lot for your support.

Upvotes: 1

Related Questions