You are on page 1of 5

2009 Sixth International Conference on Fuzzy Systems and Knowledge Discovery

An Automated Trading System with Multi-indicator Fusion


Based on D-S Evidence Theory in Forex Market

Zhihong Liu Deyun Xiao


Department of Automation Department of Automation
Tsinghua University Tsinghua University
Beijing,100084,China Beijing,100084,China
e-mail:liuzhihong06@mails.tsinghua.edu.cn e-mail:xiaody@mail.tsinghua.edu.cn

Abstract in the foreign exchange markets.Indicator analysis is an im-


portant branch of technical analysis which is derived from
Trading automation is a hotspot in the field of finan- the raw data usually including price and volume in the bar
cial research. The key to an automated trading system is chart.A technical indicator can be considered as an multi-
the buy&sell rule.Various technical indicators have been variable function of the raw data.The generic form of it can
studied and developed to generate the trading signal of be represented as
buy and sell.Each indicator has its advantage and disad-
Xn = f (On , On−1 , ...; Hn , Hn−1 , ...;
vantage.Single indicator often produces false signal which
may cause loss.In order to promote quality and reliability of Ln , Ln−1 , ...; Cn , Cn−1 , ...; Vn , Vn−1 , ...) (1)
trading signal,this paper present a method to fuse multiple where Xn denotes the calculated indicator; On denotes the
indicators based on D-S theory.Some classical indicators opening price of the nth bar; Hn denotes the highest price of
including MACD,RSI,CCI and are selected to be fused.A the nth bar; Ln denotes the lowest price of the nth bar; Cn de-
corresponding trading strategy backtesting on Euro vs US notes the closing price of the nth bar; Vn denotes the volume
dollar in 2008s is done to validate the effectiveness of this during the period of the nth bar. Although many other meth-
method compared with using single indicator. ods such as neural network[4],genetic algorithm[5]are stud-
ied and applied to forecast the foreign exchange rates,the in-
dicator analysis is still a effective method.An authentic ex-
1. Introduction planation is self-fulfilling prophecy.If enough investors sub-
scribe to the belief, it becomes a self-fulfilling prophecy.
Trading automation is a challenging area of active re- As the largest financial market, forex market has its daily
search.More and more automated trading systems are de- global turnover reaching to $3 trillion according to BIS1
veloped and running in forex market for hunting profits.An triennial survey in 2007s.Speculative trading accounts for
automated trading system (ATS),also known as algorith- 90% to 95% of the total turnover.Many paticipatants make
mic trading system or trading robot,is a computer trading their decision to buy or sell based on single or multiple in-
program that automatically submits trades to an exchange dicators that result in the self-fulfilling of some technical
based on certain algorithm[7].The key to an ATS is the indicators.
buy&sell rule,namely,entry to and exit from a position. The idea of multiple indicators fusion is motivated by
All the various methods applied in predicting the mar- two reasons. One reason is the similarity between sen-
ket movements on which the buy&sell rule based can be sor and technical indcator.Each indictor reflects the certain
characteristics of the market movement and measures the
categorized by two broad classes: the fundamental analysis
and the technical analysis[8].Fundamental analysis involves degree of this characteristics just like a sensor.Single in-
dicator has its drawback and blind zone. For example,the
evaluating an investment on the merits of its balance sheet,
products, supply and demand, and the economic climate. crossover signal of MACD is considered to be reliable for
Technical analysis is a study of past price action in mar- trend tracking,but it’s a lag signal for trading.Another exam-
ple is the passivation of RSI which means that RSI is insen-
kets, using price vs time charts and quantitative techniques,
with the objective of forecasting future price movements[9], sitive with the price change in some extreme zone.The other
which is used more widespreadly than fundamental analysis 1 Bank for International Settlements

978-0-7695-3735-1/09 $25.00 © 2009 IEEE 239


DOI 10.1109/FSKD.2009.395

