The site of has contributed the most to the market scholars and practitioners by providing the very details of the most notable stock markets of the world freely. So in this study the mentioned database was the foundation. There is no limitation in access to the site, while in this study the extracted data were applied to investigate the technique of Moving Average structurally on a practical and real base. Because of the fact that the data are real everyone has a better sense to the results.

Availability and requirements

• Project name: My simple technical analysis.

• Project home page: -

• Operating system(s): Windows XP (Professional)

• Programming language: Matlab

• Other requirements: Microsoft Excel

• License: -

• Any restrictions to use by non-academics: No


Developing a model for predicting returns in order to make investment decisions is an important goal for academics and practitioners. Typically, the financial services industry relies on three main approaches to make investment decisions: the fundamental approach that uses fundamental economic principles to form portfolios, the TA approach, and the mathematical approach that is based on mathematical models (Leigh et al. [2002]). The first two approaches dominate practice because of their applicability; however, our paper focuses on TA approach. Blanchet-Scalliet et al. ([2007]), from the perspective of mathematical models, justify this very well and say it is impossible to specify and calibrate mathematical models that can capture all the sources of parameter instability during a long time interval if one considers a non-stationary economy.

TA remains very popular despite a lack of theoretical foundation and has been used by professional investors for more than a century (Blanchet-Scalliet et al. [2007]), and there is a little dispute that it is very common among practitioners (Roberts [2005]). Brorsen and Irwin ([1987]) report that only 2 of 21 large commodity fund managers surveyed used no objective TA. According to Cesari and Cremonini ([2003]), TA is perhaps the oldest device designed to beat the market. It has a secular history given that its origins can be traced to the seminal articles published by Charles H. Dow in the Wall Street Journal between 1900 and 1902, and its basic concepts became popular after the contributions of Hamilton ([1922]) and Rhea ([1932]).

The definitions of TA that have been presented in the literature by different scholars are almost the same. Tian et al. ([2002]) know TA as a search for recurrent and predictable patterns in stock prices. Dourra and Siy ([2002]) define it as an attempt to predict future stock price movements by analyzing the past sequence of stock prices because of the fact that forces of supply and demand affect those prices. They believe that it dismisses such factors as the fiscal policy of the government, economic environment, industry trends, and political events as being irrelevant in attempting to predict future stock prices. Roberts ([2005]) knows it as a broad collection of methods and strategies which attempts to forecast future prices on the basis of past prices or other observable market statistics, such as volume or open interest. According to Wang and Chan ([2007]), TA studies records or charts of past stock prices, hoping to identify patterns that can be exploited to achieve excess profits and so many other definitions that imply the same meanings and implications.

TA literature can be divided into two periods. The first period encompasses decades of 60s and 70s, while the second period cover 80s and after. Some results obtained during the first period like Alexander ([1964]) and Fama and Blume ([1966]) supported the impracticability of applying TA for prediction of the future. Van Horne and Parker ([1967]) and James ([1968]) examine MA rules and indicated that this trading strategy did not yield returns that were superior to a buy-and-hold strategy even before transaction costs were taken into account. Over the succeeding years, many researchers like Jensen and Benington ([1970]) reached similar conclusions, especially when transactions costs were included in the analysis. Although these decades are known as years of skeptical attitude of academic community toward TA, there were also some supporting studies like Levy ([1967]) that employed relative strength.

During the last 25 years, TA has been enjoying a rebirth in the academic world, and a considerable amount of theoretical and empirical works has been developed supporting the TA. Thus, theoretical models have been proposed by Hellwig ([1982]), Treynor and Ferguson ([1985]), Brown and Jennings ([1989]), and Blume et al. ([1994]). Also, many empirical papers provide evidence of the profitability of technical trading rules, outstanding among others are Brock et al. ([1992]), Levich and Thomas ([1993]), Knez and Ready ([1996]), Gençay ([1996]), Neely et al. ([1997]), and Chang and Osler ([1999]). It is to be noted that many researchers believe that the study of Brock et al. ([1992]) has played the role of a turning point in the history of TA. They demonstrated the profitability of simple trading rules, MA and trading range breakout. They, after applying 26 trading rules on the basis of MA and trading range breakout rules to the Dow Jones Industrial Average, found that they significantly outperform a benchmark of holding cash. They document that buy signals generate higher returns than sell signals, and the returns following buy signals are less volatile than the returns on sell signals.

