GET THE APP

Developing Profitable Trading System
Journal of Stock & Forex Trading

Journal of Stock & Forex Trading
Open Access

ISSN: 2168-9458

+44 1223 790975

Research Article - (2015) Volume 4, Issue 1

Developing Profitable Trading System

Alaa Eldin M. Ibrahim*
University of Sharjah, Sharjah, UAE
*Corresponding Author: Alaa Eldin M. Ibrahim, University of Sharjah, Sharjah, UAE, Tel: 9716558500 Email:

Abstract

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 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.

<

Keywords: Stock trading; US markets; Trading system; Trading rules; Indicators

Trading Indicators

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

Moving Average (MA)

Moving averages 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. Some technicians interpret crossovers of moving averages as buy or sell signals.

Bollinger bands

Bollinger Bands, developed and introduced by John Bollinger [1], 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, which is the arithmetic average of the previous 20 days of data. Volatility for the same 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.

MACD (Moving Average Convergence Divergence)

Gerald Appel [2-10] created MACD for the purpose of producing specific trading signals. The primary reason for its popularity among technicians is the fact that it is a very easy indicator to interpret. Price moving averages (PMA) help us to identify trends more effectively by smoothing 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).

Time Segmented Volume TSV (Money Flow Indicator MFI)

TSV 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. 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.

Wilder’s RSI

The Relative Strength Index (RSI) is a rate of change oscillator [2]. RSI is calculated purely from the price of the individual stock or market average. RSI essentially compares the price of something to itself. 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 an entry point. RSI is also capable of positive and negative divergences with price. Wilder [2,10] suggests using a 14-day RSI although other settings have also proved useful.

RSI is calculated as: RSI=100-(100/(1 + RS)) Where RS is the ratio of the exponential moving average of n-period gains (value of up closes) divided by the absolute value of the exponential moving average of n-period losses (value of down closes). Wilder suggests using a 14-period.

Price Rate of Change (PROC)

This is a momentum oscillator calculated from the price of an individual stock or a market index. A rate of change oscillator measures changes in percentage rather than actual points. The latest plot is calculated as the ratio of the current closing price to the price a certain number of periods ago. For example, if you apply a 10-day rate of change to the price of a particular stock, the oscillator is calculated by simply dividing the current day’s closing price by the closing price ten days ago. The ROC oscillator often precedes reversals in price itself. It is also important to look for positive and negative divergences between the ROC indicator and price. This is also true of other oscillators, such as TSV, RSI and Stochastics.

Stochastics

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. 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 [2,10] and is calculated as follows:

K=((C - Ln)/(Hn - Ln)) * 100 Where

K is Lane’s Stochastics

C is the 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) 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.

Stochastic RSI

The concept of stochastic applied to Wilder’s RSI: Cross(20,(Sum(RSI(10)-LLV(RSI(10),10),3)/Sum(HHV(RSI(10),10)- LLV(RSI(10),10),3))*100) Where:

LLV: Lowest Low Value

HHV: Highest High Value

The Stochastic RSI indictor first subtract the Lowest lows of the RSI(10) in the last 10 days (bars) from the value of the RSI(10) then summing that for the last 3 days, then it divides that by the sum of the same replacing the Lowest lows by the highest highs. Experience showed that this indicator is very reliable.

System Building

For each indicator a system is built to test its performance.

Moving averages system

The most famous moving average systems are the 10 and 20 day (bar) exponential moving averages in addition to others such as (20, 50) and (7, 17) exponential moving averages. Our optimization tests showed that the (18, 20) exponential moving averages works very well.

Buy condition: Buy stocks when the ten-day exponential moving average of the closing price is higher than the twenty-day exponential moving average of the closing price as provided in the formula:

Mov(C,10,E) > Mov(C,20,E)

Sell condition: Sell stocks when the twenty-day exponential moving average of the closing price is higher than the ten-day exponential moving average of the closing price as provided in the formula:

Mov(C,20,E) < Mov(C,10,E)

A formula that tests one conditions: The ten-day exponential moving average of the closing price is higher than the The twenty-day exponential moving average of the closing price.

