matplotlib / matplotlib/mplfinance

PnF Reversal Bug

Open
#671 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
4.4k
Forks
678
PR merge metrics
No merged PRs in 30d

Description

Hi,

Firstly thanks for this awesome resource. This is my first time contributing to GitHub (I have much to learn re. push / pull / commit etc. thats for another day) so please be kind.

BUG:
I've been plotting pnf charts and experimenting with different reversal thresholds.
Regardless of variable submitted (tried 1-9) I always produce the same graph. Have tried with differenet slices of my dataframe, different box sizes etc. and the same behavior occurs.

Expected behavior:
Lower reversal thresholds should result in a noisier PnF chart. i.e more columns with less x's o's in the smallest.

Suspected Fix (I'm a noob so maybe way off):
Suspect the issue lies in -utils.py, _pnf_calculator, rows 1373 & 1395 which appear to reset the reverse threshold basd on: current_level +- 3* boxsize, where I think it should be "current_level +-'reverse' *boxsize", where reverse is passed into the function (row 1304 (default 3).

I think you may need to adjust with addition of "current reversal threshold" which calcs each time round the loop, based on retained reverse value (default 3) passed to the function as kwarg, if that makes sense?

Screenshot:
image

Trust this is of value to the community.
(In time I'll learn to contribute directly. One step at a time on my learning journey though...)
Best
W-Smurf

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the PnF chart with reversal values from 1 through 9 and compare the results. Inspect _pnf_calculator in utils.py, especially rows 1373 and 1395, and trace the reverse argument near row 1304. Done means changing the reversal threshold produces correspondingly different PnF charts.

Written by the indexing model from the issue text.

Assessment

Tech stack
matplotlib, python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.