There is a fairly comprehensive literature related to TA in various financial domains, but the remainder of this part addresses the ones that are more related to MA. For example, Pruitt and White ([1988]) developed the CRISMA trading system, which combined trading rules of on balance volume, relative strength, and MA and confirmed the profitability of technical trading rules. Sweeney ([1988]), Allen and Taylor ([1990]), and Taylor and Allen ([1992]) find that trading rules can outperform statistical models in predicting exchange rates and stock prices. Bessembinder and Chan ([1995]) and Ratner and Leal ([1999]) following Brock et al. ([1992]) also demonstrated the profitability of simple trading rules, MA, and trading range breakout. Hudson et al. ([1996]) examine prices for the Financial Times Industrial Ordinary Index from 1935 to 1994 and showed that MA trading rules can be utilized for USA and UK markets. As a matter of fact, this study provides novel evidence on the predictive ability of technical trading rules in developed markets with long series of price histories (Gunasekarage and Power [2001]). Mills ([1997]) analyzes daily data on the London Stock Exchange FT30 index for the period 1935 to 1994. It is found that the trading rules worked, in the sense of producing a return greater than a buy-and-hold strategy, for most of the sample period, at least up to the early 1980s. Gencay and Stengos ([1998]) use the daily Dow Jones Industrial Average Index from 1963 to 1988 to examine the linear and non-linear predictability of stock market returns with some simple technical trading rules. Some evidence of non-linear predictability in stock market returns is found using the past buy-and-sell signals of the moving average rules. Sullivan et al. ([1999]) examine close to 8,000 technical trading rules and repeat Brock et al. ([1992]) study while correcting it for data snooping problems. Gunasekarage and Power ([2001]) showed that technical trading rules have predictive ability in South Asian stock markets and reject the null hypothesis that the returns to be earned from studying MA values are equal to those achieved from a naive buy-and-hold strategy. Tian et al. ([2002]) focus in markets with different efficiency level. They found that these simple trading rules are quite successful in Chinese markets in 1990s, while do not beat the US index during the same period. Ausloos and Ivanova ([2002]) present a generalization of the classical TA concepts taking into account the volume of transactions. Lastly, the purpose of Andrada-Felix and Fernandez-Rodriguez ([2008]) is to improve moving average trading rules with boosting and statistical learning methods. In fact, MA is seen in most of the academic studies of TA that has mainly adopted quantitative indicators as prediction variables, and the literature is full of such studies.

MA as a TA

One common component of many technical rules is MA (Gencay and Stengos [1998]). MAs are one of the most popular and easy-to-use tools available to technical analysts. According to the categorization of Reilly and Brown ([1994]) on different technical trading rules which are practiced by US technicians, MA falls into the fourth group of stock price and volume techniques. For the application of MA as a TA, first of all the approach of calculating MA, i.e., simple or exponential, and then the mechanism of issuing signals, i.e., direction or crossover, should be determined.

Equations 1 and 2 show how the MA is calculated simply and exponentially, respectively:

SMA N , T = i = 0 N 1 P T i N ,
EMA N , T = 2 N + 1 × P T EMA N , T 1 + EMA N , T 1 ,

( Inc. [1999]) where SMA N,T is the simple moving average of length N on day T; EMA N,T , the exponential moving average of length N on day T; P T , the stock price on day T; and N; the length of moving average.

