FX Trading using Logistic Regression Analysis and Naive Bayes ModelKimihisa KAWABATA1 and Hitoshi TAKATA2
1Graduate School of Economics and Business Administration, Kyushu Sangyo University JAPAN
2Graduate School of Science and Engineering, Kagoshima University, JAPAN1 Introduction
In FX trading, judgment whether it trades with the next term is very
difficult. The existing technical analysis depends on the past statisticaldata. Especially, in the index of an oscillator system, there are muchwrong indexes such as divergence, falsehood, time lag and so forth andjudgment is very difficult. The propriety (probability p) of whether totrade with the next term will be judged according to the posterior
probability of Bayes using the basic formula of Bayes in this paper.
The binomial distribution is adapted as likelihood of whether trade iscarried out or not and a beta distribution is adapted as a prior distribution.
Then posterior probability distributions also turn into a beta distribution,
since the natural conjugate distribution is a beta distribution. However,about the initial value of prior probability, the output value (probabilityp) of logistic regression analysis is used not using subjective probability(prior probability).
Moreover, economic news are incorporated from the web site forforecasting calculation, and the expected value of the probability of thepropriety of a trade was modified. As a result, performance has been
improved greatly.

2 FX Trading and Decision-making

Here, beta function can also write as follows using a gamma function.

As to likelihood, we adapt the binomial distribution so as to carry out
the trade or not. The probability density function of binomial
distribution is expressed with the next equation (3).

If a beta distribution is adopted as a prior distribution to the likelihood
obtained from the data (D) which follows a binomial distribution,
posterior distribution will turn into a beta distribution which equal to aprior distribution. Because, if we adapt the natural conjugate distribution
as prior distribution (beta distribution) against a likelihood (binomialdistribution), it is known that posterior distribution will also turn into thesame beta distribution as a prior distribution.
When this relation is used, the basic formula of Bayes is expressed withthe next equation.

2.1 The Problem of a Technical Analysis and Difficulty of aTrade
A technical analysis tends to be available to forecast next trading
subjectively incorporating the price movement of FX currency pairwhich is essentially non-stationary stochastic process by the elementary
statistical technique. Bollinger band, RSI, MACD, etc. are thetechniques of being popular among a trader. However, as we know,"divergence", "falsehood", "time-lag", and so forth exist in these indexes
largely, and a trade goes fail in many cases. This is the big fault of atechnical analysis. One of these examples in USD/JPY are shown inFig.1

ACDBFig.1 RSI and Divergence
Source: Gaitame Dot Com, Chart & Tool
https://trade.gaitame.com/members/index.asp 2011.09.30.

A denominator is a very complicated equation and it is calculated by
the approximated calculation here. However, this is a constant, andsince a trade is made decisions using natural conjugate distribution, even
if a denominator is removed, it does not lose generality.
Consequently, the following is realized.
(4)
Eq. (4) is the basic formula of Bayes and posterior probability of thepossibility of a trade is simply acquired as a product of the likelihood
and prior probability. However, like common knowledge, priorprobability is subjectivity probability and cannot eliminate subjectivity
like selection of the technique of a technical analysis. Then, with thispaper, this prior probability is obtained from p; 0<p<1 which was got
from the output result of a logit model. pn denotes probability of the lastterm (the n-th term) of the analytical period of a logit model. For details,
the next Section 2.3 describes. In addition, the reason using a beta
distribution is as follows. The form of a beta distribution is various
according to parameter α and β, and it is similar in part to the form of
the exchange rate chart of currency pair USD/JPY which takes variousform.

2.3 A Naive Bayes Model and Logit Transformation

2.2 The Possibility of a Trade and Bayes Statistics

Prior probability

However, in this paper, we deal with only an entry in order tounderstand easily. The technique of "Bayes statistics" is introduced assuch a mathematical model. A beta distribution is used for calculating
the prior probability of Bayes. Hence, the probability (p) of thepossibility of a trade shall follow a beta distribution. Probability density
function of a beta distribution here is written in the next equation.

using logit transformation value zt which is computed as follows.

was calculated mechanically as the function of p t(5)

Namely, parameter α0,α1,・・・,αp of eq. (5) will be computed byusing the maximum likelihood method. Subsequently, next equation isobtained by solving eq.(5) about pt.

Combination of a logit model and a naive Bayes model is described inSection 3.2 in detail. The objective variable of a logit model
iscomposed of 2-value variable (say, 1: trade is carried out 0: trade does
not be carried out). Although various variables could be considered as
explanatory variable, finally the following variables x1t, x2t, ・・・, xnt
were chosen. x8t, x9t, x10t, and x11t are dummy variables of the economic
news at time t . The discriminant hitting ratio ( ) of whether it trades or
not to trade is required from a discriminant crossing table. The criteria ofdiscriminant is decided politically (for example, 65% or more).

