A Look into Machine Learning for Technical Analysis
Brief and Background
GDA’s R&D lab is conducting gap analyses of existing solutions regarding the application of machine learning to technical analysis. This research sprint specifically explores three topics of interest to this venture.
Technical analysis is a trading discipline by which investors analyse chart patterns visually to identify patterns which have previously shown to be indicative of certain price movements. Technical analysts have classified quite a number of patterns, generally pertaining to indicators of price trends, chart patterns, volume and momentum indicators, oscillators, moving averages and support and resistance levels.
Regarding the choice of machine learning algorithms, computer vision stands out as an immediately intuitive option. Traditionally, technical analysis is a visual endeavour in which a human trader manually identifies and classifies patterns on a visual chart. Thus, it makes sense that object detection and classification models would be well suited to doing the same, likely with a higher accuracy than a human user.
Our goal is to automate the detection of these patterns via machine learning, and to feed that data into live trading bots as one of several data points by which they will make trading decisions. In particular, we are aiming to identify patterns such as head-and-shoulders, rising wedge, Wyckoff accumulation and distribution, gartley patterns, and Fibonacci retracements — and ideally incorporate liquidity cluster data into these classifications.
TrendSpider is an automated technical analysis platform which leverages unique machine learning algorithms to detect chart patterns. Their services include:
Automated Trendline Detection
Automatic trendlines are drawn from reaction highs and lows, these remain visible until the price action moves beyond a threshold and is too far away to be linearly relevant. Solid trendlines represent a primary selected timeframe, while dashed trendlines represent secondary timeframes. This trendline functionality is customizable and allows for filtering via a range of tools, and custom formulae may be implemented to dictate the likelihood of a particular pattern’s classification.
In addition to automatic trendline detection, breakout detection is also automated and highlighted on charts whenever a candle crosses over a trendline.
Automated Fibonacci Retracements
The most meaningful Fibonacci retracements connections are drawn on each timeframe.
Candlestick Pattern Recognition
In addition to chart pattern functionalities, TrendSpider also offers pattern recognition for over 100 different candlestick formations.
Automated Gap Detection
A user can optionally specify that the system avoids drawing trendlines across price gaps, which generally occur due to news events such as rumours, unexpected reports etc. — and would likely skew data.
Truth in Analysis Timestamp
Chart analysis is timestamped and recorded, red lines update each time a user changes an analysis, yellow lines are locked at the current point in time.
Anchored Volume by Price
Heatmaps are generated to indicate volume across price levels.
Horizontal Support and Resistance
Additionally, heatmaps are generated to indicate support and resistance levels — these can be thought of as the sum of all trendlines and include horizontal heat maps, as well as depth and trend heatmaps.
Users can set alerts for automatic monitoring of technical indicators, chart patterns or drawings across charts and multiple timeframes.
TrendSpider has introduced a unique framework for chart representation, Raindrops. These are similar to candlesticks, but focus on market sentiment and volume. Intended primarily to indicate volume movement, each raindrop consists of two volume histograms, one for each half of the time period.
A human-friendly volume profile chart
by Ruslan Lagutin, Co-Founder and CTO, TrendSpider
This visualisation may be quite useful for elegantly incorporating more data into computer vision analysis without overcomplicating the image — an aspect of the problem which is quite important, and will be discussed later in this article.
Digital Asset Integration
TrendSpider is already primed and operational across 157 cryptocurrency exchanges, covering over 21,000 assets.
TrendSpider offers a chart based backtesting tool.
They also allow users to define their own, or use existing chart scanning strategies.
TrendSpider appears to be a capable solution, and a good candidate framework for building our solution upon.
The next service explored in this sprint, Tickeron, offers trading and analysis solutions using artificial intelligence and natural language processing across various markets, including cryptocurrencies. Their services include:
Tickeron has implemented a rather innovative system for technical analysis, a search engine through which a user can specify patterns to be identified via machine learning algorithms, which is then searched for across multiple charts and presented. The user can tweak this search, adjusting the confidence level and distance to target.
Stochastic and RSI Detection
Using their ‘A.I.dvisor’, Tickeron’s services allow for the detection of Relative Strength Index (RSI) and Stochastic oscillators for gauging asset momentum.
AI Trading Bots
Tickeron’s AI Robots make use of the site’s other features such as the pattern search engines to make trades with buy, sell, stop loss and trailing stops. These bots can also be used simply to provide alerts to the user.
Tickeron’s search engine functions are quite interesting and definitely warrant inquiry.
Trading via Image Classification — J.P. Morgan
Lastly, we will look at a research paper conducted by Naftali Cohen, Tucker Balch and Manuela Veloso of J.P. Morgan’s AI Research branch. This paper covered computer vision for stock chart analysis on the S&P 500.
Their study looked at three binary indicators:
Bollinger Bands (BB) crossing:
- 2 bands of 20 day moving standard deviations
- Buy signal: when the price crosses over the lower 20 day moving standard deviation
Moving Average Convergence Divergence (MACD) crossing:
- 26 day short and long exponential moving averages (EMA)
- Buy signal: 9 day EMA ‘crosses above’
Relative Strength Index (RSI) crossing:
- RSI oscillator summarizes the magnitude of recent price changes to evaluate overbuying and overselling — asset momentum
- Out of 100
- Signals: oversold/overbought RSI are standardly 30/70, buy when RSI crosses above 30 (overselling)
They used 5000 samples per class, per indicator — 10,000 images per trigger. Images were cropped according to the number of effective trading days their respective triggers consider. Each sample has 80–108 features depending on the size of the window required to compute the label:
- BB crossing: 4x20
- MACD crossing: 4x26
- RSI: 4x27
Images were labelled according to trading opportunities, and trading volume information was incorporated into the chart’s candlesticks — reminiscent of TrendSpider’s Raindrops.
A key area of interest they discussed was that of image resolution. Higher resolutions can lead to pixelation being amplified in the feature space, which introduces noise and can skew predictions. As such, the image resolution was varied on a logarithmic scale and output accuracy was tested over the following machine learning classifiers:
- Logistic Regression
- Gaussian Naive-Bayes
- Linear Discriminant Analysis
- Quadratic Discriminant Analysis
- Gaussian Process
- KNearest Neighbors
- Linear SVM, RBF SVM
- Deep Neural Net
- Decision Trees
- Random Forest
- Extra Randomized Forest
- Ada Boost
- Gradient Boosting
- Convolutional Neural Net
A Lanzcos filter was used for downscaling as an anti-aliasing solution, while preventing sharpness. A 30x30 pixel resolution was found to be ideal.
As the researchers expected, MACD underperformed on account of its inherent complexity. The best performing data used only close data as a timeseries line plot, however, this difference was only marginal between those which incorporated OHLC (candlesticks) as we can see in the following graphs:
This paper strongly emphasised the importance of data visualisation in computer vision for chart analysis. A proper graphical representation is required to capture the full complexity of the data. Though they did find that linear time series work well even at low resolutions.
A major point discussed was their realisation of the importance of time dependency in graphical representation as to whether or not time-dependent signals can be detected in static images.
A time series goes from left to right, in the case of technical analysis, more recent data points on the right side of the chart are generally more significant to the model. The authors proposed two methods of incorporating this notion.
Using labels to attribute a notion of time to data points
- Labelling candlesticks using three algorithms to compute a time-dependent function, encapsulating a corresponding notion of time
- Using this, cross triggers will always trigger because of the last few data points, restricting the model from detecting an irrelevant cross in the past
Augmenting images with sequential features
- They also tried varying the width of the candlestick boxes linearly and overlaying close values on each candlestick to give a sense of time — smaller candlesticks were further into the past and vice versa
- This method was however considered less effective than labelling
We are continually researching this topic and will release more articles when we find new information to share. Please stay tuned and consider following us to never miss an update.