Authorized licensed use limited to: National University of Singapore. Downloaded on June 30,2021 at 00:03:36 UTC from IEEE Xplore. Restrictions apply.
reason is that some evidence support the combinational use An exponential moving average (EMA), sometimes
of multi indicators.The phenomena of sympathetic vibra- also called an exponentially weighted moving average
tion of some indicators means that the more indicators in- (EWMA), applies weighting factors which decrease expo-
dicate the same direction of market movement at the same nentially. The weighting for each older data point decreases
time,the more reliable the corresponding trading signal is.In exponentially, giving much more importance to recent ob-
fact,many successful traders use multiple indicators to build servations while still not discarding older observations en-
their trading system. tirely.
This work is aimed at the fusion method of multi indic- The recursion formula of EMA(m) is represented as
tors based on D-S evidence theory.The basic scheme dia-
gram of this method is illustrated in Figure1. EMAn (P, m) = (1 − α) × EMAn−1 + α × Pn (4)
where EMAn denotes the EMA value of the nth bar
Pn denotes the applied price of the nth bar
α is a decay factor.
Let α be 2/(m + 1) ,where m is the number of periods for
calculation.
The Formula 4. can be rewritten as
Figure 1. Basic scheme diagram of multi- 2 2
indicator fusion based on D-S theory EMAn (P, m) = (1 − × EMAn−1 ) + × Pn
m+1 m+1
m−1 2
= × EMAn−1 + × Pn (5)
m+1 m+1
The structure of this paper is as follows.A brief
description of some common indicators including SMA and EMA are used to track the main trend by fil-
SMA,EMA,MACD,RSI and CCI is provided in Sec- tering the fluctuation.They are also the basis of many other
tion 2. Section 3 introduces D-S evidence theory.Based on indicators.
it,the fusion of multiple indicators is detailed in Section
4.Simulation experiment of corresponding trading strategy 2.2. MACD
test using historical data on Euro vs. US dollar is to validate
the fusion method and the result is provided in Section 5. MACD is short for Moving Average Convergence Diver-
Finally,Section 6 gives the conclusion. gence. Gerald Appel[2] introduced this indicator in 1979.
MACD has a set of two lines of EMA with different pe-
2. Description of Common Indicators riod that cross each other either low to high or high to low
as trend changes. It indicates the correlation between two
2.1. SMA and EMA price moving averages.A typical MACD is defined by

MACD = EMA(Close, 12) − EMA(Close, 26) (6)


A simple moving average (SMA) is the unweighted
mean of the previous n data points of the previous n bars’s The corresponding signal line is defined by
price.It can be calculated by
SIGNAL = SMA(MACD, 9) (7)
Pn + Pn−1 + ... + Pn−m
SMAn (P, m) =
m The basic MACD trading rule is to sell when the MACD

n
falls below its signal line. Similarly, a buy signal occurs
Pi
i=n−m when the MACD rises above its signal line. It is also popu-
= (2)
m lar to buy/sell when the MACD goes above/below zero.
where S MAn (m) denotes the SMA value of the nth bar with
the m-period; Pn denotes the applied price(generally closing
2.3. RSI
price) of the nth bar; m denotes the number of periods for
calculation RSI is short for Relative Strength Index which was devel-
When calculating successive values, a new value comes into oped by J. Welles Wilder[6].It’t used to show price strength
the sum and an old value drops out.So the recursion formula by comparing upward and downward close-to-close move-
is represented as ments. RSI is defined by
100
SMAn (P, m) = SMAn−1 −
Pn−m+1 Pn+1
+ (3) RSI(m) = 100 − ( ) (8)
m m 1 + UD

240

Authorized licensed use limited to: National University of Singapore. Downloaded on June 30,2021 at 00:03:36 UTC from IEEE Xplore. Restrictions apply.
Where U is the average number of positive price changes (H1 , H2 , ..., Hn).A basic probability assignment (BPA) is a
during m periods; D is the average number of negative price function m : 2Θ → [0, 1],such as
changes during m periods. 
RSI with its scale of 0-100 indicates the overbought zone m(Ø) = 0; 0 ≤ m(A) ≤ 1; m(A) = 1
above 70 and the oversold zone below 30.The trading rules A⊆Θ

