Developing a System for Trading in the Stock Markets

This research work provides a quantitative approach to measure the accuracy of a buy or sell signals of stocks in the US stock market. It describes several buy/sell indicators, then measures the accuracy of each indictor by testing it on a number of filtered US historical data between 2000 and 2014. We show how each indicator weighs, then by summing up scores of successful indicators, we end up with a score for each stock at a particular time. This would give a much more accurate buy or sell signal. In past stock market research [Bulkowski, Thomas N (2005), Davey, Kevin (2014), Farley, Alan S (2001), Fitschen, Keith (2013), Stridsman, Thomas (2001), Tharp, Van K (1999)], typically researchers measure the probability of a success of an uptrend or a downtrend based on a fixed number of successful indicators. For example, some research shows that six out of nine indicators must be giving buy/ sell signals. The results obtained in this research should be applicable to other international markets as well.


Trading Indicators
We have selected a number of trading indicators that are used often by trading professionals and by trading systems:

A. Moving Average (MA)
Moving averages [Grimes, Adam (2012), Pring, Martin (2015)] are used to smooth trends.A 10-day simple moving average would be the mathematical average of the closing prices over the last 10 days.An exponential moving average is similar to a simple moving average but places more emphasis on recent price movements.A 10-day and 20-day price moving averages are very popular among traders.(Figure1) Some technicians interpret crossovers of moving averages as buy or sell signals.

Figure 1: 10-day and 20-day Exponential moving average (EMA)
On mid-august the 10-day ema crossed its 20-day ema confirming the uptrend, We see a downtrend in late August, then a confirmation of an uptrend in early October.

