Skip to content

Add Point and Figure parameter to customize number of boxes needed to reverse the trend #370

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

Merged
merged 10 commits into from
Apr 22, 2021

Conversation

coffincw
Copy link
Collaborator

@coffincw coffincw commented Apr 5, 2021

The reversal was previously configured to be two boxes. With this new parameter, you can customize the reversal value as long as it's >= 2 and the product of the box_size and the reversal does not exceed 30% of the close price range of the dataset.

Here is an example:
mpf.plot(df,type='pnf',pnf_params=dict(box_size='atr',atr_length='total', reversal=3),mav=(4,6,8),volume=True)

reversal param example

Closes #368

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Apr 5, 2021

@coffincw
Caleb, Can you explain to me why we cannot support reversal=1 ?

I observed on the Bloomberg system that they allow reversal to be any integer from 1 to 9.

I also observed that, for some charts, when the reversal amount gets large (for example reversal=7, or 8 or 9) then the chart displays only a single column, or a just a few columns, and the charts for reversal=7 or 8 or 9 are all identical. Other charts do show some difference for the larger reversal settings. (Apparently the behavior depends at least somewhat on the data itself).

At any rate, being very much a novice myself at PnF charts, I would like to understand the exact nature of the limitations at both the low and the high end of possible reversal settings. Thanks. --Daniel

@coffincw
Copy link
Collaborator Author

coffincw commented Apr 6, 2021

@coffincw
Caleb, Can you explain to me why we cannot support reversal=1 ?

I observed on the Bloomberg system that they allow reversal to be any integer from 1 to 9.

I also observed that, for some charts, when the reversal amount gets large (for example reversal=7, or 8 or 9) then the chart displays only a single column, or a just a few columns, and the charts for reversal=7 or 8 or 9 are all identical. Other charts do show some difference for the larger reversal settings. (Apparently the behavior depends at least somewhat on the data itself).

At any rate, being very much a novice myself at PnF charts, I would like to understand the exact nature of the limitations at both the low and the high end of possible reversal settings. Thanks. --Daniel

@DanielGoldfarb I actually wasn't sure whether the existing reversal value was 1 or 2 since it requires two full boxes of price movement in the opposite direction to switch the trend direction.

reversal example

But since Bloomberg considers this to be reversal =1 I can easily adjust the values.

Regarding the upper limitations of the reversal value I settled on limiting the brick_size * reversal to be < 30% of the closing range, but if Bloombergs system allows reversal periods 1-9 we should probably go with that too.

Let me know what you think.

@DanielGoldfarb
Copy link
Collaborator

Caleb,
Please try allowing reversal periods 1-9 and test several different cases of data. As long as there are no exceptions raised, and the plot appears reasonable, I see no reason not to allow it. Please let me know if you run into any issues. When you are done, I will install from your fork onto my local machine and do some testing myself.
Thanks. --Daniel

@coffincw
Copy link
Collaborator Author

Caleb,
Please try allowing reversal periods 1-9 and test several different cases of data. As long as there are no exceptions raised, and the plot appears reasonable, I see no reason not to allow it. Please let me know if you run into any issues. When you are done, I will install from your fork onto my local machine and do some testing myself.
Thanks. --Daniel

Allowed for reversal values of 1-9, but I found a new bug while testing. I'm hoping to have some time to take a look at it in the next few days.

@DanielGoldfarb
Copy link
Collaborator

Thanks. Looking forward to it.

Previous implementation didn't account for the movement after the last reversal.  This led to issues with both the final box value and the final column volume data.  This change adds logic to track any further movement (volume and box) in the same signed direction after the final reversal and adds it to the last box column after the clean data loop.
@coffincw
Copy link
Collaborator Author

It's good to fork and test. Let me know if you run into any issues.

@DanielGoldfarb DanielGoldfarb merged commit 43600c3 into matplotlib:master Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Point and figure [pnf] - Reversal param
2 participants