Content uploaded by Cristian Păuna
Author content
All content in this area was uploaded by Cristian Păuna on Dec 25, 2018
Content may be subject to copyright.
DOI 10.1515/rebs-2018-0070
Volume 11, Issue 2, pp. 9-20, 2018
ISSN-1843-763X
RELIABLE SIGNALS AND LIMIT CONDITIONS FOR
AUTOMATED TRADING SYSTEMS
CRISTIAN P*
Abstract: Automated trading software is a significant part of the business intelligence system
in a modern investment company today. The buy and sell orders are built and sent almost
instantly by computers using special trading and computational strategies. The trading
decisions are made by automated algorithms. In this paper it will be presented one of these
mathematical models which generate trading signals based only on the time price series. The
algorithm combines several known computing techniques to build a trading indicator to
automate the trades. With this method, buy decisions on oversold intervals and sell decisions
on overbought price values can be built. Limit conditions in order to close the long and short
trades can be also automatically generated. More trading signal types based on this model
will be revealed. Trading results obtained with all these signals will be presented in order to
qualify this methodology developed especially for algorithmic trading.
Keywords: financial markets (FM), trading signals (TS), limit conditions (LC), algorithmic
trading (AT), automated trading software (ATS)
JEL Classification: M15, O16, G23, M21
1. INTRODUCTION
In the business intelligence system of any modern financial investment
company, the ATS have a The purposed objective of the
ATS is to generate profit
through mathematical algorithms. The buy and sell orders are built and sent almost
instantly by specialized servers using advanced computational techniques.
Similarly, the closing trade decisions are made also automatically by special
procedures. This paper will present a mathematical model which can be used with
good results to build automated trading orders to entry on the financial markets and
also to implement the automated exit decisions in algorithmic trading.
* Economic Informatics Doctoral School Academy of Economic Studies, 11th Tache
Ionescu str. 010352 Bucharest, Romania, email: cristian.pauna@ie.ase.ro
Cristian Păuna
10
questions are when a market is dropped enough in order to take a buy decision with
a reasonable risk and when the price has increased enough in order to exit the buy
trade or to sell? How to take these decisions? And how to automate them? The
model presented in this paper will permit to answer all these questions. Being
exclusively a mathematical model based on the price time evolution, the algorithm
can be easily implemented in any ATS in order to automate the trade process.
The trading methodology presented here uses several well known
computation techniques as exponential and weighted moving averages (Cox,
1961), relative strength index (Wilder, 1986) and inverse function of the Fisher
transform (Ehlers, 2004), knowledge that will not be presented in this paper. A first
objective of this article is to reveal how all of these techniques can be combined
together in order to build a reliable trading indicator. The developed method is
practically the inverse Fisher transform of the relative strength index of the
smoother exponential moving average of the time price series. We will call this
indicator Inverse Fischer Smoothed RSI, on short IFR.
Another purpose of this paper is to describe how the buy and sell decisions
can be automated using the IFR function. The last target is to build limit conditions
based on the IFR indicator in order to stay away the market on the overbought and
oversold price periods, to reduce the exposed risk. These limit conditions can be
combined with any other trading methodology in order to increase the trading
profitability. Some real trading results will be also presented in the last chapter in
order to have a measure for the efficiency level of the presented trading method.
2. THE MODEL
The development of the method starts considering a price time series given
by open, high, low and close values for each time unit in a considered time
interval. The time unit is not important; the method can be applied for any
timeframe. As we can see in the figure 1.A., the price series gives us no clear
indication about the next movement. In addition, due to the price volatility
differences, the price makes ample moves in some intervals and small amplitude
movements in others. Using only the price graph we cannot take an automated
decision to know when is good to buy or to sell.
One of the objectives of the IFR method is to find the intervals when the
price is overbought or oversold. With other words, we want to find those intervals
Reliable Signals and Limit Conditions for Automated Trading Systems
11
11
when the price is close to change its direction. If those intervals will be found,
trading and limit conditions can be set in order to manage the trading decisions.
First step is to reduce the time price series to a smoothed price line, a line
that can represent the movement of the main price trend. There are several known
methods to convert the price time series to a smoothed price line. Simple moving
averages with a short periods (Cox, 1961), polynomial, trigonometric or least
square regressions (Berbente, 1997) or simple Spline lines interpolation functions
(Reinsch, 1967) can be used in order to figure the price evolution in time.
In the presented model, for simplicity, the smoothed price line (SPL) is
given by a 4 period weighted moving average. The SPL can be shown in figure
1.A. overlapped with the price graph. The SPL function is still in the price space
and has values in accordance with the current price evolution. We will note (SPLi)
the SPL value for each (i) time unit. The next step is to reduce this function to
another one in a much limited interval space.
Figure 1. IFT of EMA of RSI of SPL (IFR) for DAX30 index
Applying the relative strength index (RSI) methodology to the SPL function
we will obtain the graph represented in the figure 1.B. We will note the values of
this function for each time unit with (RSIi). The variation of this function is limited
into a smaller interval as we purposed.
As we can see in the figure above, due to the price volatility, the RSI
function presents some false direction points. There are moments when the
function is not decided about the next direction. After a small down movement the
value is going up and down again after a little while. This is happening often when
Cristian Păuna
12
the price is close to change the direction. We wish a better function with no such of
undecided movements. An attenuation method can solve these false points. The
next step is to apply the exponential moving average (EMA) technique to the RSI
function in order to attenuate the values.
The EMA permits to obtain a more stable function practically with no time
delay for this case. The results can be seen in the figure 1.C. With a 10 period EMA,
the values noted with (EMAi) are more stable and the unstable cases of the (RSIi)
values were filtered. To determine the intervals where the price is overbought or
oversold a new transformation must be used. For the known advantages we will use
the Fischer transform function, in this case in the inversed form.
We will apply the inverse Fisher transform function to the (EMAi) values with:
(1)
The new function
interval [0; 100], as it is presented in the figure above.
The IFR function is the final function of our model, their values noted (IFRi)
have a similarity in variation with the price function and gives us more information
about the price evolution as we will see. This function has some particular
characteristics which help us to build the trading and limit conditions presented in
the next chapters.
Even to obtain the values of the IFR function implies to use some advanced
mathematical techniques, to implement this function in AT as part of an ATS is a
simple task. The code sample for IFR indicator in meta quotes language (MQL) is
presented in figure 2.
Figure 2. IFT indicator multi query language code
Different versions of this algorithm can be imagined in order to improve the
results. The values of SPL function can be built in different ways as we presented.
Before to apply the inverse Fisher transform, in the (EMAi) values can also be
inserted more information about the historical price using values (EMAk) for k
Reliable Signals and Limit Conditions for Automated Trading Systems
13
13
historical intervals, with k<i. Polynomial functions can be used in order to insert
historical values:
(2)
k is a weighting
coefficient for each time unit included. k are functional parameters
that are the subjects of an optimization process of the indicator for each financial
market and timeframe used in order to optimize the risk and exposed capital for the
traded strategy. These coefficients are computed by repetitive procedures
considering the historical time price series for each market. A machine-learning
procedure can be organized in order to improve the functional parameter set time to
time. In practice the n number of time intervals included in the method are usual
n=2 or n=3. For higher values of the n parameter, the computational effort is
increasing without a significant change in the model precision.
3. LIMIT CONDITIONS
The main characteristic of the IFR function is the asymptotic behavior on
those intervals when the price is preparing to turn the direction. This behavior is
due to the usage of the inverse Fisher function. Using this property we can set some
conditions in order to define if a price is overbought or oversold. These Boolean
conditions will be set by:
(3)
conditions is simple: buy on market or keep the buy trades opened until the (IFRi)
i) values
o be the
safe limit for the trading model. From this reason we will call these conditions as
minimizing the risk and maximizing the profit.
The limit conditions presented in (3) can be used in order to filter the trades
made by any other trading strategy. With a good parameter set, this data mining
method will considerably filter the trades in order to improve the trading
efficiency. To see the power of this simple limit conditions we will present the
example below.
Cristian Păuna
14
trading signal was traded with and without the IFR overbought limit conditions
included in (3). How the trading signal is built is not important for this example.
The trading signal played did not have something in common with the IFR
function. This example wants to reveal here only the power of the IFR limit
conditions.
IFR limit
conditions
(3)
Number
of trades
Profit
Drawdown
Risk to
reward ratio
Without IFR
258
1,003
28,824
1:0.03
With IFR
147
38,011
9,194
1:4.13
Table. 1. Trading results obtained with and without IFR limit conditions
The numbers presented in Table 1. Were obtained executing only buy trades.
T
overbought limit conditions more trades were executed, with 75,75% more trades
than the case when IFR conditions were used. A part of these additional trades
were in profit but another small part made a heavy loss. This is because buy trades
were opened on overbought price intervals, on intervals where the price was near a
local or global maximum point, according to the Fischer function methodology.
condition is used, even the number of trades is less, the profit obtained is
significant higher, much higher than the profit without the overbought conditions.
The test above was made in the period 01.06.2015 31.05.2018. As we can see in
the figure 4, no losing trade was obtained using the IFR conditions.
Figure 3. Capital evolution without IFR overbought limit condition
Reliable Signals and Limit Conditions for Automated Trading Systems
15
15
Figure 4. Capital evolution with IFR overbought limit conditions
A main characteristic of the IFR function are the monotony intervals. There
are clear increasing or decreasing intervals indicating the tendency of the price.
each market. Or the example presented in this paper, the correlation coefficient
calculated on intervals between 20 and 100 time units on a ten years time interval
for several timeframes (M5, M15, M30, H1, H4 and D1) has values between 0.486
and 0.981 for the DAX30 Index market. These values indicate a strong and positive
correlation between the IFR function and the price evolution. Based on this strong
correlation, another type of limit conditions can be imposed using the IFR
function. Considering the assumption that in a long trend when the price goes up,
IFR function has an increasing interval. Similarly, on a short trend, the decreasing
values of the price correspond with a decreasing interval of the IFR.
The increasing or decreasing tendency of the price movement can be tested
or filtered with the IFR monotony conditions:
(4)
The gradient of the IFR function can be a good filter for any trading signal.
After the price changed the direction, due to the specificity of the Fisher
transformation, behavior transmitted to the inversed Fischer function used, the
gradient of the IFR function is significantly changing. The IFR monotony
conditions (4) will filter those trades with high gradient, meaning the trades made
after the local price trend change. This reason will reduce the risk, in the
overbought and oversold price intervals the gradient of the IFR function being
reduced. To avoid trading in the overbought and oversold intervals, the relations
(4) are improved to define the IFR gradient conditions by:
(5)
Cristian Păuna
16
each market in order to minimize the exposed capital. In order to show the impact
of these kinds of limit conditions in the trading results, the next example is
presented. A buy trading signal was traded with and without the (5) IFR gradient
conditions. The signal opens a long trade when a new long trend is met,
considering another methodology which is not a subject of this paper. In order to
next results were obtained in the period 01.06.2015 31.05.2018 with the same
risk considerations as presented in the previous example.
IFR limit
conditions
(5)
Number
of trades
Profit
Drawdown
Risk to
reward ratio
Without IFR
144
5,561
16,141
1:0.34
With IFR
48
12,426
3,380
1:3.67
Table 2. Trading results with and without IFR gradient conditions
As we can see analyzing the results from the table 2, the contribution of the IFR
gradient conditions is a significant one. Without these conditions the profit obtained is
less even more trades were executed. Much important is the value of the drawdown
which is significantly higher in the case without the IFR gradient conditions.
Figure 5. Capital evolution without IFR gradient conditions
Reliable Signals and Limit Conditions for Automated Trading Systems
17
17
Figure 6. Capital evolution with IFR gradient conditions
Comparing the cases with and without IFR presented in the two examples
above, we can conclude that the IFR limit conditions are reliable trading conditions
in order to filter the trades to reduce the risk and to maximize the profitability of
any other trading algorithm.
4. TRADING SIGNALS
The IFR function gives us also the possibility to build independent trading
signals. Having the chance to know when a price is oversold, buy trading signals
can be built using IFR function on these intervals. Usual an oversold price stays
oversold for a period of time. After that period the price will reverse the direction
and it will increase for higher values. The specificity of the inversed Fischer
function used in the IFR model, tells us that after the IFR function has a local
minimum, the price will turn up in order to record a new local maximum value.
This is a buy opportunity which can be automated using the IFR function. The IFR
oversold trading condition is given by the formula:
(6)
functional parameters that can be optimized depending on the traded market.
Another type of trading signals which can be assembled with the IFR function use
the assumption that if the IFR function gradient has an important variation, the
price just passed a minimum point, according the Fischer function methodology,
and that can be a good buy signal. To avoid the oversold and overbought zones, the
next relation can be used in order to build the IFR gradient trading signal:
(7)
(IFRi) where the price is low enough to make a buy trade and not enough higher
Cristian Păuna
18
to increase the risk. These parameters will be optimized for each financial
market in order to minimize the risk. The sell signals can be similarly built as
the signals in (6) and (7) are presented, for those markets where short trading
signals can be considered.
Trading results obtained with both IFR oversold and gradient trading signals
are presented below. For (6)
Both signals were traded for DAX30 market between 01.06.2015 and 31.05.2018
with the same risk considerations as for the examples presented in the chapter 3.
Trading signals
IFR
Number
of trades
Profit
Drawdown
Risk to
reward ratio
IFR oversold (6)
22
5,698
3,772
1:1.15
IFR gradient (7)
78
20,209
6,197
1:3.26
(6) and (7) together
100
25,907
6,197
1:4.18
Table. 1. Trading results obtained with IFR trading signals
Reliable Signals and Limit Conditions for Automated Trading Systems
19
19
5. CONCLUSIONS
The IFR function presented uses only known computational methods. Using
the inverse Fisher transform, the IFR function transform the price into a limited
asymptotical function which permit an automated analyze for the overbought and
oversold intervals. When the IFR function has an asymptotic evolution near 100,
the price is approaching to make a new high and to reverse the evolution to a local
minimum point. In other time intervals, when the IFR function has an asymptotic
evolution to the 0, the price is on an oversold period, a new local minimum point
will be met and the price returns in order to make a new local maximal point.
The IFR function gives us the possibility to establish limit conditions in
order to automate the trading decisions regarding the overbought and oversold
price values. With these limit conditions, any trading signals can be filtered in
order to avoid to buy near a local maximum point or to sell near a local minimum
point. In addition, these conditions can be used in order to close earlier the buy
trades when the price touch a local maximum point.
The high gradient of the IFR function can be assimilated with the period
after a minimum or maximum local price value. The difference between two values
of the IFR function can be a good filter for a trend oriented trading signal. Adding
more consecutive IFR values on an oversold interval and comparing the results
with an optimized parameter can be a good buy signal for an oversold trade. In
addition, on the increasing periods of the IFR function, until a specified limit found
by optimization, buy trades opportunities can be made using the IFR signals
presented. Having a good risk to reward ratio values, the trades built with IFR
functions are reliable trades. Based only on mathematical functions, all these
signals and can be easily implemented in algorithmic trading.
Cristian Păuna
20
REFERENCES
1.
, ISBN 973- 31-1135-X, pp. 10-20.
2. nindex
DAX30 Components. Retrieved from http://www.boerse-
frankfurt.de/index/dax
3. Connors, Larry, Alvarez, Cesar (2009), Short Term Strategies That Work A
Quantitative Guide to Trading Stocks and ETFs, TradingMarkets Publishing
Group, New Jersey, US, ISBN: 978-0-0919239-0-1, pp. 17-19
4. Cox, David, Roxbee, Sir (1961), Prediction by Exponentially Weighted
moving Averages and Related Methods, Journal of the royal Statistical
Society, Series B, Vol. 23, No. 2, pp. 414-422
5. Ehlers, John, F. (2004), Cybernetic Analysis for Stocks and Futures. Cutting-
Edge DSP Technology to Improve Your Trading, Wiley, ISBN:
9780471463078, pp. 4-10
6.
presentation. Retrieved from https://pauna.biz/thedaxtrader
7. una, Cristian (2018), Automated Trading Software. Design and Integration
in Business Intelligence Systems, Database Systems Journal, ISSN 2069
3230, Vol. VIII, Issue 1/2018, pp. 121-128
8. ading
Systems, Proceedings of the 17th International Conference on Informatics in
Economy, pp 183-188.
9. Reinsch, Christian (1967), smoothing by Spline functions, Numerische
Mathematik, Volume 10, Issue 3, pp 177183, ISSN 0945-3245, DOI
https://doi.org/ 10.1007/BF02162161
10. Wilder, Wells, Jr. (1986), The Relative Strength Index, Journal of Technical
Analysis of Stocks and Commodities, Seattle US, 4, pp. 343-346