Independent of the method that is used to calculate MA, there are two mechanisms of direction and crossover to make investment decision. The first mechanism uses the direction of MA to determine the trend. If the MA is rising/declining by an amount larger than the band, the trend is considered up/down, and a buy/sell signal is issued. The second mechanism is based on the location of the shorter MA relative to the longer MA. If the shorter MA is above/below the longer MA by an amount larger than the band, the trend is considered up/down. Two variations of crossover technique are variable-length MA (VLMA) and fixed-length MA (FLMA). The difference between them is their band, i.e., with a band of zero we have FLMA otherwise VLMA. Band is an amount of difference that is needed to generate a signal. It is to be noted that the approach of price location is exactly the same as crossover with shorter MA of length 1. If band = α, direction and crossover issue signals according to Equations 3 and 4, respectively:

Buy Sell Hold i f MA N , T > 1 + α MA N , T 1 i f MA N , T < 1 α MA N , T 1 Otherwise ,
Buy Sell Hold i f MA N n , T > 1 + α MA N , T i f MA N n , T < 1 α MA N , T Otherwise ,

where 1 ≤ n ≤ N − 1 is the integer, and MA N,T is the MA of length N on day T whether calculated simply or exponentially.

Although trial and error is usually the best means for finding the best length, the most popular MA rule as reported in Brock et al. ([1992]) is the 1 to 200 rule, where the short period is 1 day and the long period is 200 days. Other popular ones are the 1 to 50, 1 to 150, 5 to 200, and the 2 to 200 rules (Gencay and Stengos [1998]).

Is there any difference between direction and crossover?

Naturally, it is questioned whether the two mechanisms are the same or not. To respond the question, Equations 5 and 6 for direction and crossover, respectively, are developed and being discussed. Without losing generality, MA in both of the mechanisms is calculated simply, and for crossover, FLMA is considered.

MA N , T MA N , T 1 = P T P T N N ,
MA N n , T MA N , T = n P T + P T 1 + + P T N + n + 1 N n P T N + n + + P T N + 1 N N n .

Since the yielded signal depends on positivity or negativity of the equations, for direction the relation between magnitudes of P T and PTN, and for crossover the relation between magnitude of P T + P T 1 + + P T N + n + 1 N n and P T N + n + + P T N + 1 n determines the final signal. Accordingly, the direction signal depends only on the first and last input data, while the crossover signal depends on the average of last (N − n) data and the average of first n data. Hence, it is obvious that two approaches of direction and crossover are not the same and apply different mechanisms.

Evaluation system

To compare different MA-based TA models, there should be an evaluation system according to which they are being assessed. The intended evaluation system of the paper is based on the number of correct and wrong signals and their associated weights. The general method to derive the weights is founded on wrong signals. That is, firstly the weights of wrong signals are calculated then the weights of correct signals by considering a coefficient will be achieved. The wrong signals are sell for buy, buy for sell, hold for buy, buy for hold, hold for sell, and sell for hold that, after considering the fact that whether the stock is in the portfolio or not, become twelve states as shown in Table 1.

Table 1 Different probable errors of a TA system under different conditions with their results

Losses that resulted from wrong signals, according to their degree (as can be seen in Table 1), are categorized into five: ‘double losing’, ‘losing’, ‘neutral–’, ‘neutral’, and ‘benefiting’. Double losing happens when the stock trader sell (buy) the stock when its price will increase (decrease) like state 1 (4). Losing happens when the stock trader does not buy (sell) the stock when its price will increase (decrease) like states 2 and 6 (3 and 9). Neutral− happens when the stock trader buy or sell the stock when its price will experience no tangible change in the future like state 8 or 11. Neutral happens when, in spite of wrong signals of the TA processor, the stock trader lose nothing, for example, if the stock is not in the investor portfolio, there will be no difference between sell and hold signals like states 10 and 12. The same thing happens for buy and hold signal, i.e., when the stock trader has the stock and the correct signal is holding like state 7. This can also benefit the investor if the correct signal is buying because according to signal of holding (that is wrong) the investor will keep it and will experience its increase and will benefit, exactly as happens in state 5. The states are arranged in a descending order in Table 2.