B. Bollinger Bands
Bollinger Bands, developed and introduced by John Bollinger [Bollinger, John (2002), Grimes, Adam (2012), Pring, Martin (2015)], are trading bands based on the volatility of prices around a simple moving average.The result of using volatility to compute the spacing of the bands above and below the average is that the spacing varies with volatility.Volatility in this case is measured as the statistical standard deviation computed on the same set of data as the moving average.To compute his bands, Bollinger recommends using a 20-Day Moving Average, (Figure 2 period, the same 20 days, is the variation of the data around the average for the last 20 days.This variation is measured by the standard deviation of the data from the average.The actual trading band is plotted some number of standard deviations above and below the average.Aside from the computational differences, Bollinger Bands are used in the same way as other trading bands.In addition, Bollinger has developed several rules for these Bands that can be used to look for indications of possible price moves.
The Bollinger rules are: • Sharp moves in price tend to occur after the Bands tighten, and the closer to the average the better.Since reduced volatility denotes a period of consolidation, the first increase in volatility after a consolidation tends to mark the start of the next move.
• Moving outside the Bands signals a continuation of the move until the prices drop below or inside of the Bands.
• Moves starting at one Band tend to go to the opposite Band.out daily price fluctuations.Most traders are familiar with using crossovers of simple price moving averages to arrive at buy and sell signals (i.e. when price crosses up through its moving average a bullish condition exists).MACD is a very similar concept.However, MACD consists of three price moving averages, instead of just one or two Price Moving Average's (MA).
The first MA should be set to a shorter term time frame (e.g.12-day) and the second MA is typically set to a number about twice as long as the first.These parameters are determined by the trader, based on his or her particular time horizons.The calculation of the second indicator line is simply a moving average of the first line.A common parameter used here is a 9-day moving average, but traders experiment with varying parameters since no indicator parameter works best for all market conditions.The interpretation of MACD can be explained in just a few simple sentences.Trading signals are produced when the MACD crosses through its moving average.If MACD crosses up through its moving average, it's a buy signal.Conversely, the opposite would be true.This is how the indicator is most commonly used.The histogram is the difference between the two MACD lines.
Where the histogram crosses the zero line is the point where the two MACD lines are crossing (the difference between the two is zero).

D. Time Segmented Volume TSV(Money Flow Indicator MFI)
TSV [Grimes, Adam (2012), Pring, Martin (2015)] is an oscillator, which is calculated by comparing various time segments of both price and volume.TSV essentially measures the amount of money flowing in or out of a particular stock.(Figure 3) The horizontal line in the middle, which extends across the entire length of the indicator window, represents the zero line.When TSV crosses up through the zero line it signals positive accumulation or buying pressure.This action is considered bullish.Conversely, when TSV crosses below the zero line it indicates distribution or selling pressure, which typically precedes a move down in price.

E. Wilder's RSI
The Relative Strength Index (RSI) is a rate of change oscillator [Grimes, Adam (2012), Pring, Martin (2015)] .RSI is calculated purely from the price of the individual stock or market average.RSI essentially compares the price of something to itself.
(Figure 4) The RSI indicator is most effective when used to spot positive and negative divergences with price.It is also used to determine when a stock or index has reached an overbought or oversold condition within the confines of its primary trend.
When RSI registers a reading of 70% or higher, price is generally in an overbought position.Conversely, when RSI reaches the 30% level, price can be considered oversold.When using RSI as an overbought/oversold indicator, it is extremely important to first determine whether a definable primary trend actually exists.This is best determined by using other technical indicators such as price moving averages, Trend lines, and Time Segmented Volume (TSV).Once the direction of a primary trend has been successfully identified, RSI is used to trade strictly with the trend.For example, if a stock is in a definable uptrend, use RSI to identify optimum entry points.A spike down in RSI (below 30%) would signal just such

G. Stochastics
Stochastics [Grimes, Adam (2012), Pring, Martin (2015)] is an indicator that measures the price velocity of a particular stock or market index.It essentially shows us where price is trading within a given range.(Figure 5) The boundaries of the range would be the high and the low for a specific time period determined by the user.
A stochastic of 100% would mean price is currently trading at the extreme high of the range and a stochastic of 0 would mean price is trading at the extreme low.
Stochastics, like the Relative Strength Index, helps us to determine whether price is overbought or oversold.When the Stochastics crosses up through the 80% line, it is considered overbought.Below 20% is considered oversold.The shorter the stochastic period, the more signals the indicator will produce.However, if your period setting is too short, the majority of your signals will be false.A moving average of the stochastic provides a basis for buy and sell signals.When an overbought stochastic turns down through its MA, a sell signal is produced.When an oversold stochastic moves up through its MA, a buy signal is produced.
Stochastics was developed by George C. Lane [Grimes, Adam (2012), Pring, Martin (2015)] and is calculated as follows: Furthermore, Lane recommends that the stochastic line be smoothed twice with three-period simple moving averages: SK is the three-period simple moving average of K, and SD is the three-period simple moving average of SK.Table 1 shows the results of running the twelve systems.In each system, we show average net profit, average percentage net profit, best profit trade, worst profit trade, average number of trades, average trade profit/loss, and average profit/ average loss.
Here is an explanation of the terms used in the table : 1. Avg.Net Profit: How much equity the security earned during the simulation.
Ave Net Profit = Gross profit -Gross Loss.In this stage, our goal is to find the values of the optimization variables opt1, opt2 that will give the maximum average gain using this system.In other words, we run the new system many times using different combinations of opt1 and opt2 to produce the two values that would make the system most profitable.Which means that buy the stock if the sum of all weights is higher than 49, sell it if the sum of all weights is lower than 36.The system shows an average percentage gain of %51.55 as shown in Table 3 and Figure 6.

E. Demonstration:
The top chart in Figure 7 shows that when the new system indicator is above the value of 49, it creates a buy signal, but when it is less than the value of 36, it creates a sell signal.

Conclusion
In past stock market research, typically researchers measure the probability of a success of an uptrend or a downtrend based on a fixed number of successful indicators.For example, some research shows that 6 out of 9 indicators must be giving buy/sell signals.This technique treats each indicator equally.In this research we show how each indicator weighs by summing up scores of successful indicators; we end up with a score for each stock at a particular time.This would give a much more accurate buy or sell signal.The system has an average gain of %51 versus an average gain ranges from %2 to %33 for its component indicators.
There have been limitations set to the equity used in order to get uniform results.

52
University of Sharjah Journal for Humanities & Social Sciences, Volume 12, No. 2 December 2015 For example there has been a limit of using equity of only $10000 per transaction (if available).There has not been an interest paid to unused equity.Also, only long orders where executed and no short orders were created.Avoiding these limitations would definitely increase the average gain.
It would be interesting to run this system in relatively new stock markets, for example stock markets in the Middle East where it is likely that automated trading is not used as much as it is in the USA stock markets or at least it is not optimized that much.
In the future, we would like to incorporate our new system with Japaneese methods such as Candlestick patterns [Nison, Steve (1991)] and well known chart patterns such as descending triangles chart pattern.
In future systems, we would like to investigate the possibility of having adaptive weights for each indicator.In this system weights could change over time depending on their success.For example if an indicator contributed to a profitable trade, its weight would be rewarded by increasing its weight.On the other hand if the trade ended up to be a loss, that indicator would be penalized by reducing its weight.

37
University of SharjahJournal for Humanities & Social Sciences, Volume 12, No. 2 December 2015 ) which is the arithmetic average of the previous 20 days of data.Volatility for the same 38 University of Sharjah Journal for Humanities & Social Sciences, Volume 12, No. 2 December 2015

Figure
Figure 2: 20-Day Bollinger Bands, 20-day simple moving average is shown in the middle

Figure 3 :
Figure 3: 16-Day Time segmented volume (TSV) and its moving average, when the TSV16 crosses up the middle line and its moving average it signals an uptrend and vice versa.

Figure 4 :
Figure 4: 21-Day Wilder's RSI and its moving, when the RSI21 crosses up its moving average it signals an uptrend and vice versa.
latest closing price of the stock L is the n-period low price of the stock H is the n-period high price of the stock n can be any number (Lane suggests 5 to 21)

Figure
Figure 6: Comparison between the average gain of the new system versus its component indicators

Figure 7 :
Figure 7: The new system indicator and its moving average are used to create buy/sell signals.

University of Sharjah Journal for Humanities & Social Sciences,
Volume 12, No. 2 December 2015 Table2above shows that we obtain maximum gain when the values of the optimization variables opt1 and opt2 are 50, and 35.Further tuning showed in Table3indicates that the optimum values are at 49 and 36.So the final buy and