Bollinger Band: Code for the Bollinger Band: We check if the Close is crossing the 20-day BBand Bottom Cross(C, BBandBot(C, 20, S, 2))

TSV/MFI: We test if the 16-day MFI is above the value of 50 and that its above its 4-day exponential moving average.

(MFI(16) > 50) AND (MFI(16) > Mov(MFI(16),4,E)

RSI2: We test if the Wilder’s RSI 21-day is above the value of 50 and that its above its 4-day simple moving average. (RSI(21) > 50) AND (RSI(21) > Mov(RSI(21),4,S))

STOCH(5,3): We test if the Stochastic (5,3) is above the value of 20 and that it is above its 3-day simple moving average (Stoch(5,3)>20) AND (Stoch(5,3) >Mov(Stoch(5,3),3,S))

MCAD: We test if the MCAD is above its 4-day exponential moving average.

MACD() > Mov( MACD(), 4, EXPONENTIAL)

StochRSI: Stochastic RSI code as explained above

Cross(20,(Sum(RSI(10)-LLV(RSI(10),10),3)/Sum (HHV(RSI(10),10)-LLV(RSI(10),10),3))*100)

Experiment and Results

By scanning through historical stock data using varieties of trading software, we were able to examine each indicator individually on 100 randomly selected US stocks in time frames between January 2000 and January 2014. We filter out stocks that are cheap (less than US $ 5 per stock), low volume stocks (average volume is less than 100,000 shares per day).

Simulation running

In order to evaluate each indicator, each indicator system was virtually tested on stocks in the time frame mentioned above. For each indicator system, a $10,000 initial virtual equity is given, and for each buy signal, a $10,000 equity is provided (if available) to virtually buy stocks. The equity that is not used during transactions doesn’t gain interest to avoid giving a system that generated so few trades a credit it doesn’t deserve.

Results

Table 1 shows the results of running the twelve systems.

Indicator Avg. Net Profit Avg.% Gain Best Profit Worst Profit Avg. Trades Trade Profit/Loss Avg.Profit/Ave. Loss
StochasticsRSI $3,343.08 33.43 $35,512.14 $4,813.96 19 12.3/7.4 0.87
EMA 18/20 $1,857.31 18.75 $61,977.39 $4,463.64 7 2.5/4.5 2.98
Stochastics 5.3 $1,836.90 18.37 $22,036.79 $7,388.05 13 8.7/4.7 0.69
Bollinger Bands(BB) $1,765.30 17.65 $25,856.55 $5,745.69 8 5.9/2.7 0.61
TSV/MFI $1,693.34 16.93 $30,664.97 $3,493.13 17 7.2/10.6 1.85
EMA 20/50 $1,269.02 12.69 $69,576.56 $2,881.00 2 0.9/1.7 N/A
MCAD $750.54 7.51 $34,867.36 $3,986.99 16 6.3/10.5 1.88
EMA 7/17 $575.07 5.75 $51,693.66 $2,872.13 4 1.4/3.1 3.97
EMA 10/20 $430.39 4.3 $32,745.90 $3,868.28 4 1.3/2.8 2.44
Wilder's RSI 21 $223.46 2.23 $15,404.93 $3,009.88 6 2.2/4.5 2.29
Wilder's RSI 5 $211.71 2.12 $16,284.91 $2,360.07 36 15.1/21.8 1.44
PROC ($243.73) -2.44 $9,942.76 $3,631.07 12 4.8/7.4 1.61

Table 1: Shows the Results of Running the Twelve Systems.

Here is an explanation of the terms used in the table:

• Average Net Profit: How much equity the security earned during the simulation.

Ave Net Profit=Gross profit – Gross Loss.

• Average Percentage Gain: The percentage of the initial equity represented by the net profit.

Average % Gain=Ave Net Profit / $10,000.

• How many trades the simulation generated for this security

Average Trades: Average number of trades when applying the system on 100 stocks.

Trade Profit/Loss How many trades were profitable, and how many were losses

• Avg. Profit/Avg. Loss: This percentage represents the total equity earned divided by the number of profitable trades divided by the total equity lost divided by the number of losing trades (Table 1 and Figures 1-5).

forex-trading-moving-average

Figure 1: 10-Day and 20-Day exponential moving average (EMA) on midaugust, the 10-Day EMA crossed its 20-Day EMA confirming the uptrend; we see adowntrend in late august, then a confirmation of an uptrend in early october.

forex-trading-Bollinger-bands

Figure 2: 20-day Bollinger bands, 20-day simple moving average is showing in the middle.

forex-trading-segmented-volume

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.

forex-trading-wilders-RSI

Figure 4: 21-day wilder’s RSI and its moving, when the RSI 21 crosses up its moving average it signals an uptrend and vice versa. Note that it didn’t signal the uptrend and downtrend in august.

forex-trading-Stochastics

Figure 5: Stochastics.

Creating the new system

Using the average percentage gains above, we are able to give each indicator a weight that will be used in creating the new system below. The least performing indicators. The Wilder’s RSI 5, and Price Rate of Change (PROC) were excluded from the formula of the new system.

{exponential 10-day and 20-day moving average}

MOVv1:=if(Mov(C,10,E) > Mov(C,20,E),4.3,0); {exponential

18-day and 20-day moving average} MOVv2:=if(Mov(C,18,E)

> Mov(C,20,E),18.57,0); {exponential 7-day and 17-day

moving average} MOVv3:=if(Mov(C,7,E) >

Mov(C,17,E),5.75,0); {Bollinger Bands (BB)}

BBv:=if(Cross(C, BBandBot(C, 20, S, 2)),17.65,0); {TSV (MFI)}

MFv:=if((MFI(16) > 50) AND (MFI(16) > Mov(MFI(16),4,E)),16.93,0); {RSI}

RSI21v:=if((RSI(21) > 50) AND (RSI(21) > Mov(RSI(21),4,S)),2.23,0); {Stochastics 5.3}

STOCHv:=if((Stoch(5,3)>20) AND (Stoch(5,3) >Mov(Stoch(5,3),3,S)),18.37,0); {MCAD}

MACDv:=if(MACD() > Mov( MACD(), 4, EXPONENTIAL), 7.51, 0); {Stoch RSI}

STOCHrsi:=if(Cross(20,(Sum(RSI(10)-LLV(RSI(10),10),3)/ Sum(HHV(RSI(10),10)-

LLV(RSI(10),10),3))*100), 33.43, 0);

{Sum of all weights}

macsum:=MOVv1+MOVv2+MOVv3+BBv+MFv+RSI21v+STOC Hv+MACDv+STOCHrsi; {general condition}

GENv:=(C >= 5) AND (C <=50) AND (V >=1000);

{Buy condition}

SUMv:=(macsum > opt1);

(SUMv AND GENv)

{Sell condition} S

UMv:=(macsum < opt2);

SUMv)

