Showing posts with label Brownian motion. Show all posts
Showing posts with label Brownian motion. Show all posts

Wednesday, May 6, 2009

From Bollinger to Fractal Bands

Bollinger Bands indicator is a well-known and interesting indicator, as it provides with entry and exit points. It basically consists in a MA and two bands above and below it. Each band is classically placed at 2 standard deviations away from the MA. If we assume that price variations follow a normal distribution, this ensures that 95% of the prices will fall within the bands.
______________________________________________________________________________________________________

I-Some theoretical points

Keeping this assumption for now, the time-series of price variations can be described by a Wiener Brownian Motion of normal distribution N(0,t). It is interesting to see the probability of the prices to be within the bands is equal to the probability of the maximum of the price (that we will name M(t)) to be within them, as shown below:



For more details and the justification of this formula, see my other blog.
We then see:



Such probabilities are calculated for the theoretical value of the standard deviation of the WBM, the Bollinger Bands, however, calculates an empirical value for it using the well known formula:



Given this practical σ and the theoretical one, we can equate the two:



And knowing the theoretical standard deviation for a FBM (see there), we get the practical standard deviation for FBM (of Hurst parameter H):




II-Implementation of Fractal Bands

A straightforward way to implement Fractal Bands seems to just take classical Bollinger Bands and merely increase the width of the bands by raising the standard deviation to the power of 2H. However, if we do that, here is what we get (the MA is the FRASMAv2, the reference period is 30, the blue bands are Bollinger Bands for the same speed) :



I don't find this indicator very useful (not useful at all actually, for me). It seems necessary here to get some perspective about how we wish to improve on the Bollinger Bands. From my point of view, as a day trader, I feel Bollinger Bands too narrow, the prices hit them too often, especially in a trending market, where I would like to get a clear signal only when the trend is over. But, with Bollinger Bands, most of the trend occurs outside the bands, prompting me to close the trade much too early and basically inciting me not to ride the trend.
Applying equation (1) however, we get the counter-productive effect of narrowing the bands when in a trend, because, in our case of price variation, the standard variation is much lower than 1(this may not be the case for stock exchange, but it clearly is for FOREX), raising it to a higher power therefore decreases its value proportionally.
A way out of this quandary is simply to apply the following treatment to the standard deviation from the Bollinger Bands instead of the one from (1):



By taking α greater than 1, the higher our H, the wider the bands will be, here is what it leads to (with the same setup as before, and α=2):



The script fractal_bands.mq4 can be downloaded from this address from the MQL4 site.
The input parameters of the indicator are as follows:
e_period (integer): This is the period considered for calculating the fractal dimension, default is 30.
normal_speed (integer): This is the speed of the SMA before being modified to become the FRASMA, default is 30.
alpha (real): This is the alpha from equation (2), default is 2.
shift (integer): This is the number of bars the FRASMA is shifted to the right(positive) or to the left(negative), default is 0.
e_type_data (0,1,2 or 3): This is the type of price the indicator will consider (0=CLOSE, 1=OPEN, 2=HIGH, 3=LOW), default is 0.


III-Strategical considerations

I have started using the Fractal Bands indicator, and am very happy of it so far. The strategy is quite straightforward.
I enter in a BUY position after the price have rebounded (after touching it) from the lower band and crossed the FRASMA, my Stop Loss is then set to the level the prices hit the lower band, and my Take Profit is when the prices hit the higher band.
Symmetrically, I enter a SELL position after the price have fallen from the higher band (after touching it) and crossed the FRASMA, Stop Loss set at the level of the hit of the higher band, and Take Profit when the lower band is hit.
It is obviously possible (and even advised) to make your Stop Loss trailing the price changes.
I used this strategy for EUR/USD on a 5 minutes timeframe, using it on other timeframes or on other instruments may require a different setup, mine was to set the speed of the FRASMA at 30, and α=2 (in equation (2) above), it is possible to change these values.

Wednesday, June 25, 2008

Why fractals?

A significant part of TA, if not all, is based on Averages, and as such, it relies heavily on the Gaussian (or Normal) Distribution which is the statistical translation of the Random Walk Theory.
Indeed for Averages (and that includes all kind of Moving Averages, Simple or Exponential) to really be as meaningful as TA considers them, prices variation must actually be described adequately by the Gaussian Distribution and its counterpart in random process, the Brownian Motion.

It is interesting to note that there is a contradiction inherent to the practise of TA. In his "Technical Analysis of the Financial Market", John Murphy wrote (with good reason):
The Random Walk Theory (...) claims that price changes are "serially independent" and that price history is not a reliable indicator of future price direction. In a nutshell, price movement is random and unpredictable(...) It also holds that the best market strategy to follow would be a simple "buy and hold" strategy as opposed to any attempt to "beat the market."

Something I completely agree with, but then, if a technical analyst is to reject this Random Walk view of price movement, shouldn't he reject as well the mathematical ramifications of this assumption rather than to use them as tools.
In a Gaussian model, the average (the mean) clearly is a good information to consider, it is the quantity that has the highest probability to be realised, and the closest to the average, the higher the probability is.

The large pool of experimental data we have from financial markets, however, tells us that they don't follow a Gaussian distribution, they diverge from it in various ways but a remarkable one is that they are fat-tailed , which means that the probability for the variable to be far away from the average is actually higher than in the Gaussian model (i.e. extreme variations are more frequent than what is predicted by the model). And that is important, because it tends to make our beloved Average less useful, in terms of prediction, while the differences are not such that Averages don't retain any usefulness. But more precise tools may likely be derived from a more fitting model of the real price movement.

Another problem with the Gaussian model is that it assumes continuity and evenness of change. Benoit Mandelbrot in "Fractals and Scaling in Finance" wrote:
In the classical (Gaussian) theory of errors, a large change would typically result from the rare chance simultaneity of many large contributing causes, each of them individually negligible. In economics, this inference is indefensible. Typically, the occurrence of a large effect means that one contributing cause, or at most a few turn out ex-post to be large.

This non-evenness, as well as the discontinuity of price movement (which is obvious given the structure of the process of price determination, the apparent continuity is just an artefact of price representation), contribute even further to undermine the validity of information given by Averages and even more so, by Moving Averages.

Mandelbrot again, remarks:
In particular, price continuity is an essential (but seldom mentioned) ingredient for all trading schemes that prescribed at what point one should buy on a rising market, and sell on a sinking price. Being discontinuous, actual market prices will often jump over any prescribed level, therefore, such schemes cannot be implemented.

Then, what are the alternatives to the Gaussian Distribution ?
Mandelbrot goes on discussing a few of them in his above-mentioned book. I won't do that here. The alternative I wish to discuss on this blog is the one most promising, in terms of modeling the behaviour of price movement, as far as I know.
It is the option involving the use of fractals. The models developed with fractals have so far shown a better fit than Gaussian models (as well as other alternatives), and I therefore hope that they can lead to the development of more efficient TA tools than the ones existing today.