for using RSI as an overbought or oversold is to sell when


The notation 2Θ relates to the power set of Θ. The mass
RSI is above 70 and then drop below 70.while a buy signal
function m(A) represents how strongly the evidence support
occurs when RSI is below 30 and then rise above 30.
A.
If A⊆ Θ and m(A) > 0,then A is called a focal element.
2.4. CCI A belief measure is a function Bel : 2Θ → [0, 1] , and is
drawn from the sum of probabilities that are subsets of the
CCI is short for The Commodity Channel Index probabilities in question, defined by
(CCI) is an oscillator originally introduced by Donald 
Lambert[1].Since its introduction, the indicator has grown Bel(A) = m(B), ∀A ⊆ Θ (10)
in popularity and is now a very common tool for traders in B⊆A
identifying cyclical trends.
The CCI is calculated as the difference between the typi- It represents the confidence that a proposition y lies in A or
cal price of a commodity and its simple moving average, any subset of A.
divided by the mean deviation of the typical price. The in- A plausibility measure is a function Pl : 2Θ → [0, 1] ,
dex is usually scaled by a factor of 1/0.015 to provide more defined by
readable numbers.The formula is as follows. 
Pl(A) = m(B), ∀A ⊆ Θ (11)
1 Pn − SMA(P, m)
CCI(m) = × (9) A∩BØ
0.015 σ(P)
Clearly, Pl(A) represents the degree that we fail to disbe-
where the P is the typical price (average of the high, low, lieve A. Hence, the interval [Bel(A), Pl(A)] is the range of
and closing prices,P = (H + L + C)/3), SMA is the sim- belief in A and it denotes the uncertainty of A. Bel(A) and
ple moving average, and σ is the mean deviation,m is the Pl(A) can be interpreted as the uncertain interval of propo-
number of periods for calculation. sition A , which is shown as Figure 2
The CCI typically oscillates above and below a zero line.
Normal oscillations will occur within the range of +100 and
-100. Readings above +100 imply an overbought condition,
while readings below -100 imply an oversold condition.So
a simple trading rule of CCI is to sell when CCI is above
+100 and sell when it’s below -100.

3. D-S Evidence Theory

D-S(Dempster-Shafer) evidence theory, a statistical- Figure 2. D-S uncertainty interval


based data fusion algorithm, has the advantage of presenting
and dealing with uncertain information.It is strongly the-
oretical, and can differ uncertain from unknown. It may 3.2. Dempster’s Combination Rule
deal with uncertainty caused either by random or by fuzzi-
ness. Knowledge from multiple information sources about D-S theory of evidence also provides a method to com-
events (called propositions) is combined using Dempsters bine these pieces of evidence from a number of different
rule to reduce the interval of uncertainty, and find the inter- sources by using Dempsters combination rule. This rule as-
section or conjunction of the propositions and the associated sumes that there are n independent and different sources to
probability.[3] carry the evidence. Then the function (m1 ⊕m2 ⊕...⊕mn )(A) :
2Θ → [0, 1] is also a BPA and defined by
3.1. Basic Concept ⎧


⎪ 0, A=Ø



⎨   mi (Ai )  
n n
In D-S evidence theory,there is a fixed set of n mutu- mi (Ai )
m(A) = ⎪ ⎪ ∩Ai =A i=1 ∩A =A i=1 (12)
ally exclusive and exhaustive elements, called the frame ⎪

⎪   = i 1−k ,A  Ø

n
⎩ 1−∩A =Ø i=1 mi (Ai )
of discernment [10],which is symbolized by Θ and Θ = i

241

Authorized licensed use limited to: National University of Singapore. Downloaded on June 30,2021 at 00:03:36 UTC from IEEE Xplore. Restrictions apply.
4. Multi-Indicator Fusion Based on
D-S evidence Theory

Three kinds of indicators including MACD,RSI and