Testing and optimizing the new system

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. Table 2 below shows that we obtain maximum gain when the values of the optimization variables opt1 and opt2 are 50, and 35. Further tuning showed in Table 3 indicates that the optimum values are at 49 and 36. So the final buy and sell conditions are:

ID Avg. Net Profit Total Profit Avg. % Gain Avg. Trades Avg.Trade Profit/Loss Avg.Profit/ Ave Loss OPT1 OPT2
13 $4,707.47 $470,747.09 47.07% 47 26.9/21.0 1.09 50 35
16 $4,507.27 $450,727.50 45.07% 54 29.8/25.2 1.18 40 40
17 $4,483.10 $448,309.84 44.83% 53 29.0/24.4 1.18 45 40
6 $4,329.82 $432,981.85 43.30% 46 24.7/21.5 1.2 40 30
19 $4,257.67 $425,767.36 42.58% 42 23.7/18.9 1.12 55 40
18 $4,249.86 $424,985.76 42.50% 45 25.8/20.0 1.06 50 40
11 $4,241.87 $424,186.74 42.42% 49 26.7/22.6 1.15 40 35

Table 2: Shows the Search for the Two Optimization Variables to Set the Optimum Buying and Selling Points.

ID Avg. Net Profit Total Profit Avg. % Gain Avg. Trades Avg.Trade Profit/Loss Avg.Profit/Ave. Loss OPT1 OPT2
20 $5,155.23 $5,155.23 51.55% 48 27.4/21.5 1.14 49 36
19 $5,155.23 $5,155.23 51.55% 48 27.4/21.5 1.14 48 36
7 $4,877.31 $4,877.31 48.77% 46 25.8/20.7 1.16 48 34
8 $4,877.31 $4,877.31 48.77% 46 25.8/20.7 1.16 49 34
13 $4,877.31 $4,877.31 48.77% 46 25.8/20.7 1.16 48 35
14 $4,877.31 $4,877.31 48.77% 46 25.8/20.7 1.16 49 35
1 $4,714.72 $4,714.72 47.15% 45 25.4/20.4 1.15 48 33

