1. Introduction
The use of artificial intelligence (AI) in financial assets price forecasting and trading has become more and more frequent as the amount and speed of the flow of new financial data increased dramatically. Algorithms are used to analyze simultaneous multi-sourced data. Those systems are developed by market experts and are usually applied to stocks and currencies markets. The following research develops and tests such an AI system and applies it to the precious metals’ futures market. Precious metals have always been perceived by investors as a hedging tool against inflation (see, for example, [
1]) or stock market crashes. In the following research, we designed, optimized, and tested three algorithmic trading systems suitable for precious metal futures trading. Our long period of time data enables us to test the performance of our system over changing economic conditions. The technical analysis approach used here, commonly used by practitioners to trade stocks and foreign exchanges, relies on historical data for the sake of forecasting future prices. We used the particle swarm optimization (PSO) algorithm as our primary optimization tool because of its ability to handle multi-objective optimization simultaneously.
Many researchers have tried to prove the ability of such algorithmic trading systems to achieve abnormal returns for stocks, currencies, and indices. However, many researchers focus on stocks and foreign exchange and partly neglected commodity futures and especially precious metal futures. The following research aims to fill that gap with an insight into three algorithmic trading strategies that were programmed in accordance with the uniqueness of the precious metal financial markets. We use 20 years of daily futures data corresponding to five major precious metals, including gold, silver, copper, platinum, and palladium, to test three algorithmic trading strategies: linear regression (LR), Darvas boxes (DB), and Bollinger bands (BB). We followed [
2], that concluded that LR and DB could help traders predict Bitcoin short-term price trends. Our 20 years of data were split into 10 years of training and optimization and 10 years of testing the trading results. We found that it is possible to forecast short-term price trends of precious metals. Silver futures prices were found to be best forecasted by our systems, and platinum was the worst. Our system better forecasts price-up trends than downtrends for all examined techniques and commodities. Linear regression was found to be the best technique to forecast silver and gold prices, while the Bollinger band technique best fits palladium forecasting.
2. Literature Review
Our system is based on pattern recognition which is a developing AI field that helps us to understand different chaotic phenomena. [
3] argued that the applicability of Bayesian methods was greatly enhanced through the development of a range of approximate inference algorithms such as variational Bayes and expectation propagation. An important foundation for learning input–output mapping from a set of examples was presented by [
4]. They developed a theoretical framework for the approximation method based on regularization networks that are closely related to pattern recognition. Their methodologies included task-dependent clustering and dimensionality reduction. Other researchers provided an understanding of the mathematical concepts behind forecasting methods that are based on probabilistic derivations. [
5] provided a joint introduction to Gaussian processes (GP) and relevance vector machines (RVM-developed by [
6]). They found that RVMs allow the choice of more general basis functions, whereas the behavior of predictive variance is generally counterintuitive. [
7] examined the GP and RVM models and concluded that probabilistic models could produce predictive distributions instead of point predictions.
Most researchers that tried to explain precious metals prices have done so by linking the stock market to the precious metal market. [
8] explained that precious metal futures have higher returns when investor sentiment is pessimistic rather than optimistic. [
9] argued that the price of precious metals and their volatility are driven by shocks originating in the economic uncertainty and risk appetite of investors that prevail in the equity market. Other researchers focused on the interrelations between the prices of the leading precious metals. [
10] showed that precious metals were strongly correlated with each other in the last decade. [
11] documented that weekly changes in traders’ positions have a destabilizing impact on subsequent conditional volatility in gold, silver, and palladium futures markets.
Other researchers linked precious metals prices to each other and other commodities. [
12] examined spillover effects among six commodity futures markets and found that both gold and silver are information transmitters to other commodity futures markets. [
13] have examined the impact of oil price changes on precious metals prices. They identified the safe-haven nature of precious metals against an oil price drop.
Past researchers also attempted to construct AI systems to predict precious metals prices. [
14] proposed a model that combines the adaptive neuro-fuzzy inference system and genetic algorithm. [
15] discovered hidden patterns governing systems’ evolution. Unlike these attempts to predict precious metals prices, we designed algorithmic trading systems and tested their ability to predict precious metals prices.
3. Data and Methodologies
Our data consists of 20 years of daily data of open–closed, high–low prices of five precious metals futures. We used a lagged multi-dimension stepwise regression model to examine lagged correlations between the daily return of the examined precious metals, including autocorrelations, as described in Equation (1).
where:
= the daily return of gold, silver copper, platinum, and palladium,
is 1…3 days ago daily returns of gold, silver, copper, platinum, and palladium.
The results of this model enabled us to better understand short term autocorrelations of returns and lagged dependencies between the precious metals price movements and helped us design our trading systems.
3.1. Algorithmic Trading System
We designed our algorithmic trading system to report the actual trading results: net profit (NP), percent of profitable trades of all trades (PP), and the profit factor (PF). NP is the dollar value of the total net profit generated by the trading system, PP is the percentage number of winning trades out of the entire set of trades generated by the system, and PF is defined as gross profits divided by gross losses. We programmed three algorithmic systems based on three sophisticated trading technical tools and altered their configuration until we achieved maximum profitability in terms of NP and PF. The designed systems are based on three methodologies: linear regression, Darvas boxes, and Bollinger bands which are well-known technical formations that are commonly used to analyze investment opportunities for stock and currencies traders. We then optimized NP and PF by altering the setups behind our systems and splitting the system’s performance into long and short positions.
The complexity of our systems requires multi-objective optimization formulas. We selected particle swarm optimization (PSO), developed by Kennedy and Eberhart ([
16,
17]) as our primary optimization method. This methodology enabled us to train the system in the initial period and test it in the latter period. The 20 years of our examined period were split into two separate periods, 10 years of training and optimizing and 10 years of testing and reporting results. We started the process with a random trading setup that included the trading time frames and the various tools ingredients. Next, for each setup, we evaluated the desired fitness of the trading results to our predefined goals: Maximum NP, PF, and PP. We then compared each result to its former maximum and set a new maximum if needed. The process is described in Equation (2).
where Vid = the value of each setup, Rand = random number, Pid = the setups initial identification, and Pgd = the setups’ maximum identification.
Last, we looped the process using Equation (3) until the highest multiple objectives were achieved.
3.2. Linear Regression Strategy
Figure 1 demonstrate how we used the linear regressions technique for algorithmic trading platforms.
A linear regression strategy demands the length of time for the line formation and the span from that line that determines the entry and exit from the trading positions. The regression line in
Figure 1, for example, is based on 50 trading days when one standard deviation from that line determines the entry and exit points to the trading position. We started our PSO procedure with a random variable for both the daily time length and for the span that determined the actual entry and exits of trades. The system altered those variables in order to maximize our trading targets.
3.3. Darvas Boxes Strategy
Figure 2 show an example of an automated trading platform using Darvas boxes.
Figure 2 show how Darvas boxes are designed and how they generate a long and short signal. This algorithmic trading system assumes that the trader is always exposed to price shifts between long and short positions. Darvas boxes use the notation that deviation from overtime horizontal support and resistance lines can be used to construct a winning trading strategy. The idea is that the asset’s price should move within a specific box formation when no external news is provided and break formation when important news concerning the commodity is introduced to the financial markets. Boxes can be formed using any predetermined time frame according to the financial asset’s volatility. A high volatility financial asset demands a shorter time frame for box formation than a low volatility asset. The PSO process starts with a random number of days to construct the boxes and alter them to achieve better trading performances. Once the size and shape of the boxes are formed in the training period, it is used for the tested period for which performances are remeasured.
3.4. Bollinger Bands Strategy
Bollinger bands (BB) (developed by John Bollinger) use two standard deviations away from a simple moving average. The trading strategy demonstrated in
Figure 3 uses 14 days for the moving average calculation with the original two standard deviations. When the price of the commodity crosses the lower band, the system opens, a buy long order is placed, and when it crosses the upper band, a sell short order is generated.
The PSO procedures start with random setups for both the moving average and the standard deviations and optimize both particles of our trading system.
The three methodologies that were tested in this research are based on the pattern recognition of price movements of the precious metals. The LR tries to adjust a linear model (horizontal or diagonal) to the data and determine price direction through a deviation from that linear formation. The DB methodology works on a shorter-term formation of boxes that represent the horizontal support and resistance lines. A deviation from that formation can be used to identify price trends shifts and support trading decision making. The concept that lies behind the BB structure does not demand the identification of a predetermined formation but rather determines a zone in which the financial assets are expected to move within a specific time frame. A break-out of the price from the expected zone can indicate irregularities of movements and can be used to make profits.
4. Results
We start the results section by presenting 10 years of (until the end of April 2021) monthly and daily correlations matrix between the returns of the examined precious metals.
From
Table 1, we learn that all examine precious metal monthly returns are positively correlated. However, on a daily level, the correlations between the precious metals prices do not have the same sign. While gold and silver and copper and silver are negatively correlated, platinum and palladium and silver and platinum are positively correlated. We now apply to the daily data our designated multi-dimension regression model (Equation (1)), and report the results for the standard stepwise regression model is presented in
Table 2. This model enables us to better understand the one to three day lag dependencies of each metal to its previous price changes and to the other precious metals.
Table 2 show an interesting phenomenon, all precious metals’ current daily returns are negatively autocorrelated to their former days’ returns: gold and silver to their former three consecutive days returns, platinum to its two consecutive days returns, and copper and palladium to their single former day returns. In terms of interdependencies,
Table 2 exhibit that gold current daily returns are negatively affected by silver’s former days’ returns. However, silver’s current daily returns are positively correlated to gold’s returns two and three days ago. Platinum’s current daily returns were found to be positively affected by gold, silver, and palladium’s past returns. Palladium’s current daily return was found to be positively correlated to yesterday’s returns of silver and platinum and two days ago of gold’s returns. The observations described above about the precious metals’ daily autocorrelations helped us better understand the fluency of daily prices to construct our trading strategy. All the designed trading systems are based on daily trading data. However, because of the different nature of these strategies, the number of days used for each of them which is determined solely by the optimization process, is different. For example, the linear regression system needs more days than the other methodologies to construct its formations; therefore, the algorithm needs a higher number of days to analyze the price trends and produce profitable trading signals than the systems that are based on Darvas boxes and Bollinger bands which are more dynamic in nature and demand fewer days to achieve their best performances.
4.1. Linear Regression Trading Strategy
The linear regression strategy requires determining the number of days on which the linear regression line is formed. We start with a random number of days for each metal and optimize the trading results through our PSO system. The best trading results are summarized in
Table 3 and
Figure 4.
Table 3 and
Figure 4 demonstrate that the linear regression methodology best fits to the trade of silver, palladium, and gold and fits less to the trade of copper and platinum. The best setup for gold and silver trading systems is 38 days, for which the system generated USD 177,198 and USD 561,425 NP, respectively. For palladium, the best setup is 20 days achieving an NP of USD 235,950 with a PF of 1.30. In
Table 4, we split our trades into long and short trades to examine whether a difference in profitability will occur.
Table 4 indicate that the linear regression technique fits both long and short trades. However, it is a better strategy for long trades than for short trades for all the examined commodities. The difference in long and short trades is significant for all metals in terms of NP and PF. Silver, again, leads the other metals in both long and short trades, resulting in a PF of 1.8 for long trades and 1.55 for short trades.
4.2. Darvas Box Strategy
Darvas box strategy requires determining the number of days on which the system will build the boxes formations and deliver buy or sell signals. Again, we start with a random number of days and let our PSO system optimize our goal functions. The best trading results are summarized in
Table 5 and
Figure 5.
The trading results according to the Darvas boxes methodology described in
Table 5 and
Figure 5 show that this methodology, like the linear regression technique, best forecasts silver price trends than copper and gold, and it is less effective in forecasting future prices of platinum and palladium. Our system generated an NP of USD 319,200 for silver, with a PF of 1.55, using a 7-day setup. This setup was found to be useful also for gold and copper trading.
Table 6 divide all the trades into long and short trades using the optimized setups for each metal.
The table shows that for all five precious metals, the system again performed better for long trades than for short trades. Moreover, short trades have produced losses for gold, platinum, and palladium. The only precious metals for which the Darvas boxes technique fits both long and short trade are silver and copper. These results indicate that the system based on the Darvas boxes methodology can better predict positive future price trends than negative trends.
4.3. Bollinger Band Strategy
Table 7 summarize the results of the examined metals prices using the Bollinger band (BB) technique. This methodology calculates a moving average of a predetermined number of the trading day and contrasts the upper and lower bands using two standard deviations from that moving average. Using our PSO system, we optimized the trading results for each commodity in terms of NP, PP, and PF. The results are presented in
Table 7 and
Figure 6.
Table 7 and
Figure 6 indicate that BB best forecasts silver and palladium futures prices, and it is less effective for copper and platinum. Seven days was found to be the best setup for silver and palladium, while 13 days best fit the gold price forecast. It is worth noting that silver and palladium prices are more volatile than the other metals, as was demonstrated in
Table 1, resulting in relatively fewer preferred days setups for the BB methodology. The BB technique provided better percent of profitable (PP) results for all metals than the linear regression or the Darvas boxes techniques making it the lowest risk algorithmic trading system.
Table 8 split the trades for long and short trades.
Table 8 indicate that, again, the BB methodology also fits long than short trades better. This technique fails to predict the negative price trends of gold.
5. Summary and Implications
In this research, we examined the short-term behavior of five major precious metals and tried to determine whether prices can be predicted and traded accordingly to algorithmic trading systems. By using a multidimensional regression model, we found that all precious metals’ current daily returns are negatively autocorrelated to their former days’ returns. Gold and silver are negatively correlated to the former three consecutive days’ returns, platinum to two former days returns, and copper and palladium to a single former days’ returns. The model also identified lagged interdependencies among the examined metals. These findings helped us to better understand the daily price fluctuation of each metal and to improve the trading systems. The trading systems used three forecasts’ methodologies: linear regression (LR), Darvas boxes (DB), and Bollinger bands (BB). Our data consisted of 20 years of daily price data concerning five precious metals futures: gold, silver, copper, platinum, and palladium. During that long time, the precious metals experienced high and low price volatility under different economic conditions. We used PSO as our primary optimization tool because of the complexity of our target function. For that optimization process, we split our data into two equal time periods, 10 years of training and optimization of our system and 10 years of testing and reporting results.
We found that it is possible to forecast the short-term price trends of all the examined precious metals. Moreover, we documented that our system better forecasts price-up trends than downtrends for all examined techniques and commodities. Our systems best predict silver future prices and forecasts platinum prices the worst. Linear regression was found to be the best forecasting technique for silver and gold price trends, while the Bollinger band technique best fits palladium. This research has proven that precious metals prices can be predicted using an algorithmic trading system and, therefore, can be used by researchers, traders, and hedgers.