Reader small image

You're reading from  Getting Started with Forex Trading Using Python

Product typeBook
Published inMar 2023
PublisherPackt
ISBN-139781804616857
Edition1st Edition
Right arrow
Author (1)
Alex Krishtop
Alex Krishtop
author image
Alex Krishtop

Alexey Krishtop is a quantitative trader and researcher with 20 years of experience in developing automated trading solutions. He is currently the head of trading and research at Edgesense Technologies and CTO at ForexVox Ltd. He develops market models and trading algorithms for FX, commodities, and crypto. He was one of the first traders who started using Python as the ultimate environment for quantitative trading and suggested a few approaches to developing trading apps that, today, have become standard among many quant traders. He has worked as a director of education with the Algorithmic Traders Association, where he developed an exhaustive course in systematic and algo trading, which covers the worlds of both quantitative models and discretionary approaches.
Read more about Alex Krishtop

Right arrow

Technical Analysis and Its Implementation in Python

In the previous chapter, we considered fundamental factors and saw how they may impact market prices. We noted that, although such an impact may be significant and potentially quite lucrative for trading, most of the time, it’s difficult to suggest a quantitative model that could generate unambiguous trading rules (when to enter the market, to which direction, and when to exit it) that wouldn’t require human discretion. For clarity’s sake, let’s note that there exist various fully quantitative approaches to evaluating fundamental factors, even political ones, but they are based on complex cross-discipline subjects, such as semantic analysis, and thus require solid knowledge of respective sciences. Is it possible to avoid this complexity and find a method to analyze market behavior using only price data? Or, maybe, some additional data, but only in numeric form?

The answer is yes, and this kind of market...

Technical analysis – ideal for computing, but missing real market processes

The main idea that lies in the foundation of technical analysis, or TA for short, is that price includes everything in itself. From this standpoint, if we see a price movement up or down, large or small, we don’t really want to know the reason behind this movement; instead, we just acknowledge that it was caused by some fundamental factors and try to focus on the future price development in regard to the observed price movement only.

Of course, TA can analyze a series of data and not just a single data point. In this regard, TA studies help in identifying patterns or repeating sequences in price time series that bear resemblance to each other. TA suggests that if we observe a pattern that we already saw in the past, then the following price development will also be similar to what happened in the past; therefore, we can be prepared and exploit it.

With TA, we don’t want and don’...

Implementation of TA indicators in Python

I am sure you remember that any TA indicator uses a certain period as a parameter. This period means a number of data points that we take into consideration. To calculate an indicator on every bar, we start from the oldest one (the leftmost on the chart) and then move one by one, updating our dataset with each new bar.

Since we are talking about an absolutely essential thing that lies in the foundation of all TA, let me be very detailed here – probably too detailed – but I want to leave no place for ambiguity or misunderstanding in the following concepts and code samples.

Let’s start with the core concept of time series processing: the sliding window.

Sliding windows

Let’s go back to the example of a random walk (around bars and movies) that we considered in the previous section. The entire dataset, or historical data, consists of 10 data points:

S1 = {0.7, 2, 1.5, 0.3, 2.6, 1.1, 1.8, 0.45, 3.1, 2...

Summary

Well, it’s been a long and – I hope – interesting trip, so it’s time now to summarize what we learned.

Technical analysis assumes that price includes everything in itself and attempts to find repeating patterns of behavior, suggesting that the price action following a similar pattern will also be similar to what already happened in the past.

There are just four major classes of technical studies, despite their visual diversity at first glance: market speed or momentum, digital filters, range, and volatility. Each type of study can be used to detect a certain situation in the market, but none of them can produce a ready profitable trading strategy on its own.

The cornerstone of all technical studies is the sliding window, and the bane of technical trading is peeking ahead during development and testing. Using queues to emulate incoming data streams and to organize sliding windows solves the problem of peeking ahead once and for all.

Besides...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Getting Started with Forex Trading Using Python
Published in: Mar 2023Publisher: PacktISBN-13: 9781804616857
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Alex Krishtop

Alexey Krishtop is a quantitative trader and researcher with 20 years of experience in developing automated trading solutions. He is currently the head of trading and research at Edgesense Technologies and CTO at ForexVox Ltd. He develops market models and trading algorithms for FX, commodities, and crypto. He was one of the first traders who started using Python as the ultimate environment for quantitative trading and suggested a few approaches to developing trading apps that, today, have become standard among many quant traders. He has worked as a director of education with the Algorithmic Traders Association, where he developed an exhaustive course in systematic and algo trading, which covers the worlds of both quantitative models and discretionary approaches.
Read more about Alex Krishtop