Table 3: Shows the Fine Tuned Optimized Buying and Selling Point.

{Buy condition}

SUMv:=(macsum > 49);

(SUMv AND GENv) {Sell

condition}

SUMv:=(macsum < 36);

(SUMv)

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.

forex-trading-average-gains

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

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.

forex-trading-the-new-system

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

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 [11-21].

There have been limitations set to the equity used in order to get uniform results. 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 were executed and no short orders were created. Avoiding these limitations would definitely increase the average gain.

In the future, we would like to incorporate our new system with Candlestick patterns and well known chart patterns such as descending triangles and cup and handle chart patterns.

References

  1. Bollinger J (2002) Bollinger on Bollinger Bands. McGraw-Hill, New York, USA.
  2. Bulkowski TN (2000) Encyclopedia of Chart Patterns. John Wiley & Sons, New York, USA.
  3. Connors, Laurence A, Linda BR (1995) Street Smarts, High Probability Short TermTrading Strategies. M. Gordon Publishing Group, Malibu, California, USA.
  4. Cooper J (1996) Hit and Run Trading, The Short-Term Stock Traders' Bible. M. Gordon Publishing Group, Malibu, California, USA.
  5. Crabel T (1990) Day Trading with Short Term Price Patterns and Opening Range Breakout.Rahfeldt and Associates, Jupiter, Florida, USA.
  6. Dunnigan W (1956) New Blueprints for Gains in Stocks & Grains. Financial Times Pitman Publishing, London, England, UK.
  7. Dunnigan W (1957) One-Way Formula for Trading in Stocks & Commodities, Financial Times Pitman Publishing, London, England, UK.
  8. Edwards, Robert D, John M (1948) Technical Analysis of Stock Trends.John Magee, Springfield, Massachusetts, USA.
  9. Epstein DC, Richard A (1967) The Theory of Gambling and Statistical Logic. Academic Press, San Diego, California, USA.
  10. Fosback N (1976) Stock Market Logic. The Institute for Econometric Research, Fort Lauderdale, Florida, USA.
  11. Nison S (1991) Japanese Candlestick Charting Techniques. New York Institute of Finance, New York, USA.
  12. Reverre S (2001) The Complete Arbitrage Handbook. McGraw-Hill, New York, USA.
  13. Schabacker R (1932) Technical Analysis and Stock Market Profits. Financial Times Pitman Publishing, London, England, UK.
  14. Schabacker RW (1934) Stock Market Profits. Financial Times Prentice Hall, London, England, UK.
  15. Schwager JD (1989) Market Wizards, Interviews with Top Traders. New York Institute of Finance, New York, USA.
  16. Schwager JD (1992) The New Market Wizards. John Wiley & Sons, New York, USA.
  17. Stridsman T (2000) Trading Systems that Work. McGraw-Hill, New York, USA.
  18. Tharp VK (1999) Trade Your Way to Financial Freedom. McGraw-Hill, New York, USA.
  19. Vince R (1992) The Mathematics of Money Management. John Wiley & Sons, New York, USA.
Citation: Ibrahim AEM (2015) Developing Profitable Trading System. J Stock Forex Trad 4:145.

Copyright: © 2015 Ibrahim AEM. This is an open-access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Top