-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Report: #568
Comments
Please provide all of your input data that you passed into mpf.plot(). Thank you. |
Hi Daniel, please find below all the parameters I used within mpf.plot(). I imported mplfinance as mf mf.plot(datanew, **pnf_kwargs, style='starsandstripes', pnf_params=dict(box_size=pnf_box_size, reversal=pnf_reversal), return_calculated_values=cv) I defined pnf_box_size as 1% of last close price I have not modified or added anything else. Thank you ! |
Amit, |
This line of code: datanew = data1.set_index(['Date']).astype(float) makes no sense. mplfinance will fail because the index is not a datetime index. |
I am able to reproduce the chart you have posted here and the chart closely matches a chart that I can see on another system. However the other image you have posted here does not make sense to me given the data you have posted. Notice on this chart that it starts and ends in the month of October (where as the data is year-to-date: Jan 2022 to Oct 2022). If I ignore the first few months, the chart more closely resembles the mplfinance pnf chart, however not quite, possibly because the results depend in part on when the data starts. What evidence do you have that this chart is using the same data (it seems that it may not be). I did not personally write the code that calculates PNF for mplfinance, however I did test it agains some other systems at the time it was written and it did match. I don't much time to look into this now, however you are welcome to review the code here and see if you think it is correct. That said, you have not yet convinced me that this is not just a case of different input data to the different PNF charts. Let me know how you want to continue. I will help out in any way that I can to the extent that I have time. |
@amitgupta16033 I have re-written the mplfinance point-and-figure algorithm, and I am putting on the finishing touches and rewriting the regression tests, and hope to enter a PR for the corrected algorithm sometime in the next few days. I cannot compare the stockcharts.com results to mplfinance, but I have confirmed (for at least a dozen cases) that the corrected mplfinance algorithm matches the point and figure results on both Schwab and Bloomberg. Again, I hope to have the code updated in this repository in a few more days. Sorry for any inconvenience. |
Hi Daniel, Once again thank you for your response. I appreciate that you have invested time and effort in updating the logic. Honestly, I do not know much about python but I can help you with the Point and Figure logic (based on High/low/Close price). I can even help you with percentage/fixed box sizes for point and figure. Please let me know if I can help you with these ideas. I am eagerly waiting to work on the new update logic. Thanks again for working on this request. |
Amit, Thanks. If you specify the box size as a percentage, do you want to see a box size as a percent of (a) the most recent close price, (b) the average close price of the entire data set, or (c) something else? If seems to me, just glancing around, that most systems use the percent of the most recent close price. Is that what you expect? |
Yes Daniel, box size as a percent of the most recent close price. This is the most preferred approach. |
Rewrite (fix/correct) Point and Figure algorithm for #568
@amit7702 This should behave much better. One thing I did discover is that no two systems match each other exactly (because there are so many nuances as to how to run the algorith), however for a given chunk of time (say 6 months) and identical box sizes and reversal sizes, most of the chart should match relatively closely. The main differences between systems tend to be at the beginning of the chart, because that is where there appears to be the most variation in algorithms in terms of how to "kick start" the chart. Please let me know how the new mplfinance |
Thank you for fixing this. The plots are perfect. |
Hi,
The calculation of 'pnf_counts' is incorrect. Hence, leading to incorrect plotting. I am attaching the out of mplfinance as well the correct chart from 'Stockcharts.com'. Following parameters were used -
Box Size = 180
Reversal =3
Code excerpts -
data1 = data.loc[:, ['Date', 'Open', 'High', 'Low', 'Close', 'Volume']]
datanew = data1.set_index(['Date']).astype(float)
pnf_kwargs = dict(type='pnf', volume=True, figratio=(1, 1), figscale=5)
cv = {} # blank dict to hold return_calculated_values values
close_last_value = int(data1['Close'].iloc[-1])
pnf_box_size = round(close_last_value * 0.01)
print("Box_Size is - " + str(pnf_box_size))
pnf_reversal = 3
print("Reversal is - " + str(pnf_reversal))
mf.plot(datanew, **pnf_kwargs, style='starsandstripes', pnf_params=dict(box_size=pnf_box_size, reversal=pnf_reversal),
return_calculated_values=cv)
col_value = cv.get('pnf_counts')
print(col_value)
Could you please provide us a solution? I am also attaching images and for your reference.
https://drive.google.com/file/d/1vpa8e7mI3GGpQTnQdJE5YpLWyNWHh8Pu/view?usp=share_link
https://drive.google.com/file/d/1_ZpgnahDxZGLQpVIH2kNML_zBxLN_VqH/view?usp=share_link
https://docs.google.com/spreadsheets/d/16SpG7Waq19as98-5CnME9EyefPzdGoRG/edit?usp=share_link&ouid=115874185577837631247&rtpof=true&sd=true
The text was updated successfully, but these errors were encountered: