0% found this document useful (0 votes)
74 views6 pages

Folts PDF

This document discusses trend following strategies for stock market trading. It begins by introducing trend following as a trading strategy that aims to take advantage of long-term price moves in markets. It then discusses two main approaches to analyzing markets: fundamental analysis and technical analysis. The rest of the document focuses on trend following strategies, outlining some key principles such as cutting losses and letting profits run. It proposes using statistical rules to define trend following strategies and automate trading based on trends in market prices.

Uploaded by

The_Sun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views6 pages

Folts PDF

This document discusses trend following strategies for stock market trading. It begins by introducing trend following as a trading strategy that aims to take advantage of long-term price moves in markets. It then discusses two main approaches to analyzing markets: fundamental analysis and technical analysis. The rest of the document focuses on trend following strategies, outlining some key principles such as cutting losses and letting profits run. It proposes using statistical rules to define trend following strategies and automate trading based on trends in market prices.

Uploaded by

The_Sun
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

The Application of Trend Following Strategies in Stock Market Trading

Simon Fong, Jackie Tai


Department of Computer and Information Science
University of Macau, Macao SAR
[email protected]

Abstract— Trend-following (TF) strategies use fixed trading classical example of failure. Furious debates still continue on
mechanism in order to take advantages from the long-term the efficacy of fundamental analysis, so are other analysis.
market moves without regards to the past price performance. The second popular approach into market forecasting is
In contrast with most prediction tools that stemmed from soft- called technical analysis that works in opposite principle of
computing such as neural networks to predict a future trend, the fundamental analysis. The underlying philosophy for this
TF just rides on the current trend pattern to decide on buying approach is that the market prices well reflect all known
or selling. While TF is widely applied in currency markets with factors at all times. So the price is already a solid
a good track record for major currency pairs [1], it is doubtful performance indicator as a result of the supply and demand
that if TF can be applied in stock market. In this paper a new
for that particular market. Therefore technical analysis
TF model that features both strategies of evaluating the trend
evaluates solely on the market prices themselves rather than
by static and adaptive rules, is created from simulations and
later verified on Hong Kong Hang Seng future indices. The on any fundamental factor else outside the market. Traders
model assesses trend profitability from the statistical features who are solely armed with technical analysis suppose that a
of the return distribution of the asset under consideration. The careful analysis of daily price movement as well as a long
results and examples facilitate some insights on the merits of term trend is all that is required to predict a price trend for
using the trend following model. their trading.

Keywords-Trend-following, Stock Market, Trading Algorithm II. TECHNICAL ANALYSIS


