Errata

Mastering Financial Pattern Recognition

Errata for Mastering Financial Pattern Recognition

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Page Chapter 1
Installing the environment

It should be stated up front that though there is a Mac version of MetaTrader5, the python library only works on Windows. It requires an emulator on a Mac. Not sure why the company decided a Mac version of the software was warranted but not a library?

Note from the Author or Editor:
Yes, I believe we can include a note that states: Even though there is a MAC version of MetaTrader5, the python library only works on Windows. It requires an emulator on a Mac. For Mac users, you may also try the manual import way seen later in the chapter.

Doug Whitehead  Aug 17, 2022  Oct 18, 2022
Page chapter 7
-

"If the current high equals the previous high, the current low equals the previous low, and the candlestick from two periods ago is bullish, then print 1 in the next row as a representation of a buy signal on the open price."

"bullish" should be "bearish" instead.

Note from the Author or Editor:
The Errata is confirmed. The conditions of the Doppelganger section in chapter 7 should be as follows:

"""

Algorithmically, the real conditions are as follows:

* If the current high equals the previous high, the current low equals the previous low, and the candlestick from two periods ago is bearish, then print 1 in the next row as a representation of a buy signal on the open price.

* If the current high equals the previous high, the current low equals the previous low, and the candlestick from two periods ago is bullish, then print −1 in the next row as a representation of a sell signal on the open price.


"""

Therefore, the two bullet points will have the words bullish and bearish switched so that the first bullet point has the word bearish and the second bullet point has the word bullish (As is the proposed change in above).

Paul  Nov 19, 2022 
Page Several sections
NA

I am posting this errata for an O'Reilly customer who has general feedback and several questions. I'm including their gmail address but posting anonymously so it is not publicly visible. They said:

==============================
Can I please get clarity on how to use the code in this book.

Book: Mastering Financial Pattern Recognition by Sofien Kaabar
ISBN: 978-1-098-12047-4
I use Python 3.10.4 (64 bit) - VSCode

The book first discusses the main code to import data, run tests, plot data etc.
Chart plotting is incomplete: plt.grid() does not plot a chart but only plt.show() will actually plot the chart. Why is "plt.grid()" used?

Then the book start going in some simple data analysis. Great!!

But now the first part of the book is not incorporated in getting the analysis to work. The author of the book maybe now assume you need to code the whole thing again to get it working. Why is this?

Everytime I run any of the data analysis code it fails due to missing imports in the file. 
Must I import all the files myself or can you give a proper example?

I need a clear example on how to use the data analysis code together with the "Master_Function_MFPR.py" 

Note from the Author or Editor:
Hello,

Thank you for submitting your feedback. The chart plotting may differ from one version of Python to another and from interpreter to another. In my experience, using Spyder's latest version made the plot come out without the need to write plt.show(). Of course, this may change depending on the user and thank you for pointing that out. The plt.grid() function shows horizontal and vertical lines corresponding to regular intervals of time and value which makes the chart more interpretable.
Finally, yes, the master function must always be executed prior to the other code. It's like the engine needed to run the whole thing. This should have been better clarified in the book, apologies.
Thank you and please let me know if you need more info.
Best
Sofien

Anonymous  Dec 29, 2022 
Page Chapter4 The Three Candles Pattern (p.74)
#bearish pattern (Python code)

Original code :
#Bearish pattern
data[i, close_column] - data[i, open_column] > body and \
data[i - 1, close_column] - data[i - 1, open_column] > \
body and data[i - 2, close_column] - \
data[i - 2, open_column] > body and data[i, close_column] \

Suggest to change:
data[i, open_column] - data[i, close_column] > body and \
data[i - 1, open_column] - data[i - 1, close_column] > \
body and data[i - 2, open_column] - \
data[i - 2, close_column] > body and data[i, close_column] \

Reason:
close_price minus with open_price in bearish candle will result minus value that cannot to compare with positive body value.

Note from the Author or Editor:
Hello, the reader is right. This block of code is correct in Github but in the book, there's a minor technical mistake. Hence for the block of code of the three candles pattern,


Instead of:

--------
def signal(data, open_column, close_column, buy_column, sell_column):

data = add_column(data, 5)

for i in range(len(data)):

try:

# Bullish pattern
if data[i, close_column] - data[i, open_column] > body and \
data[i - 1, close_column] - data[i - 1, open_column] > \
body and data[i - 2, close_column] - \
data[i - 2, open_column] > body and data[i, close_column] > \
data[i - 1, close_column] and data[i - 1, close_column] > \
data[i - 2, close_column] and data[i - 2, close_column] > \
data[i - 3, close_column] and data[i, buy_column] == 0:

data[i + 1, buy_column] = 1

# Bearish pattern
elif data[i, close_column] - data[i, open_column] > body and \
data[i - 1, close_column] - data[i - 1, open_column] > \
body and data[i - 2, close_column] - \
data[i - 2, open_column] > body and data[i, close_column] \
< data[i - 1, close_column] and data[i - 1, close_column] \
< data[i - 2, close_column] and data[i - 2, close_column] \
< data[i - 3, close_column] and data[i, sell_column] == 0:

data[i + 1, sell_column] = -1

except IndexError:

pass
--------

It should be as follows:

--------
def signal(data, open_column, close_column, buy_column, sell_column):

data = add_column(data, 5)

for i in range(len(data)):

try:

# Bullish pattern
if data[i, close_column] - data[i, open_column] > body and \
data[i - 1, close_column] - data[i - 1, open_column] > body and \
data[i - 2, close_column] - data[i - 2, open_column] > body and \
data[i, close_column] > data[i - 1, close_column] and \
data[i - 1, close_column] > data[i - 2, close_column] and \
data[i - 2, close_column] > data[i - 3, close_column] and \
data[i, buy_column] == 0:

data[i + 1, buy_column] = 1

# Bearish pattern
elif data[i, open_column] - data[i, close_column] > body and \
data[i - 1, open_column] - data[i - 1, close_column] > body and \
data[i - 2, open_column] - data[i - 2, close_column] > body and \
data[i, close_column] < data[i - 1, close_column] and \
data[i - 1, close_column] < data[i - 2, close_column] and \
data[i - 2, close_column] < data[i - 3, close_column] and \
data[i, sell_column] == 0:

data[i + 1, sell_column] = -1

except IndexError:

pass

return data
--------

Thank you!

Sofien

Sukit Deeyiengyang  May 10, 2024