Machine Learning and Pattern Recognition for Algorithmic Forex and Stock Trading: Intro

100 thoughts on “Machine Learning and Pattern Recognition for Algorithmic Forex and Stock Trading: Intro

  • Haha, it was just a pic I made. I've put it on the machine learning tutorial page on my website. About > Tutorials > Machine Learning and it is below the video.

  • hey, thanks for your really helpful video.  I have successfully downloaded python and numpy without any problems, but I have had problems getting matplotlib to run in python.

    I am running a 64 bit windows OS and have downloaded matplotlib from the recommended website ( and downloaded the  It should also be known that the version of Python which I downloaded was 2.7.6 (however I downloaded 2.7.5 and the same problem persisted)

    The error message I got was:
    ">>>import matplotlib
    Traceback (most recent call last):
       File"<stdin>", line 1, in <module>
       File "", line 111, in <module>
          raise ImportError("matplotlib requires dateuntil")
    ImportError: matplotlib requires dateuntil"

    Thanks for your help!

  • hi there whenever i type import matplotlib i get this message

     Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:Program Files (x86)libsite-p
    10, in <module>
        raise ImportError("matplotlib require
    ImportError: matplotlib requires dateutil

    any help??

  • Loving these vids Harrison. Please keep em coming especially the Python stuff, I'm learning loads here, just DEVOURING this channel ha ha!

  • Looks like a great tutorial. Do you teach how you are calculating 'sentdex' in this series ? If not, do you mind pointing to a url where you explain it ? 

  • seem like a real result ..i wish it .. i think that the file contain the actual & predicted value .. u should test ur result at real life forex data and trading .. then we all ll say " congratulations "

  • When I put in "import matplotlib" I got "Traceback <most recent call last>:
      File "<stdin>", line 1 , in <module>
      File "", line 105, in <module>
             Import six
    ImportError: No moudle names six

    Thanks in advance,

  • I get :

    >>> graphRawFX()

    Traceback (most recent call last):
      File "<pyshell#9>", line 1, in <module>
    NameError: name 'graphRawFX' is not defined

    My code is :

    import matplotlib
    import matplotlib.pyplot as plt
    import matplotlib.ticker as mticker
    import matplotlib.dates as mdates
    import numpy as np

    def graphRawFX():
        date,bid,ask = np.loadtxt('GBPUSD1d.txt', unpack=True,
                                 delimiter = ',',
        fig = plt.figure(figsize=(10,7))
        ax1 = plt.subplot2grid((40,40), (0,0), rowspan=40, colspan=40)

        ax1.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H:%M:%S'))

    what should I do now?


  • GUYS!!!!! To get Matplotlib to work you will need install ALL of these from the website he provided. 1) numpy 2)six and 3) python-Dateutil this will make it work 

  • similar to +Hema Al-Qady
    I get :

    >>> graphRawFX()

    Traceback (most recent call last):
      File "<pyshell#9>", line 1, in <module>
    NameError: name 'graphRawFX' is not defined

    It shows that error if I try calling it in the terminal, however if I place a call to graphRawFX() in my script, it runs

  • What are the pre requisites for this video series? What other video series should I have watched before this one to clearly understand it?
    Thanks in advance.

  • Traceback (most recent call last):
      File "<pyshell#1>", line 1, in <module>
      File "C:/Python27/", line 10, in graphRawFX
      File "", line 737, in loadtxt
        fh = iter(open(fname, 'U'))
    IOError: [Errno 2] No such file or directory: 'GBPUSd1.txt'

    Im guessing my txt file is not in the directory, can someone tell me where to find the directory to put the files?

  • I have numpy, matplotlib and sklearn loaded in the pyhton27 directory on windows 8.1, but I can't seem to import them

    I get errror: no module name numpy, or matplotlib   what is the mater?

  • Hello there. You've got a great series of tutorials, kudos ! What I'm looking for though, and that't the reason I looked in this series, is how to mine Forex data. Do you have a relevant tutorial somewhere or any suggestions as to where/what to look? Thanks and all the best, you're awesome and inspiring ! Keep it up.

  • I did all what you said, but in the result, when I print "import matplotlib" python said that it requires dateutil
    I found this package, but after that I don't know what to do
    I mean I tried to put it in the directory of python – nothing
    another action which I found in the Internet was to install via pip – this one I didn't understand
    please help me, I really want to study your course but this problem doesn't allow me to do this
    Thank you

  • Having trouble downloading and installing the .whl files.  Gohlke almost exlusively uses them now, no .exe.

  • Hey, if i try to import matplotlib in python an error occurs 'matepltlib requires dateutil' how can i fix that ? Import numpy actually works. I have version 2.7.10 of Phyton.
    Greets from Germany

  • Does anyone know any other good channels that has great videos for machine learning? Thank you in advance!

  • my god this seem impossible.
    is there any clear documentation of steps to install on linux as well as win 8.1

    I have put numpy and pandas into site-packages but still no Import?

    how can one learn with nothing but compugeek speak

    should be simple and not need PHD in Hindi to understand

  • this is all very cryptic..
    thanks for the advice

    I installed Anaconda after spending more than 6 hours in attempts to load modules in python.
    Anaconda works on my windows machine

    I will try different methods for linux, and windows after I get more comfortable with the modules; numpy, pandas, and matplotlib

  • after I download the data in my desktop, I can not use this code" date,bid,ask = np.loadtxt('GBPUSD1d.txt' " like you. I am a greenhand ,please tell me how

  • How can you so certainly state that backtesting on all available data, is a bad method to judge whether or not that strategi will work or not in the future?

  • Do you have a tut for machine learning on robotics? Maybe a general understanding on the topic. Any link would suffice.

  • Sir,
    I have been following your tutorials.I have come up with following doubts in doing so.Firstly
    can you please explain what is it that we are getting in output (on
    video 6 and 7). I am unable to understand the pattern that we are
    getting. We get 10 values when we print patternFinder() function. So
    what does those values imply?Also what is currentPoint that we are printing?
    Please reply ASAPThank You Sir!

  • Hello, I have 64 bit Win7 OS, I am finding problem in importing, Numpy and matplotlib. Could you please help me. Thanks

  • +sentdex 1. please suggest me some book or any paper where I can learn about same approach of stock and forex trade predicitions.
    2. If not then can you explain my previous queries?

  • Hello, I am having difficulties installing the matplotlib. I am guessing it is because the version I am installing is a much older version? Please help me out?

  • Guys, i'm a total noob. I follow every step but when i got to the maplotbid website theres no option to download the file. what can I do?

  • Hey, thanks for the tutorials, they're great.
    Do you recommend watching these tutorials in any sequence? i.e value investing then machine learning etc..?

  • Hi, I found you release a new tutorial relate to machine learning, is there any relation? Which one should be select first? Thanks!

  • Hey, thanks for the tutorial. Wanted to ask: do you use these algorithmic strategies when trading your self and if so, have you been more successful than standard trading?

  • Hi Sentdex, there are 2 series of machine learning you uploaded, one is this one, the other is the Sci-kit one. So which one should I look at first?

  • I keep getting 'invalid syntax' error on line 12:

    File "<ipython-input-9-cdc0fdcbe767>", line 12
    fig = plt.figure(figsize=(10,7))
    SyntaxError: invalid syntax

    I've made sure my code matches every line in the video all packages installed.
    Could this be an Anaconda issue?

  • Hi, i am finding an startup problem in understanding the tutorial,
    can you give me a straight-forward answer on choosing the predictors and target for Forex data( date, bid, ask),
    i am quite finding difficult to knowing about what should we predict in forex data.. thanks .

  • where did you find the GBPUSD files? did you simply download them from a stock website? with the info of the file in such specific order?

  • Hi sentdex. I've noticed that this series is from 2013. Is there an updated version I should be watching (you have a 2015 machine learning series) or is this the best series for machine learning and stocks.

  • for python 3.6, use bytespdate2num instead of strpdates2num , see

  • People are getting confuse on what to choose, and what is the best, with the uncountable number of apps and huge amounts of information available on Binary Options trading. I guess I can help you with this. I have been using one great app (Link here ) for over a year now, and I don’t need to worry about a thing anymore. It takes care of all my trading, within my given pre-set instructions. And above everything, it is for free. All you need to do is sign up and download it. Then follow some simple instructions and get going.

  • Hi Sentdex, I tried to download the package 'qsforex' but wasn't able to do so. I tried downloading using pip and searched it on the website you have mentioned ( the unofficial windows binaries for python packages) but didn't found the 'qsforex' package. Can you please tell the procedure to download it ??

  • on the stock exchange, i.e made available on the stock exchange to buy and sell. follow for signals

  • hi sentdex
    i am trying to import numpy and matplotlib but giving me error no module named numpy. i have downloaded . whl files.plz help i am rookie in coding

  • I and my family was in pains trading with forex, and forex made us run at lost but when we discovered Mr. BAILEY strategy our family business become a great business bringing much income and profit of 98%. thanks to Bailey strategy. [email protected] com

  • Thank you, excellent channel!
    Question from my side – you are an expert in data science & python, do you use it to invest your own/anyone else's money in stocks/forex/crypto?

  • Good one !!
    Get Free Signals and Improve your Trading –
    Check this amazing indicator as well from –
    We provide GREAT EA services too !!?

  • Great series +sentdex, and thank you for the free lessons!

    In all fairness to those who followed this entire series and still think this was a tutorial on how to copy code, then easy money, think again. The core concepts, techniques, tools, and steps of reasoning are the true gold and creative empowerment.

    A couple things I'm interested in knowing and (my humble) constructive pieces of criticism:
    – like +dagharr2 i'd also like to see some abstraction, maybe even account for new tick data and desired predictions based on a future time.
    – you mentioned at the start that traders use fancy names for these patterns. how about a vid on pseudo code dissections of these patterns?
    – how can these patterns be applied or considered in NN's?
    – can you talk about any experience you have with Pine Script ( and maybe walkthrough a strategy test or two?
    – can you target these kinds of vids to more code-oriented people? some of the beginner explanation stuff takes away from the breadth and brevity of your content.

    Keep it rock'n!

  • Hi – just trying to get started and failed to download matplotlib or numpy. neither seem to be quite as video. Have managed to download Python v 2.7. I am W10 (Pro). I follow the links
    and find myself with a command 'python -mpip install -U pip'. I tried this in the Python command line but not accepted.
    Just need to get the basics correct to make any progress

  • I can't get these things to download and install properly, except Python??? "pip" install – throws an error?? Anyone?

  • In the Forex field now after numerous year I have turned into the best performing pioneer or trader, and get a kick out of the chance to give the preferred standpoint to my broker Forex4you who give each imperative strategies, systems, administrations, rule whatever I require I get them on ideal time. In particular they are amicable as they generally endeavor to give me the best things to wind up effective.

  • Hello sentdex. First I would like to congratulate you on your channel which I think is the best and most complete I have seen about Python. I would like to ask you if it is possible for a retail trader to be profitable in algorithmic trading because I understand that many Hedge Funds have at their service brilliant mathematicians and programmers like you with a level of knowledge that very few people on the planet can reach, in addition to having millions of dollars in infrastructure. What has been your personal experience on this subject and do you think it is really possible to achieve it? Thank you very much in advance

  • Hello there , thanks for your video ,im studing quantitatif finance and i need please some PDF and more information about trading using machine learning, and thanks

  • Hi Sentdex, I just understood what exactly you are trying to do with the data at around the 7th video in this series.

    I think your first video (here) does not explain clearly the strategy you are going to use in the rest of the series. For your future series (or this series), I suggest that you give an outline of the strategy so that your audience get the big picture. It will help your audience to follow your codes. Overall, I really enjoyed this series so far. Please, keep up the good work.

  • For anybody starting this series… I wrote this code in Python, and then re-wrote it in NodeJS (i.e. JavaScript) using python-shell for MatPlotLib. The final code runs way faster in NodeJS. I'm running the 1month data in NodeJS (using more than 800,000 patterns in the searches) as fast as Python runs the 1 day data (using only 30,000 patterns). I wish people moved away from Python for machine learning.

  • There's now a source of forex data for training machine learning algorithms in AWS called Hello Forex. You can find it in the AWS marketplace by searching for "forex"

  • Any change this pattern recognition code is available in python 3?. I am very
    new to python and trying to figure out the bugs is well…a job and a half

Leave a Reply

Your email address will not be published. Required fields are marked *