matplotlib / mplfinance

Financial Markets Data Visualization using Matplotlib
https://pypi.org/project/mplfinance/
Other
3.48k stars 613 forks source link

Highlighting candlestick patterns. #254

Open simonholzapfel opened 3 years ago

simonholzapfel commented 3 years ago

What is the best way to highlicht a pattern in a candlestick chart for example by changing their color. Any help is appreciated as I am new here and using this library for the first time.

fxhuhn commented 3 years ago

i use two horizontal lines for 4 candle narrow ranges and triangles for EMA/SMA breakouts.
Do you mean something like this?

fb_us

simonholzapfel commented 3 years ago

Well this could be a good alternative, but I had something like coloring the highlighted candlesticks with brighter colors in mind. Is that even possible?

DanielGoldfarb commented 3 years ago

@simonholzapfel

There is no "best way" to highlight a pattern. It's really just a matter of preference how you want to do it.

In terms of actually modifying the candle colors for some of the candles, mplfinance does not yet support this, but there is a suggestion here for an enhancement that would support doing so. The enhancement suggestion mentions ohlc bars, but it can also be made to work for candles.

A good workaround, for now, would be to use fill_between, or to overlay a marker symbol from a scatter plot, as shown in some of the examples below, but to put the marker directly on top of the candle(s) of interest.


Here are some examples of what some people have done:

  1. As Markus noted above: https://github.com/matplotlib/mplfinance/issues/254#issuecomment-685729260

  2. https://github.com/matplotlib/mplfinance/issues/97#issue-601609003

  3. https://user-images.githubusercontent.com/49436733/79945165-84a61500-846d-11ea-8d7c-ec3ac876bdd5.png

  4. https://user-images.githubusercontent.com/11164790/82761057-b04a5100-9dc5-11ea-93e2-dfba0ef00095.png

  5. https://user-images.githubusercontent.com/11164790/76273899-70a7aa80-6255-11ea-8636-f2cff10b3ba8.jpg

  6. fill_between example (from the plot cutomizations tutorial): image

  7. Example from the addplot tutorial

image

  1. Some examples from the [lines tutorial](https://github.com/matplotlib/mplfinance/blob/master/examples/using_lines.ipynb):

    image image image

fxhuhn commented 3 years ago

have not found any good suggestions for this. Parallel to this I am still working with colored dots below/on top, which can be noticed immediately.

ice_amd_us

simonholzapfel commented 3 years ago

i use two horizontal lines for 4 candle narrow ranges and triangles for EMA/SMA breakouts. Do you mean something like this?

fb_us

@fxhuhn I will use this as an alternative until the requested feature gets implemented, thank you for bringing up this solution! Could you please provide me a code example, so I can figure out how this works?