CCI,previously introduced in Section 2. are adopted to be
evidence to support the decision of buy or sell.Several mass
function are built to map the domain of corresponding indi-
cator to [0,1].The final belief interval of buy or sell is cal-
culated by using the Formula 12.The trading rule based on Figure 3. The possible profile of f1 function
the belief interval are designed to build a trading strategy,of
which the backtesting result is illustrated in Section 5.The Similarly,the function of f1S can be written by the following
details of multi-indicator fusion based on D-S evidence the- form
ory is as follows. ⎧


⎪ −
(x−μ2 )2

⎪ 1
⎨ a2 √2πσ2 e 2 ,
2σ2
i f MACDn < MACDn−1
4.1. Constructing frame of discernment m1 (S ) = f1S (x) = ⎪



⎪ −
(x−μ2 )2

⎩ 1 − a2 √ 1 e 2σ22 , i f MACDn ≥ MACDn−1


2πσ2
Since the action of financial trading is either buy or (14)
sell,the frame of discernment for a trading action is very Where a1 , a2 , μ1 , μ2 , σ1 , σ2 are the parameters of the func-
simple which can be defined by Θ = (B, S ). tion which depend on the traded currency pair and sample
Where Θ denotes the frame of discernment,B denotes the period.
buy action,S denotes the sell action. The overbought zone ranged from 70 to 100 of RSI
provids a good opportunity to sell while the the oversold
4.2. Selecting evidence zone ranged from 0 to 30 provides a good opportunity to
buy.The profile of f2 function can be considered as a sig-
MACD,RSI and CCI are selected.MACD is good at moid function which is illustrated in Figure 4
tracking the main trend which will more helpful in a strong
trending market.While RSI does well in a sideways mar-
ket.CCI is used to inspect the abnormal price change. All of
the three indicators are used widespreadly.

4.3. Constructing mass functions

Let m1 , m2 , m3 be the mass function of MACD,RSI and


CCI respectively.

m1 (B) = f1B (MACD), m1 (S ) = f1S (MACD)


m2 (B) = f2B (RSI), m2 (S ) = f2S (RSI)
Figure 4. The possible profile of f2 function
m3 (B) = f3B (CCI), m3 (S ) = f3S (CCI)
The function of f2B can be written by
According to the basic trading rule of MACD,the
crossover point of two EMA line is a reliable buy signal if 1
m2 (B) = f2B (x) = 1 − (15)
the fast EMA line upwards crosses the slow line while it’s a 1+ e−0.2(x−30)
reliable sell signal if the fast EMA line downwards crosses Similarly,the function of f2S can be written by
the slow line.When the fast EMA line moves upwards,the
possible profile of the function m1 (B) = f1B (MACD) can be 1
m2 (S ) = f2S (x) = (16)
considered as a Gaussian function that’s illustrated in Fig- 1 + e−0.2(x−70)
ure 3. The function of f1B can be written by the following CCI indicates strong signal of sell when it’s above 100
form and signal of sell when it’s below -100 which is very simi-
⎧ lar to RSI.With its range of (−∞ +∞),it can avoid the phe-


⎪ −
(x−μ1 )2

⎪ √ 1
⎨ 1 2πσ1
a e 1 ,
2σ2
i f MACDn > MACDn−1 nomena of passivation. The f3 can be also considered as a
m1 (B) = f1B (x) ⎪
⎪ sigmoid function. f3B can be written by


(x−μ1 )2
⎪ 1 − a √ 1 e− 2σ21 , i f MACD ≤ MACD
⎩ 1 2πσ n n−1
1 1
(13) m3 (B) = f3B (x) = (17)
1 + e−0.2(x+100)

242