Table 2 Ranking of different states of errors according to the magnitude of resulted losses

To differentiate between different ranks, the assigned weights to them are 100, 60, 20, 10, and 0 for ranks of 1 to 5, respectively. Whereas each error is associated with two states, the weight of each error should be a function of its corresponding states' weights. In this study, simple averaging has been used to come up with Table 3.

Table 3 Weights of different errors

According to Table 3, the negative score (Ers) of a TA on the basis of a particular data set can be calculated by Equation 7:

ErS = 80 × nisb + nibs + 35 × nihs + 30 × nihb + 15 × nibh + nish ,

where nisb is the number of incorrect sell for buy signals; nibs, the number of incorrect buy for sell signals; nihs, the number of incorrect hold for sell signals; nihb, the number of incorrect hold for buy signals; nibh, the number of incorrect buy for hold signals; and nish, the number of incorrect sell for hold signals.

On the basis of the fact that many evaluation systems consider weight of a correct answer three times larger than an incorrect one, this study does the same to calculate the weight of correct buying, selling, and holding signals as 150, 150, and 90, respectively. Hence, the total score of a TA processor is calculated by Equation 8:

TSc = 1 tns 150 × ncb + ncs + 90 × nch ErS ,

where tns is the total number of signals.

Benchmark signals

To determine whether the issued signal of TA for a particular day is correct or not, there should be a benchmark signal for that day. The following two parts first describe the implication of each sign and then the methodology of deriving the benchmark signals.


A TA signal does not always mean taking actions; for instance, a buy signal for the stock which is in the portfolio does not necessarily imply increasing its share in the portfolio. In fact, a buy signal means that the stock price will increase in the future, and it is recommended to have the stock; thus, if the stock trader has the stock, the TA processor implies keeping of it. This is similar for a sell signal that recommends not keeping the stock and selling it completely. As a matter of fact, if the investor does not have the stock, a selling signal implies to do nothing. Hence, t uninterrupted buy (sell) signals tell the investor to (not to) have the stock in his/her portfolio for the t-day period. Lastly, a hold signal means there will be no considerable change in the price of the stock in the future.


The mechanism of deriving the benchmark signals in this study for running the experiments is shown in Equation 9:

S t { Buy if P t + 1 P t P t > sl Sell if P t + 1 P t P t < sl where sl 0 , Hold Otherwise

where S t is the benchmark signal on day t, and sl is the sensitivity level for considering buy or sell opportunities.

Table 4 shows the results of applying Equation 9 to the stock price of Yahoo Company for 10 days between 1 July 2008 and 15 July 2008.

Table 4 Benchmark signals for trading stocks of Yahoo

Design and running of experiments


The experiments have been run using data on the three market indices and four individual stocks as shown in Table 5. While it is possible to create MAs from the open, the high, and the low data points as usual this study uses the closing price.

Table 5 Some points about time series of data for running experiments

The common measures of literature to quantify variability of a data set are variance (VAR), standard deviation (SD), and so on. However, there is a main problem with them that not consider proportional variability and focus on the absolute magnitude of changes. To see the point better, consider Table 6 in which the variability of two sets of data are calculated by both measures of VAR and SD.

Table 6 Two sets of data and their VAR and SD

According to Table 6, the measures evaluate the variability of the second set considerably bigger than the first that does not make sense because change percentage of the first set of data from a particular data to the next one is considerably bigger than the second set. To meet the challenge, Equation 10 is devised to quantify the variability of input data:

Vol = i = 2 n P i P i 1 P i 1 n 1 ,

Where P i is the stock price on day i, and n is the total number of data that is to be analyzed.

After applying Equation 10 to the data in Table 6, volatility of data achieved are 2,643.33% and 4.25% for the first and second data sets, respectively, that are completely sensible. According to Equation 10, Table 7 shows the volatility of data sets used in the study.

Table 7 Variability of data that are used in this study according to Equation 10


Table 8 shows different amounts of band, sl, l, and (m, n) where l denotes length of moving average (LMA) in approach of direction and m and n denote lengths of short and long MA in approach of crossover, respectively.

Table 8 Different amounts of parameters

According to Inc. (1999), some of the more popular lengths of MA include 21, 50, 89, 150, and 200 days as well as 10, 30, and 40 weeks. On the basis of these lengths and the ones that are recommended by other scholars, the amounts of m are decided to be 1, 2, 3, 5, 13, 21, 50, 89, 150, 200, and 250, and for each m = a, there are 100 n s of (a + 1, a + 2, …, a + 100) that totally becomes 1,100 states.

All combinations of these parameters, beside simple or exponential calculation of MA, deliver a total of 93,600 MA trading rules. To make the calculated TScs applicable for the final inferences, the achieved TScs need some kind of manipulation. The data manipulation for the approach of direction transforms 36 data into 1, while for crossover, 3,600 data into 1. The logic of transformation for both of the approaches is the same and says if a parameter affects the benchmark signals, none of its amount should be ignored, and if it affects the generated signals, the one that maximizes the performance should be considered during the manipulation process because setting the parameters to generate signals is a trial-and-error process while the other kind of parameter depends on the investor.


After running the experiments by direction 100800, TScs are achieved. In fact, for each l under a particular technique of calculating MA, there are 36 TScs that are notated by TSc ij i = 1, …, 6; j = 1, …, 6, where i denotes category of band, and j denotes category of sl. On the basis of what has been discussed before, Equations 11 and 12 work the 36 input data into one. After applying the equations to the 100800 TScs, 2,800 T ¯ ¯ Sc s are achieved. Table 9 summarizes these results by means of seven indices of 1 to 7.

T ¯ Sc i = j = 1 6 TSc ij 6 , i = 1 , 2 , , 6 ,
T ¯ ¯ Sc = Max T ¯ Sc 1 , , T ¯ Sc 6 .
Table 9 Results of applying indices to results of running experiments on the approach of direction

Index 1 calculates the maximum difference between T ¯ ¯ Sc s to determine how much selection of l or technique of calculating MA is important, while index 2 seeks the maximum difference between scores of simple and exponential techniques with similar length to determine the importance of being careful toward selection of the technique. Index 3 calculates the difference between maximum and minimum of T ¯ ¯ Sc s for the simple technique to highlight the magnitude of effect that LMA has on performance of direction, while index 4 do the same but for exponential technique. Index 5 specifies that between 400 T ¯ ¯ Sc s of each market index or stock, what proportion of top forty T ¯ ¯ Sc s, belongs to the exponential technique. Then, indices of 6 and 7 concentrate on the LMAs that are associated with the three top T ¯ ¯ Sc s for simple and exponential techniques, respectively. Based on the average performance for different amounts of l for the stocks Nikkei 225, Egypt CMA Genl, Yahoo, Dell, and HP, the approach simple is superior, but for the stocks S&P500 and China South Air Ltd., the approach exponential is better.


Manipulating the 554,400 outputs of crossover because of an extra length parameter needs more processing. In fact, for each m under a particular technique of calculating MA, there are 3,600 TSCs that are notated by TSc ijk , wherei = 1, 2, …, 100 denotes category of n, j = 1, 2, …, 6 denotes category of band, and k = 1, 2, …, 6 denotes category of sl. Equations 13, 14, and 15 work the 3,600 input data into one:

T ¯ Sc ij = k = 1 6 TSc ijk 6 ,
T ¯ ¯ ScSc i = Max T ¯ Sc i 1 , T ¯ Sc i 2 , , T ¯ Sc i 6 ,
T ¯ ¯ ¯ Sc = Max T ¯ ¯ Sc 1 , T ¯ ¯ Sc 2 , , T ¯ ¯ Sc 100 ,

After applying the equations to the 554,400 TSCs, 154 T ¯ ¯ ¯ Scs are achieved that prove the priority of the approach exponential to the simple, and also Table 10 summarizes them according to five indices of 1 to 5.

Table 10 Results of applying indices to results of running experiments on the approach of crossover

Indices 1 to 4 are the same as Table 9 just l is replaced by m. Index 5 specifies that what proportion of top three T ¯ ¯ ¯ Sc s of each data set that are calculated simply or exponentially belongs to the exponential technique. Lastly, Table 11 shows the best n s that have the maximum TSc for some particular m s used in the experiments.

Table 11 The n s that produce the maximum TSC with the corresponding m

Another thing about crossover that should be analyzed is the behavior of TSc for a fixed m while n increases continuously. In the experiment, m s are the same as the previous experiment, while n, if m = a, gets 200 amounts of {a + 1, a + 2, …, a + 200}. The behavior for all the seven data sets is, to some extent, the same and just as the instance in Figure 1 shows the results for S&P 500 when MA is calculated simply, while Figure 2 shows the results for HP when MA is calculated exponentially for different m s.

Figure 1
figure 1

The behavior of crossover on the basis of data from S&P 500. Each line represents a particular m.

Figure 2
figure 2

The behavior of crossover on the basis of data from HP. Each line represents a particular m.

Direction versus crossover

After studying two approaches of direction and crossover individually in this section, their performances according to the criterion of processed TSc are compared. The comparison is done by three indices as shown in Table 12. Index 1, by calculating the difference between the best performance of direction and crossover, determines how much choosing between direction and crossover is important. For indices 2 and 3, firstly top five TScs of direction and top five TScs of crossover are combined to form 10 TScs. In this regard, indices 2 and 3 mention the ranks of crossover and direction, respectively.

Table 12 Results of three indices on comparing direction versus crossover

There are two points about the results of all the experiments of this study. First, the measure of TSc is designed in the way to show the effects of different factors on performance of the TA for a particular and not different sets of data. Thus, it is not a proper measure to determine how much a TA is appropriate or applicable for a particular set of data. Second, all the results whether in the form of table or figure are optimal ones over 6 amounts of band. Consequently, the comments have been given on the basis of the assumption that an appropriate band has been chosen.


In this paper, after developing a measure to evaluate the performance of a TA processor, efficiency of different states of a MA model are tested to get some clues to construct a better TA processor. To our surprise, the results, on the basis of the ranges that have been considered for the parameters, show that some factors in spite of what has been thought only have negligible effects. The factors are as follows:

• In the conditions that other factors are set appropriately, choosing between approaches of direction and crossover, although in most cases, crossover proves to be slightly more efficient.

• In the conditions that other factors are set appropriately, choosing between simple or exponential calculation; although for the approach of direction, simple and for the approach of crossover, exponential prove to be slightly more efficient.

• For the approach of direction, specification of l proves to be more important than choosing the technique of calculating MA.

• For the approach of crossover, specification of one of the two parameters when the other has not specified yet. That is, whether m or n is specified first, the other length (n or m) can be determined in the way to have acceptable performance.

On the other hand, the factor that affects the performance of crossover considerably is the combination of (m, n). It is proved that the difference between m and n should not be much. As a matter of fact, for a fixed m if n increases, the performance of MA deteriorates. Although there may be some improvements in the performance of MA by increasing n, they are venial, and the general trend is descending. Lastly, it is concluded that the more volatile the input data, the more sensitive the performance of TA model to the discussed factors.

As was noted before, the results are independent of the parameter of band. Studying this area to get some points in the selection of band and monitoring the performance of MA for different amounts of it would be a good research area to continue this study. On the other hand, focusing on other evaluation systems of TA models or even optimizing weights of the system that has been presented in this study to present the best sensitivity toward performance of TA is recommended.