For decades traders were hoping to have some reliable
I. INTRODUCTION decision making tools that would assist them in market
forecasting. Many such tools are available both as
Trend following is a simplistic trading strategy that tries commercial products and research prototypes. Predicting
to take advantage of long-term moves that seem to play out market trends is a hot area in the academic research
in various markets. A trend following system aims to work community using methods of soft computing. Some popular
on the market trend mechanism and take benefit from both choices are Genetic Algorithms [3], Support Vector
sides of the market being able to gain profits from the ups Machines [4], and Artificial Neural Networks [5, 6]. They
and downs of the stock market. Traders who use this are used to analyse past financial data ranging from ten to
approach can use current market price calculation, moving twenty years to attempt to divine the market direction. Many
averages and channel breakouts to determine the general research papers in the literature claim that they yield
direction of the market and to generate trade signals. Traders significant results of “indicators” and they offer pretty good
who opt for trend following strategy do not aim to forecast or accuracy. Still, the question of whether technical analysis
predict markets; they simply jump on the trend and ride it. works has been a topic of contention for over three decades.
Basically there are two approaches for gaining insights of Can past prices forecast future performance?
the markets in trading. Fundamental analysis is one of them On the other hand, there is an alternative type of
and also the most commonly used approach in studying the technical analysis that neither predicts nor forecasts. This
markets. This analysis considers many external factors that kind is entirely based on price. Instead of striving to predict a
are supposed to affect the supply and demand of a particular market direction, this strategy is to react to the market’s
market. Sources from which the information can be obtained movements whenever they occur; hence the name Trend
for fundamental analysis may include government policies, Following (TF). TF responds meticulously to what has
domestic and foreign events, political and economic news, recently happened and what is currently happening, rather
and cooperates’ annual reports. By carefully examining the than anticipating what will happen. TF is solely based on
supply and demand factors, or “fundamentals” for a some statistically trading rules. In [7], a simulator has
particular market, it is believed to possibly predict changes in attempted to program TF into trading agents which base on
market conditions. These changes are then supposedly linear regression of direct market trends. The obvious
related to the fluctuation of the price of the market. It was challenge for generating profits in this strategy is how to
however argued that nobody can be absolutely certain about define such rules. The rules are usually derived from the
the accuracy of the market information. Market trends traders’ judgments and are subjective in nature. A main
change upon a flux of news that come by every day is too contribution of this paper is to define and program these
complex to be accurately analyzed [2]. The bubble burst of rules into an automated trading simulator.
dot-com stocks by the hype of “new digital economy” is one
III. PRINCIPLES OF TREND FOLLOWING METHODS increase of the initial trade. Conversely, certain adverse price
Some principles of trend following methods are reviewed movements may lead to an exit for the whole trade.
here [8]. In the later section we proposed a logical way of When there is a turn detected in contrary to the trend, the
setting the rules. The success of Trend Following strategies system will have to decide whether to signal a pre-
obviously depend on certain underlying assumptions. The programmed exit or wait until the turn establishes itself as a
first assumption is the regular occurrence of price trends that trend in the opposite direction. If the situation favours an exit
are resulted from a variety of factors. The trends go up and as reasoned by the rules, the system will re-enter when the
down all the time in markets. Market prices are the objective trend re-establishes. In order to have the TF trading system
data as they are the ultimate indicators reflected from the automated, we need the following elements to be considered.
factors. The price movements are enough for making Trade Management: Some rules are implemented over
decisions in trading, and little anything else according to TF the decision of how much to trade over the course of the
strategies. Individual price histories and charts can just be trend. This includes decision of how much to trade at each
used as primary data for TF trading program to operate. time, and how much money to risk in each trade. In order to
Secondly, the success assumes that TF trading systems minimize risk, for example, the trading size is reduced
can possibly harvest profit from these trends. As believed by during periods of higher market volatility or losing periods.
some experts, the basic trading strategy that all trend The trade is managed to let the profit runs when market is
followers try to systematize is to ‘cut losses’ and ‘let profits good, and holds back during bad times to preserve capital
run.’ This basic premise is that the most profit is gained until more positive price trends reappear.
when a trader is synchronized to an enduring trend. To do Market Price: The market price should be the sole input
this, traders need to adopt a strict discipline that minimizes data to the system. Although there could be information
behavioral bias (i.e., intuitive or “gut” feel). It does not derived from the market price history, as a general rule other
anticipate a trend beginning or end, and acts when the trend indicators estimating where price will go next should be
changes. disregarded. In order to run the TF system in real-time,
Based on this premise, a Performance Probability Score likewise must be for the availability of the latest market
(PPS) model [8] was proposed as a classic approach to trend price. Price and time are pivotal at all times.
following. PPS incorporates analysis of relative valuation Rules: The main rules are simply to maximize profiles
and relative price performance to produce risk and reward and cut losses. The rules operate systematically and
expectations for individual stocks. The core of the model is a objectively without consideration of any analysis of
binary separation of whether long-term relative price fundamental supply or demand factors. The rules automate
performance is positive or negative. Price performance is the trading by making decisions on when to enter the market,
used as a key indicator derived from the price trend over a for how long to stay in a trade for profit, and when to exit the
reasonable length of time. Trend following is doing the trade if it becomes unprofitable.
same. The basic rule of PPS is to stay with a positive or We proposed a new model that is derived from PPS but
negative rating until a definable change has occurred. In with more accurate and more adaptive detection of the
other words, PPS does not anticipate changes in trends. change(s) that trigger a buy or sell action. Hence some rules
must be formulated for determining when to enter or exit a
position in the market based on two important signals. The
two signals that are directly derived from the market price
trend tell us when to enter a market, and when to exit a
market. These two signals are two fundamental variables in
defining the rules of the trading model.
A. Static P & Q Rules
Trading rules are the underlying mechanism of a TF
system. In our model, the rules mainly depend on two
variables, namely P and Q. P is defined to be the amount of
the trend in the upward direction that triggers a position to be
opened. Literally P stands for a proposition for signaling it is
time to enter the market since certain significant progress of
Figure 1. Division of relative price strength along the price trend.
market growth is observed. Q is the amount of opposite trend
(Source: Legg Mason) after a pivotal turn that will cause an opened position to
close. Q can simply be considered as a signal to quit the
trade from the market in order to prevent any deep loss.
IV. OUR PROPOSED MODEL Let T denotes the market trend which is a continuous
Based on the concept of the PPS model, our model curve made up of Price(t) in the function of time t. For
attempts to reap profits from the difference of the initial example in the following diagram, it will open a long
market price and the market volatility. Changes in price position when the current Price at point t over the trend T
mean opportunities that may lead to a gradual reduction or advances over P; and it will close out the position when the
trend T declines deeper than Q.
believed that market data is a reflection of the consequent
trends and they are sufficient for references.
The values of P and Q, therefore can be either found by
brute-force or heuristic methods based on the historical
methods. In brute-force method, all combinations of P and Q
values are tried exhaustively over a sample, and observed for
the best performing pair as shown in Figures 3 and 4.
Alternatively, an artificial neural network can be trained
Figure 2. P and Q over the price trend T and EMA(T) by using historical dataset to estimate the most profitable set
of P and Q values. For instance a pair of optimal P and Q
However in reality the market price trend doesn’t go values could be derived from a sample of Hang Seng index
constantly on a straight line; it is much volatile that the line future contract used in an artificial neural network as in our
fluctuates up’s and down’s repeatedly. Therefore it is not experiment. A forward feed neural network with a hidden
possible (at least not practical) to apply the P & Q rules layer of 20 neurons was tested to give reasonable results. A
directly on the trend T because the frequent fluctuation will 10% random sampling of dataset across ten years of records
alarm off too many signals of trading actions. In order to could be used as training set.
compromise this fluctuation, an Exponential Moving By the nature of neural network whose initial weights
Average (EMA) is adopted and upon which we applied the were set randomly and different samples were selectively
rules. EMA at the time of t is calculated as follow, used in the training phase, a range of P and Q values could
 2  be possibly obtained. Some post-processing was required to
