mplfinance icon indicating copy to clipboard operation
mplfinance copied to clipboard

PNF return_calculated_values --> miny / maxy not correct

Open Pipsopath opened this issue 1 year ago • 5 comments

I have noticed the miny / maxy might not be correct in the return_calculated_values of PNF (maybe in renko as well?)

The returned values:

miny 137.33999633789065 maxy 181.83999633789065

The chart:

pnf chart

Further, how is minx and maxx to be interpreted, as the x-achis is a timeline, but the values are decimal? minx -0.9777777777777777 maxx 44.977777777777774

Pipsopath avatar Jun 07 '23 11:06 Pipsopath

minx,maxx to be interpreted as the "column number" that is furthest to the left and furthest to right, respectively, on the x-axis. (In your example, the actual first column may be plotted at approximately 0.0, the x-axis starts at -0.97). The actual dates (for the columns) are returned as ['pnf_dates' ] in the calculated values dict, and thus the minx date and maxx date would be the first and last elements of that list.

will look into the miny,maxy issue.

DanielGoldfarb avatar Jun 07 '23 12:06 DanielGoldfarb

Another issue, which I now relate to this observation is, that if i plot as tight_layout, then it doesn't plot the complete range. I guess this is an resulting error from the wrong miny and maxy:

tight_layout = true pnf chart - tight

tight_layout = false pnf chart

Pipsopath avatar Jun 07 '23 12:06 Pipsopath

hmm. yes, that's a problem. the type of matplotlib axis objects that mplfinance uses do not support matplotlib's tight_layout, therefore mplfinance internally implements its own tight_layout, and obviously the existing algorithm doesn't work correctly for pnf and renko plots. as you mentioned, this probably related (whole or in part) to the calculation of min and max y.

DanielGoldfarb avatar Jun 07 '23 12:06 DanielGoldfarb

I am unable to reproduce the maxy,miny and tight_layout issue. Perhaps it is data related. Can you please post your data as a csv file, and code, to reproduce the above plots?

DanielGoldfarb avatar Jun 07 '23 21:06 DanielGoldfarb

Please find attached the code and the data. Sorry, could not figure out how to provide the code in a proper way than as text file

pnf plot bug.txt _AAPL_H1.txt

Pipsopath avatar Jun 08 '23 09:06 Pipsopath