2.4 Precondition of Decision-Making
Although the style of a trade has scalping, one day trade, swing trade,
middle-term trade, and long-term trade first, swing trade is dealt with in
this paper. However, data is a closing price of USD/JPY. An analytical
period is carried out from April 1, 2011 to August 31, 2011.
Subsequently, let a forecasting period be 12 business days from
September 1, 2011 to September 16, 2011. The objective variable y of alogit model is calculated by the rule of a trade. It will be referred to as"up-trend" if three exchange rate charts (4-leg chart) of USD/JPYcontinue by positive line. Conversely, it will be referred to as "downtrend" if three exchange rate charts (4-leg chart) of USD/JPY continueby the negative line. When it is not any, it will be referred “0” as “unchange”. If the market is either “up-trend” or “down-trend”, then “1”will be given. Conversely, the market is “un-change”, then “0” will begiven. It corresponds to the meaning that “1” is “it trades” and “0” is “itdoes not trade”. Economic news has received from the web site of
http://forexpros/jp/economic-calendar 2011.10.3 .
Subsequently, although we consider a swing trade, a swap point shallnot be considered here. Moreover, neither a commission nor a tax shallalso be considered. The parameters a and b of beta distribution ofposterior distribution become
respectively by the relationthat the "natural conjugate distribution" is beta distribution against
likelihood. Then, using not the MCMC method ( Markov Chain Monte
Carlo method) but "a natural conjugate distribution" , the expectedvalue
of a posterior distribution (beta distribution) can be simplycomputed by the next equation.
Calculation of statistic can be simply performed by avoiding thecomplicated calculation including the integration operation of posterior
distribution, and using "natural conjugate distribution".

3 Trading of USD/JPY
3.1 The Recent Trend of USD/JPY
Let’s look at the recent trend of USD/JPY (Daily) in the period onApril 1, 2011 to August 31, 2011. Analysis period shows five phases
divided by the peak and the bottom.

3.2 Combination of Logit Model and a Naive Bayes Model
A naive Bayes model is used for forecasting of the possibility of FX
trading. The basic formula of a naive Bayes model was expressed by eq.
(4). Though, here, the right-hand side
is subjective probability, wedefined this the last probabilityof n-th term of a logit model. Hence,
the next equation is assumed.

What is necessary is just to forecast "it trades" with more than 0.5
on. On the contrary, what is necessary is just to forecast "it does nottrade" with less than 0.5 on. The necessary matter is just to carry out
the above forecasting calculation during some periods (for example, 12business days on September 1, 2011 to September 16, 2011) .

3.3 Forecasting of Trade of USD/JPY
We carried out the decision making of trade considering economic
news in order to improve
to. Thus, the revised
wasobtained re-calculating. The obtained forecasting result is in Fig.2.

Fig.2 Forecasting Value of Trade (2011. 9.1-2011.9.16)
The performance of the "actual value" which became clear later on,
and the "forecasting value" of a naive Bayes model was eight wins andfour losses among 12 business days. Hence, the rate of coincidence offorecasting became 66.67%.

4 Conclusion
In this paper, forecasting of propriety of a trade of USD/JPY wastreated in a fashion of mathematical science. Hence, the propriety(probability) of whether to trade with the next term was calculated by
the naive Bayes model. However, an initial value of the prior probability
distribution (beta distribution) of naive Bayes model was not treatedsubjectively but adapted the probability which is the last output value oflogistic regression analysis. Hence, the following idea was introduced
into the naive Bayes model. When we take the prior distribution of theprobability which trades as beta distribution which is “a naturalconjugate distribution “ against likelihood obtained from the data ofwhether to carry out the trade , which follows binomial distribution, aposterior distribution is also a beta distribution. When re-calculating of
the parameters n, r, α and β and substituting them into the naive Bayesmodel, a posterior probability of a beta distribution could be computed
sequentially (renewal of Bayes).This calculated value served asdecision-making (forecasting value) of whether to trade after the next
term.
However, in the process of forecasting, the value ofstopped at
the low value, and was obliged to correction. Then, revised expected
probability
which incorporated the economic news announced inadvance, like logistic regression analysis, was re-calculated. The result
approached considerably the actual value, as became clear later on, andthe performance of a trade improved to about 66.67%.

References[1] Congdon P.: Bayesian Statistical Modelling, John Wiley & Sons,
2001.
[2] Lien, K: Day Trading of the Currency Market: Technical andFundamental Strategies to Profit from Market Swings, John Wiley& Sons, 2006.
[3] Esumi: " Excel Tahenryo Kaiseki Ver.5.0 User's Manual," ESUMI,
2003. (in Japanese)[4] Uchida, O. and Fukushima, R.: Reikai Tahenryo Kaiseki Gaido:
Excel Adoin Sohuto wo Riyou site, Tokyo Tosho Co., Ltd., April,2011. (in Japanese)[5] Wakui, Y.: Dogu toshiteno Bayes Toukei, Nippon Jitsugyo
Publishing Co., November, 2009. (in Japanese)[6] Gaitame Dot Com :https://trade.gaitame.com/members/applet/main.asp, September 19,
2008. (in Japanese)