EMA ( t ) =  price ( t ) − EMA ( t − 1) ×  + EMA ( t − 1) narrow the choices of P and Q values into a reasonable
 n +1
where price(t) is the current price at time t, n is the number range. If any of the P and Q values gets too small, then there
of periods in minute for intra-day trading or days in inter-day will be too many order executions. If the value is too large,
trading, and t is any given market time. Using P&Q rules on for example 1000, there may be no order execution at all.
EMA helps to smooth a fluctuating trend. The logic of the
trading rule by using P&Q is shown in pseudo-code as
follow.
P=294 Q=0
Pseudo code of Static P&Q Rule
Repeat
Compute EMA(T)
If no position opened
If EMA(T) >= P Q=278
If trend is going up
Open a long position
Else if trend is going down P=0
Open a short position Start Observation
Else if any position is opened
If EMA(¬T) >= Q
Close position
If end of market
Close all opened position Figure 3. Ranges of P and Q values obtained from heuristic measures
Until market close
Test Case 2: Q Incremental and P Static
5000
Our method as depicted in the pseudo code above, entails 4500
4000
using a moving average, for a set of market price data, to 3500
3000
determine when to enter the market and when to exit. Profits I
O
R 2500

and losses were made along the way between buying and 2000
1500
selling. The number of days n used to calculate the moving 1000
500
average is found by observing which value of n gave the best 0
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97
profit over a reasonable length of time. Q Value
Test Case 1: P Incremental and Q Static
In other TF systems, values for P and Q, or such similar 4000

