![Page 1: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/1.jpg)
Introduction to Algorithmic Trading StrategiesLecture 6
Technical Analysis: Linear Trading Rules
Haksun [email protected]
www.numericalmethod.com
![Page 2: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/2.jpg)
Outline Moving average crossover The generalized linear trading rule P&Ls for different returns generating
processes Time series modeling
![Page 3: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/3.jpg)
References Emmanual Acar, Stephen Satchell. Chapters
4, 5 & 6, Advanced Trading Rules, Second Edition. Butterworth-Heinemann; 2nd edition. June 19, 2002.
![Page 4: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/4.jpg)
Assumptions of Technical Analysis History repeats itself. Patterns exist.
![Page 5: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/5.jpg)
Does MA Make Money? Brock, Lakonishok and LeBaron (1992) find
that a subclass of the moving-average rule does produce statistically significant average returns in US equities.
Levich and Thomas (1993) find that a subclass of the moving-average rule does produce statistically significant average returns in FX.
![Page 6: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/6.jpg)
Moving Average Crossover Two moving averages: slow () and fast (). Monitor the crossovers. , Long when . Short when .
![Page 7: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/7.jpg)
How to Choose and ? It is an art, not a science (so far). They should be related to the length of
market cycles. Different assets have different and . Popular choices:
(150, 1) (200, 1)
![Page 8: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/8.jpg)
AMA(n , 1) iff iff
![Page 9: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/9.jpg)
GMA(n , 1) iff
(by taking log) iff
(by taking log)
![Page 10: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/10.jpg)
What is ?
![Page 11: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/11.jpg)
Acar Framework Acar (1993): to investigate the probability
distribution of realized returns from a trading rule, we need the explicit specification of the trading rule the underlying stochastic process for asset
returns the particular return concept involved
![Page 12: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/12.jpg)
Empirical Properties of Financial Time Series Asymmetry Fat tails
![Page 13: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/13.jpg)
Knight-Satchell-Tran Intuition Stock returns staying going up (down)
depends on the realizations of positive (negative) shocks the persistence of these shocks
Shocks are modeled by gamma processes. Persistence is modeled by a Markov switching
process.
![Page 14: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/14.jpg)
Knight-Satchell-Tran Process
: long term mean of returns, e.g., 0 , : positive and negative shocks, non-negative,
i.i.d
![Page 15: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/15.jpg)
Knight-Satchell-Tran
Zt = 0 Zt = 1q p
1-q
1-p
![Page 16: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/16.jpg)
Stationary State
, with probability , with probability
![Page 17: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/17.jpg)
GMA(2, 1) Assume the long term mean is 0, .
![Page 18: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/18.jpg)
Naïve MA Trading Rule Buy when the asset return in the present
period is positive. Sell when the asset return in the present
period is negative.
![Page 19: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/19.jpg)
Naïve MA Conditions The expected value of the positive shocks to
asset return >> the expected value of negative shocks.
The positive shocks persistency >> that of negative shocks.
![Page 20: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/20.jpg)
Period Returns
𝑅𝑅𝑇=∑𝑡=1
𝑇
𝑅𝑡× 𝐼 {𝐵𝑡− 1≥0 }Sell at this time point
𝑇𝐵𝑇<0
0 1
hold
![Page 21: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/21.jpg)
Holding Time Distribution
![Page 22: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/22.jpg)
Conditional Returns Distribution (1)
![Page 23: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/23.jpg)
Unconditional Returns Distribution (2)
![Page 24: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/24.jpg)
Long-Only Returns Distribution
Proof: make
![Page 25: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/25.jpg)
I.I.D Returns Distribution
Proof:
make
![Page 26: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/26.jpg)
Expected Returns
When is the expected return positive? , shock impact , shock impact , if , persistence
![Page 27: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/27.jpg)
GMA(∞,1) Rule
![Page 28: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/28.jpg)
GMA(∞,1) Returns Process
![Page 29: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/29.jpg)
Returns As a MA(1) Process
![Page 30: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/30.jpg)
GMA(∞,1) Expected Returns
![Page 31: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/31.jpg)
MA Using the Whole History An investor will always expect to lose money
using GMA(∞,1)! An investor loses the least amount of money
when the return process is a random walk.
![Page 32: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/32.jpg)
Optimal MA Parameters So, what are the optimal and ?
![Page 33: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/33.jpg)
Linear Technical Indicators As we shall see, a number of linear technical
indicators, including the Moving Average Crossover, are really the “same” generalized indicator using different parameters.
![Page 34: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/34.jpg)
The Generalized Linear Trading Rule A linear predictor of weighted lagged returns
The trading rule Long: , iff, Short: , iff,
(Unrealized) rule returns
if if
![Page 35: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/35.jpg)
Buy And Hold
𝐵𝑡=1
![Page 36: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/36.jpg)
Predictor Properties Linear Autoregressive Gaussian, assuming is Gaussian If the underlying returns process is linear,
yields the best forecasts in the mean squared error sense.
![Page 37: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/37.jpg)
Returns Variance
![Page 38: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/38.jpg)
Maximization Objective Variance of returns is inversely proportional
to expected returns. The more profitable the trading rule is, the
less risky this will be if risk is measured by volatility of the portfolio.
Maximizing returns will also maximize returns per unit of risk.
![Page 39: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/39.jpg)
Expected Returns
![Page 40: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/40.jpg)
Truncated Bivariate Moments Johnston and Kotz, 1972, p.116
Correlation:
![Page 41: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/41.jpg)
Expected Returns As a Weighted Sum
a term for volatility a term for drift
![Page 42: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/42.jpg)
Praetz model, 1976 Returns as a random walk with drift. , the frequency of short positions
![Page 43: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/43.jpg)
Comparison with Praetz model
the probability of being short
increased variance
Random walk implies .
![Page 44: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/44.jpg)
Biased Forecast A biased (Gaussian) forecast may be
suboptimal. Assume underlying mean . Assume forecast mean .
![Page 45: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/45.jpg)
Maximizing Returns Maximizing the correlation between forecast
and one-ahead return. First order condition:
![Page 46: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/46.jpg)
First Order Condition Let
![Page 47: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/47.jpg)
Fitting vs. Prediction If process is Gaussian, no linear trading rule
obtained from a finite history of can generate expected returns over and above .
Minimizing mean squared error maximizing P&L.
In general, the relationship between MSE and P&L is highly non-linear (Acar 1993).
![Page 48: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/48.jpg)
Technical Analysis Use a finite set of historical prices. Aim to maximize profit rather than to
minimize mean squared error. Claim to be able to capture complex non-
linearity. Certain rules are ill-defined.
![Page 49: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/49.jpg)
Technical Linear Indicators For any technical indicator that generates
signals from a finite linear combination of past prices Sell: iff
There exists an (almost) equivalent AR rule. Sell: iff
,
![Page 50: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/50.jpg)
Conversion Assumption
Monte Carlo simulation: 97% accurate 3% error.
![Page 51: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/51.jpg)
Example Linear Technical Indicators Simple order Simple MA Weighted MA Exponential MA Momentum Double orders Double MA
![Page 52: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/52.jpg)
Returns: Random Walk With Drift
The bigger the order, the better. Momentum > SMAV > WMAV
How to estimate the future drift? Crystal ball? Delphic oracle?
![Page 53: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/53.jpg)
Results
![Page 54: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/54.jpg)
Results
![Page 55: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/55.jpg)
Returns: AR(1)
Auto-correlation is required to be profitable. The smaller the order, the better. (quicker
response)
![Page 56: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/56.jpg)
Results
![Page 57: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/57.jpg)
ARMA(1, 1)
Prices tend to move in one direction (trend) for a period of time and then change in a random and unpredictable fashion. Mean duration of trends:
Information has impacts on the returns in different days (lags). Returns correlation:
AR MA
![Page 58: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/58.jpg)
Resultsno
systematic winner
optimal order
![Page 59: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/59.jpg)
ARIMA(0, d, 0)
Irregular, erratic, aperiodic cycles.
![Page 60: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/60.jpg)
Results
![Page 61: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/61.jpg)
ARCH(p)
are the residuals When , .
residual coefficients as a function of lagged squared residuals
![Page 62: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/62.jpg)
AR(2) – GARCH(1,1)AR(2) GARCH(1,
1)
innovations
ARCH(1): lagged squared
residualslagged
variance
![Page 63: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/63.jpg)
Results The presence of conditional
heteroskedasticity will not drastically affect returns generated by linear rules.
The presence of conditional heteroskedasticity, if unrelated to serial dependencies, may be neither a source of profits nor losses for linear rules.
![Page 64: Introduction to Algorithmic Trading Strategies Lecture 6](https://reader036.vdocuments.site/reader036/viewer/2022081421/568166da550346895ddafb71/html5/thumbnails/64.jpg)
Conclusions Trend following model requires positive
(negative) autocorrelation to be profitable. What do you do when there is zero
autocorrelation? Trend following models are profitable when
there are drifts. How to estimate drifts?
It seems quicker response rules tend to work better.
Weights should be given to the more recent data.