Charting Stocks/Forex for Technical Analysis Part 11 – Candlestick and Volume Chart in Matplotlib

Advertisements

This is the l lth video in the collection for supply rate analysis, teaching you exactly how to produce candle holder and quantity charts in matplotlib. The objective of the video clips in this series is to show you just how to configure your own charting and analysis of stocks or Forex.

This is valuable for you if you prepare to do any type of kind of algorithmic, high-frequency, or any kind of sort of automated trading.

Sentdex.com
Facebook.com/ sentdex.
Twitter.com/ sentdex.

I show You how I made $1,006 from $100, then $257,000 from $1,006 with Bitcoin and cryptocurrencies!

Related posts

23 Thoughts to “Charting Stocks/Forex for Technical Analysis Part 11 – Candlestick and Volume Chart in Matplotlib”

  1. Marcel Caraciolo

    Congrats for your tutorials but for replication purposes Where can I find the source code to better understand it ?

    Marcel

    1. sentdex

      Haven’t posted the code yet. Will eventually post it with the other codes on my website most likely.

  2. Isaac Miller

    Is it possible to set a default window size for the chart window? 

    1. sentdex

      Look into figsize()

    2. Isaac Miller

      @sentdex Perfect, thank you!

  3. Birone L

    Looks like you can use something like this to get the candle array:
    rowmaker = lambda row: (mdates.date2num(row[0]), row[1][0],
                            row[1][3], row[1][1],
                            row[1][2], row[1][4])
    candle_array = [rowmaker(row) for row in df.iterrows()]

    Where df.columns = Index([u’Open’, u’High’, u’Low’, u’Close’, u’Volume’, u’Adj Close’], dtype=’object’)

    iterows gives rows as a tuple; row[0] is index (here date as timestamp) , row[1] is a tuple containing the row values in same order as df.columns.

    So currently bit of a PIA to use with dataframes – but doable (with a bit of help from your tutorial)!

  4. Aliaksei Harbuz

    Hi. How I can make candlestick from intra-day stock data. I always have  mistake ‘unconverted data remains’

    1. sentdex

      Because intra-day data is reported in unix time, not a typical date stamp. Here’s a video that covers intra-day graphing: Python Charting Stocks part 31 – Graphing live intra-day stock prices

    2. Алексей Гарбуз

      @sentdex
       Thanks

  5. Gavin thompson

    Hey Harrison, great vids man I’m learning a lot. still need to watch your matplotlib tutorial vids as I have no clue what half this stuff means/ does but i got a queation for ya man. When I run the module this message pops up:

    Warning (from warnings module):
      File “C:Usersgthomp16Anacondalibsite-packagesmatplotlibfinance.py”, line 865
        mplDeprecation)
    MatplotlibDeprecationWarning: This function has been deprecated in 1.4 in favor of `candlestick_ochl`, which maintains the original argument order, or `candlestick_ohlc`, which uses the open-high-low-close order. This function will be removed in 1.5

    No idea what this means. I’m thinking it is because I’m using anaconda. 

    – Thanks man keep up the good work!

    1. sentdex

      It has to do with the version of matplotlib, and the function we’re using here (soon to be killed away).

    2. Cypherdude1

      @Gavin thompson It means the function “candlestick” is being replaced with “candlestick_ochl”. Go into the text of the program and replace all instances of “candlestick” with “candlestick_ochl” and you won’t get any more warnings.

      Strange how the interpreter doesn’t give the actual problem function name.

  6. Ayushman Gupta

    waaaaaaaaooooooooooo!!!!!!

  7. Charles Man

    Hey Harrison, I’ve been getting this error:

    Runtime error!

    Program: c:python27pythonw.exe

    This application has requested the runtime to terminate in an unusual way. Please contact the application’s support team for more information.

    Any idea what’s wrong, or how I can fix this?

  8. Jack Trahan

    Enjoying this series!

    I’m searching for a way to avoid the gaps on my chart caused by the market closures on the weekends. Any ideas on how to eliminate (step over) the weekend sections from my chart’s x-axis?

  9. Tao Ding

    Hi, when I put the mouse at the figure, the number showing at the bottom right for x is in number instead of date format. Any way to overcome this issue?

  10. # TagTippz

    If you get this error “from matplotlib.finance import candlestick
    ImportError: cannot import name candlestick” it’s because the module name has change from candlestick to _candlestick . from matplotlib.finance import _candlestick

  11. Kenny Potts

    After reading the docs, it looks like the matplotlib.dates datenum is the number of days since 0001-01-01 plus 1 day for a correction. Then it seems that you’re right you could then convert to unix. Still with current implementation, the only option is to hack around a bit.

  12. Tipsy River

    if you’re getting an error you due to matplotlib.finance getting removed soon, but don’t know what to do(error message instructions are unclear), you should:

    1) Go to https://github.com/matplotlib/mpl_finance to get the new finance module.

    2) Move *mpl_finance.py*(you don’t need the other files) to site packages directory, which probably is C:Python27Libsite-packagesmatplotlib.

    3) Now you can use *from matplotlib.mpl_finance import _candlestick*. Take note of the syntax change, you need the underscore before “candlestick” now.

  13. Krishnan Narayanan

    The best tutorial that I have been able to follow except for few hiccups. I am currently stuck in candlestick part since is has been deprecated. I have tried downloading the mpl_finance from git but that gives me problem. Is there any way you can shed some light on this?

    1. Rafa Jiménez Seibane

      Try with candlestick2_ochl or candlestick_ohlc.

  14. Andrew Olson

    Using:
    from mpl_finance import candlestick2_ohlc
    ex:
    candlestick2_ohlc(ax1, opens=openp, closes=close, highs=highp, lows=lowp, width=0.5, colorup=’g’, colordown=’r’, alpha=0.75)

    Stack Overflow ref: https://stackoverflow.com/questions/42373104/candlestick-ochl-graph

    repo: matplotlib/mpl_finance
    https://github.com/matplotlib/mpl_finance

Leave a Comment