parameters were either chosen arbitrarily or by subjective 3500

3000
intuition of some experienced human traders. In some cases, 2500
the two parameters are represented by a single threshold I
O
R 2000

whose value was calibrated intuitively. The threshold was 1500

1000
used as a baseline to indicate appropriate timings of buying 500
and selling. Those systems yielded certain results although 0
1 5 9 13 17 21 25 29 33 37 41 45 49 53 57 61 65 69 73 77 81 85 89 93 97
not optimum. In our model, the value of P and Q are derived P Value

empirically from the historical market price data as it is


Figure 4. By holding the other value constant, it is possible to have
multiple values of P and Q that generate good profits
B. Adaptive P & Q Rules The ideas that hold true for oscillators in general hold
Previously, the values of P and Q are obtained from true with the RSI. The oscillator will frequently turn around
considering the combo values that give the best performance before the price does – for example, a price still rising that is
over a relative long period of time. It is intuitively observed accompanied by a falling RSI produces a bearish divergence
that the lengths of P and Q that worked well in a particular between price and oscillator, a major warning that the
section of a trend may not do the same in other situations. uptrend is running out of steam.
Hence the process of generating the P and Q values should Note that 70 and 30 are typical values for RSImax and
be modified such that they would dynamically change to RSImin respectively. These two thresholds can be arbitrarily
adapt to the real-time market trend. chosen by traders. In our experiments, we set RSImax and
In this adaptive operation, the amounts of progress and RSImin to be 60 and 40 that narrows the range by an offset of
decline that govern the buying and selling are calculated in 10 for less-risky trading.
real-time at regular intervals along the market trend. Hence,
P' and Q' are two new variables that are used in the trend
following algorithm for the same purposes. They have
basically the same meaning as P and Q in the rules of trading
except that their values may change dynamically in different
parts of the trend instead of remaining constants.
In this case, some additional technical analysis that helps
determining the buying and selling positions in real-time is
desirable for adjusting the P' and Q'. Relative Strength Index
(RSI) is one of the popular approaches for this purpose. RSI
is a technical momentum indicator that compares the
magnitude of recent gains to recent losses in an attempt to
determine overbought and oversold conditions of an asset.
The advantage is that it reflects signals of overbought or
oversold in real time as the market progresses. It is Figure 5. Figure 5. Illustration of RSI and its maximum and minimum
calculated using the following formula: thresholds (Source: Investopedia)
100
RSI ( t ) = 100 −
1 + RS A trader using RSI should be aware that large surges and
AU(t) drops in the price of an asset will affect the RSI by creating
RS = false buying or selling signals. The RSI is best used as a
AD(t)
Up ( t ) + Up ( t − 1) + ......Up ( t − n + 1) valuable complement to other stock-picking tools. In our
AU (t ) = adaptive P&Q strategy, RSI is used as a main reference index
n in calculating P' and Q' in real-time. By studying the
Down ( t ) + Down ( t − 1) + ...... Down ( t − n + 1)
AD (t ) = interaction of how the indicator reacts to the market, we can
n derive the criteria as follow, which depict the situation ready
for a position to open.
where AU is average price upward in n periods, AD is
average price downward in n periods , n is the number of RSI For long position, at P'
periods that is usually taken as 14 by most analysts. 1. Price is advancing
One example is given below in Figure 5, the RSI ranges 2. RSI(t) is greater than EMA(RSI(t))
from 0 to 100. An asset is deemed to be overbought once the 3. EMA(RSI(t)) is less than 40 or greater then 60
RSI approaches the 70 level, meaning that it may be getting For short position, at Q'
overvalued and is a good candidate for a pullback. Likewise, 1. Price is declining
if the RSI approaches 30, it is an indication that the asset may 2. RSI(t) is less than it EMA(RSI(t))
be getting oversold and therefore likely to become 3. EMA(RSI(t)) is less than 40 or greater then 60
undervalued. According to [9], the following three
observations are classical and well known by stock market The following diagram shows an example of a long
technical analysts. position opened at time 10:35 after the long position criteria
• Above 50, the internal strength of the market is are met, and closed out at time 13:36 1 when the short
considered bullish; below there, considered bearish. position criteria are met. The values of P' and Q' now change
• Above 70 is a bullish danger zone, considered to adaptively and dynamically according to and along with the
represent an overbought market that will correct sooner RSI. As the trading goes, the criteria assess the fluctuating
or later. trend of the market and trigger positions to be open or close.
• Below 30 is a bearish danger zone, considered to
represent an oversold market that will rally sooner or 1
In Hong Kong stock market there’s a two hours break between morning
later. and afternoon sessions, to avoid this discontinuation on the chart, we
shifted the time backward, and joined this two sessions into one, so 13:36 is
equivalent to 15:36.
The ROI is calculated based on the assumption that one
contract is traded with the initial capital of HKD 100,000, the
average monthly ROI is the total ROI divided by the number
of months in the length of the simulation.
• Read in the stock market data from a file.
• Calculate the EMA and RSI for some given values of
parameters, such as n the period of time.
• Feed the data into the two P&Q strategies, static and
Figure 6. Figure 6. P' and Q' are determined by the criteria of adaptive adaptive, and generate the buying and selling signals -
strategy.
During the simulation, when the reversal of trend gives
rise to P and Q conditions, then our trading strategy
To program this strategy into an automated trading
regard this situation as a buying signal and selling
simulator, the following pseudo-code is used:
signal respectively.
Pseudo code of Adaptive P&Q Rules • Simulate the trading by calculating the profits each day
Repeat and subtract costs if there is a trade.
Compute RSI(t) and EMA(RSI(t)) • Run this for many values of n and summarize the
results including the ROI.
If price is advancing at t
If RSI(t)>EMA(RSI(t)) and 40<EMA(RSI(t))>60 The following diagram shows the simulation of both
If no position opened strategies with respect to the Hang Seng index performance
Open a long position, P' as a base line. The base line could represent a buy-and-hold
Else if short position opened strategy that suffers an overall depreciation in value when
Close out short position, Q'
Else if price is declining at t the whole trend is sinking down in performance as shown in
If RSI(t)<EMA(RSI(t)) and 40<EMA(RSI(t))>60 the diagram. The two P&Q strategies of TF however in
If no position opened contrast, are gaining in increasing the values of the initial
Open a short position, Q'
Else if long position opened
capital; the lines show that profits can be reaped even during
Close out long position, P' those bad times when the market index was going down.
If end of market The dates are normalized, taking the starting date of the
Close all opened position input data as the initial date in the simulation. Figure 8 shows
Until Market Close
a snapshot of daily profits gained and daily losses incurred
on a daily basis. In general, when the total trading events are
V. SIMULATION EXPERIMENTS AND RESULTS averaged out, there are more profits than losses both in
magnitudes and in counts.
The purpose of this simulation experiment is to verify Table 1 shows a summary list of results extracted from
that the effects of P&Q strategies in applying trend the simulation graph in Figure 7. It shows in comparison of
following, and to compare the static and adaptive P&Q the performance of the static and adaptive versions of P&Q
strategies. Most importantly the simulator is to prove the strategies in trend-following. Overall, we can see that the
possibilities that TF can yield profits in market trading, by adaptive P&Q outperforms the static one because the rules of
strictly following the rules in a computer program. opening and closing a positions can be better estimated based
Our experiment simulates intraday trading on Hang Sang on real-time RSI. They are adaptive in real-time to the ever
future contract, which is stored in data file with daily records changing market trend. Both trend-following strategies
in year 2008; with a total size of 355 days. Hang Seng Index however are yielding impressive results in average monthly
is founded in 1969 November, it is composed of 36 different ROI, amounted to 67.67% and 75.63% respectively based on
securities including some well-known companies such as Li our simulation results.
Ka Shing's Cheung Kong, HSBC holdings and China
Mobile. It is the second largest stock market in Asia in total CONCLUSION
capital that is worth of USD $1.6 trillion by 2007 January.
Technical trading can be predictive or reactive. Trend
We use the indices as our to-be-estimated target to
followers just follow the trend, they don't predict the trend.
represent the average of all companies and balanced
This enables traders to focus on the market and not get
portfolios which approximates the overall market returns. emotionally involved. Trend followers expect and handle
The reason that we use indices rather than individual stocks
losses with objectivity and detachment.
is that we suppose the market index can balance the bias for
It is believed that trend following strategies can be used
choosing stocks and eliminate the influence of single stock.
for profitable trading in stock market. The idea is to
One important resultant variable in our simulation is the
automate the buying or selling process depending on the
returns on investment (ROI) on common shareholder's
position of the price relative to a long time moving average
equity. In this study, we are going to use the average ROI of
value. We tried to verify this TF phenomenon by adhering to
overall stock in a specified market as a performance
the trading rules. Such rules are used in TF but in the past
indicator for comparing the two variants of trend following
they were manually defined. In this project we formulated
strategies.
the TF trading rules and their parameters heuristically, and
we programmed them into a simulator. The contribution of Evolutionary Computation Conference, Seattle, USA, July 2006,
this work forms a cornerstone for future development of pp.1857-1858
automated trading system based on TF principles which are [4] Y. Sai, Z. Yuan, K. Gao, "Mining Stock Market Tendency by RS-
Based Support Vector Machines", The 2007 IEEE International
discussed in section 3. Two different TF strategies namely Conference on Granular Computing, Silicon Valley, USA, November
static P&Q and adaptive P&Q are proposed and our 2007, pp.659-664
simulation results show that they give positive trading profits [5] S. Xu, B. Li, Y. Shao, "Neural Network Approach Based on Agent to
even when the stock market index is declining at the bad Predict Stock Performance", IEEE International Conference on
times. We would be testing TF strategies with more data. Computer Science and Software Engineering, Vol.1, Wuhan, China,
December 2008, pp.1223-1225
[6] R. Makwana, Financial Forecasting Using Neural Networks, ADIT
REFERENCES Journal of Engineering, Vol.2, No.1, December 2005, pp.56-59
[1] J. James, Simple trend-following strategies in currency trading [7] A. Sherstov and P. Stone, "Three Automated Stock-Trading Agents:
Quantitative Finance 3, 2003, C75-C77 A Comparative Study", In P. Faratin and J.A. Rodriguez-Aguilar,
editors, Agent Mediated Electronic Commerce VI: Theories for and
[2] C. Robertson, S. Geva, R. Wolff, "What types of events provide the Engineering of Distributed Mechanisms and Systems (AMEC 2004),
strongest evidence that the stock market is affected by company Lecture Notes in Artificial Intelligence, Springer Verlag, Berlin,
specific news", Proceedings of the fifth Australasian conference on 2005, pp. 173–187
Data mining and analystics, Vol. 61, Sydney, Australia, 2006, pp.145-
153. [8] Covel, Michael, Trend Following: How Great Traders Make Millions
in Up or Down Markets, Financial Times, Prentice Hall Books, 2004
[3] D. Fuente, A. Garrido, J. Laviada, A. Gomez, “Genetic algorithms to
optimise the time to make stock market investment”, Genetic and [9] J. Welles Wilder, New Concepts in Technical Trading Systems, 1978

Static Dynamic Hang Seng Index

40000

Performance by Adaptive P&Q


30000

20000

Performance by Static P&Q


t
in
o
P
x 10000
e
d
n
I

1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341

-10000

Market trend
-20000

No. of Date

Figure 7. Simulation experiment of trading on Hang Seng Index using trend-following strategies.

Dynamic: Daily Profit and Loss


TABLE I. SUMMARY OF RESULTS FROM THE
2000
SIMULATION EXPERIMENT

1500

1000

t
in
o
P
x 500
e
d
n
I

1 21 41 61 81 101 121 141 161 181 201 221 241 261 281 301 321 341

-500

-1000

Figure 8. Daily profits and losses occurred in the adaptive P&Q TF trading.

You might also like