Authorized licensed use limited to: National University of Singapore. Downloaded on June 30,2021 at 00:03:36 UTC from IEEE Xplore. Restrictions apply.
Table 1. Trading Rule Table Table 3. Backtesting Resuslt
conditions actions indicator signal number correct signal annual return(%)
T ∈ [Bel(B) Pl(B)] open a long position MACD 73 47 533(5.33%)
and Pl(B) − Bel(B) ≤ U or hold the long position RSI 196 135 -961(-9.61%)
T ∈ [Bel(S ) Pl(S )] open a short position CCI 175 126 718(7.18%)
and Pl(B) − Bel(B) ≤ U or hold the short position Fused 32 25 1837(18.4%))
Pl(B) < T close the long position Indicator
and Pl(B) − Bel(B) ≥ U or keep the neutral position
Pl(S ) < T close the short position
and Pl(S ) − Bel(S ) ≥ U or keep the neutral position 6. Concluding Remark and Future work
otherwise keep the neutral position
An automated trading system using multiple indicators
fusion based on D-S evidence theory has been described in
Table 2. Table of Test Information this paper.It’s just a attempt to apply fusion theory to trad-
initial deposit: $10000 ing area.Backtesting result on historical data shows that the
currency pair: Euro vs US dollar fused indicator can produce more reliable signal and return
transaction cost: 2 pips spread than single indicator.But the parameter set of the fused indi-
time range: 2008.01.02 - 2008.12.31 cator mainly depend on expert experience which can’t pro-
time frame(sample period): 1 hour duce stable and consistent return.The future work will be
ratio of leverage: 1:1(without leverage) aimed at the self regulation of the parameter.
test platform: Matlab and Meta Trader
trading rule:refer to Table 1.
References

f3S can be written by [1] D.R.Lambert. Commodity channel index: Tool for trading
cyclic trends. Commodities Magazine, 1:120–122.
1 [2] G.Appel. The Moving Average Convergence-Divergence
m3 (S ) = f3S (x) = (18)
1+ e−0.2(x−100) Method. Signalert, Great Neck, NY, 1979.
[3] G.Shafer. A mathematical theory of evidence. Princeton
The combinational mass function is University Press, N.J., 1976.
[4] I.Kaastra and M.Boyd. Designing a neural network for fore-
m(B) = m1 (B) ⊕ m2 (B) ⊕ m3 (B) (19) casting financial and economic time series. Neurocomput-
m(S ) = m1 (S ) ⊕ m2 (S ) ⊕ m3 (S ) (20) ing, 10:215–236, 1996.
[5] J.C.Dempster. A real-time adaptive trading system using ge-
The value of m(B) and m(S) can be calculated refer- netic programming. Quantitative Finance, 1:397–413, 2001.
ring to Formula 12. The belief interval [Bel(B) Pl(B)] and [6] J.W.Wilder. New concepts in technical trading systems.
[Bel(S ) Pl(S )] can be also derived referring to Formula 10 Commodities Magazine, 10:215–236, 1978.
and 11. [7] L.Harris. Trading and Exchanges Market Microstructure for
Practitioners. Oxford University Press, London, 2003.
[8] M.Rosenberg. Currency Forecasting:A Guide To Funda-
5. Trading Strategy Backtesting mental and Technical Models of Exchange Rate Determina-
tion. Irwin Publishing, London, 1996.
In order to generate reliable trading signal based on be- [9] Murphy.J. Technical Analysis of the Financial Markets:A
Comprehensive Guide to Trading Methods and Applica-
lief interval.Two thresholds are introduced.One is trigger
tions. Prentice Hall Press, N.Y., 1999.
threshold -T ,the other is uncertainty threshold -U.The cor- [10] Y.G.Wu and K.Liu. On the evidence inference theory. IN-
responding trading rule is specified in the Table 1. FORMATION SCIENCES, 89:245–260.
Trading strategy backtesting aims at the Forex market.
Due to the high liquidity,low transaction cost and unmanip-
ulability,Euro vs US dollar is chosen to be the candidate.
The inforamtion of the strategy test are listed in Table 2.
The backtestting result is illustrated in Table 3. The re-
sult shows the fused indicator has a good performance with
the 37% annual return in 2008s. Although the number of
trading signal is less than any of three other indicator,the
percentage of correct signal is rather high.

243

Authorized licensed use limited to: National University of Singapore. Downloaded on June 30,2021 at 00:03:36 UTC from IEEE Xplore. Restrictions apply.

You might also like