Skip to content
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

When saving candle charts to file, the candles are red when should be green. why? #639

Open
TraderMan999 opened this issue Jul 3, 2023 · 13 comments
Labels
question Further information is requested

Comments

@TraderMan999
Copy link

TraderMan999 commented Jul 3, 2023

in think or swim for example, this is the difference between the "CANDLE" style and the "CANDLE TREND" style.

What it appears is happening in MPL Finance using the yahoo style is if the close is below the open then the candle is RED, EVEN IF the close is above the previous days close.

This is very confusing to me and i want to have the candle be green if it closes higher than the previous days close.

Any suggestions?

Here's an example:

https://ibb.co/25hgDLD

Code:

mpf.plot(data, type='candle', style='yahoo', title=title + charttitle + ' ' + keyDateForImageTitle, marketcolor_overrides=mco, savefig=savedPlotFileName,addplot=apd)

@TraderMan999 TraderMan999 added the question Further information is requested label Jul 3, 2023
@DanielGoldfarb
Copy link
Collaborator

Please provide the exact data and code used to generate the example plot, so that the questionable candle is 100% reproducible from the data and code.

@DanielGoldfarb
Copy link
Collaborator

DanielGoldfarb commented Jul 4, 2023

As a general rule, for all traditional candlestick charts, the color of a candle depends entirely on whether the Close for that candle is higher than the Open of the same candle (green) or whether the Close is lower than the Open (red), with no dependence on previous candles.

Within mplfinance styles, there is a parameter 'vcdopcod' which stands for "volume color depends on previous close on day," which happens to be True for style yahoo, however this only affects the volume bar colors and not the candle colors.

Additionally, mplfinance now supports type='hollow', aka type='hollow_and_filled', which differs from type='candle' in that the color of the candle does depend on the change from the previous Close, while the body of the candle is filled or hollow based on whether the Close is down from the Open, or up from the Open.

@TraderMan999
Copy link
Author

TraderMan999 commented Jul 7, 2023 via email

@DanielGoldfarb
Copy link
Collaborator

@TraderMan999
As mentioned, traditional candlestick charts are colored based on the difference between the open and the close for each candle, so you have two alternatives: (1) use hollow and filled candles, or (2) enhance mplfinance to accept a kwarg that says to color each candle based the difference between the candle's close and the previous candle's close. If you want to do (2), and are unsure how to do it, then I can guide you through the process.

@TraderMan999
Copy link
Author

TraderMan999 commented Jul 12, 2023 via email

@DanielGoldfarb
Copy link
Collaborator

@TraderMan999
I finally took the time to read thinkorswim and, from what I can tell, the CANDLE TREND Chart is exactly what mplfinance calls type='hollow'.

I suggest you try using type='hollow' in your call to mpf.plot(). That should give you exactly what thinkorswim describes as a Candle Trend Chart.

@TraderMan999
Copy link
Author

TraderMan999 commented Jul 12, 2023 via email

@TraderMan999
Copy link
Author

TraderMan999 commented Aug 4, 2023 via email

@DanielGoldfarb
Copy link
Collaborator

Now by default the times on the x axis are not what I want. I’d rather they show the 930 est open etc. Is there a way to change those to be the ones I want?

I don't know what you are asking. What exactly are you seeing? What exactly do you want to see instead?

@TraderMan999
Copy link
Author

TraderMan999 commented Aug 10, 2023 via email

@DanielGoldfarb
Copy link
Collaborator

@TraderMan999
The image you tried to attach does not show.
Do not reply by email. It does not work!

Rather go to GitHub.com and add your comment and images here

@TraderMan999
Copy link
Author

TraderMan999 commented Aug 10, 2023 via email

@DanielGoldfarb
Copy link
Collaborator

@TraderMan999

Posting to GitHub by email does NOT work (they have bugs).

You need to go directly to the issue on the github website and post there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants