Sunday, May 17, 2009

Blogs dynamics

As some of you may have noticed, from now on, I will publish all the posts that do not relate directly to trading or economics on two other blogs: http://thenomadicchronicle.blogspot.com/ for english, and http://chroniquenomade.blogspot.com/ for french (one will not necessarily be the translation of the other, the content may be different)
The posts which are directly focusing on mathematics will also be made on another blog: http://stochasticfractals.wordpress.com/

I however leave all past posts on this blog.
This is not to mean that my posts on the other blogs will not relate in anyway to trading, I actually believe that most of them, if not all, do relate to it in some ways. My intention in separating them is only for the purpose of clarity.

Friday, May 15, 2009

Internationalization of the Yuan

Today, the Bank of China Chairman Xiao Gang announced the beginning of a scheme to internationalize the Chinese Yuan. The immediate real effect of this declaration will be relatively mild, this internationalization will only concern trading relationships with south-east asian countries, but we can expect a psychological effect on the exchange rate of the Yuan, and therefore a trade shorting USD against the CNY seems possible.

On a more fundamental point of view, the Yuan is still very far from being a reserve currency, but given the geopolitical situation, and the weakening of US economy, the environment is certainly propitious for China to undertake such measures in the direction of a strengthening of the Yuan and basically an affirmation of its real weight in the world economy. Clearly, until now, China has been relying on US consumption to boost its economy, with this consumption currently falling (and still far from bottoming), China would be well-inspired to develop its domestic consumption and that supposes a strengthening of the Yuan.

For more details, see Reuters, insiderNews,...etc.

Thursday, May 7, 2009

Fractional Bands

Let's consider again the equation (1) from yesterday:

$\sigma _{FBM}=(\frac{1}{N}\sum_{i=1}^{N}(x_{i}-\bar{x})^{2})^{H}=\sigma _{WBM}^{2H}$

We were facing the technical problem of having very small real variations of prices, leading to very small standard deviations. This can however be easily solved by converting all our values in PIPS. For EUR/USD, it simply consists in multiplying all the prices by 10000. If we then apply the above equation to PIPS, and convert it back to the scale of real prices (by dividing by 10000), we can then get a proper representation of bands, which, given that they are strictly obeying the model of FBM we are working with, I shall name Fractional Bands.

Here is a representation of these fractional bands for the 5 mn timeframe of EUR/USD, the red bands are the Fractal Bands defined as earlier, with the default parameters, the yellow bands are the Fractional Bands, with the same default parameters (without α, which we don't need anymore since we are not using equation (2)):

We can also compare the Fractional Bands (in yellow) with the Bollinger Bands (in blue-green) , to confirm what we expect from the above equation:

We indeed see that whenever the Fractal Dimension crosses the 1.5 line (i.e. whenever H crosses the 0.5 mark), the respective bands cross as well. The Fractional Bands are therefore narrower for a side-market and wider for a trendy market (even wider than the Fractal Bands for a very trendy market).

The paramaters for the Fractional Bands are the same as for the Fractal Bands except that there is no α, and in addition, we have the following parameter:
PIP_Convertor (integer): the factor necessary to convert real price to PIPS, default is 10000 (for EUR/USD)

As for the strategy, I am not sure whether there is one for this indicator alone, it seems to cross the prices quite often, especially during a side-market, it may however be combined efficiently with the FGDI and/or the Fractal Bands.

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:

$P(M(t)\leq x)=1-P(M(t)\geq x)=1-2(1-\Phi (\frac{x}{\sqrt{t}}))$

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

$P(M(t)\leq 2\sqrt{t})=1-2(1-\Phi (\frac{2\sqrt{t}}{\sqrt{t}}))=2\Phi (2)-1=erf(\sqrt{2})=0.954$

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:

$\sigma =\sqrt{\frac{1}{N}\sum_{i=1}^{N}(x_{i}-\bar{x})^{2}}$

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

$\sqrt{t}=\sqrt{\frac{1}{N}\sum_{i=1}^{N}(x_{i}-\bar{x})^{2}}$

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

$\sigma _{FBM}=|t|^{H}=(\frac{1}{N}\sum_{i=1}^{N}(x_{i}-\bar{x})^{2})^{H}=\sigma _{WBM}^{2H}\; \; \; \; \; \; \; (1)$

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):

$\sigma _{final}=\sigma _{WBM}*\alpha ^{H}\;\; \; \; \; \; (2)$

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 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.

Sunday, May 3, 2009

Fraternité

Some interesting remarks about fraternity came to my attention today, and I think it reveals an interesting difference between a social policy and Socialism, a confusion that many seem to make, in one sense or another.
First, here is a quote from Charles Péguy's "De Jean Coste" written in 1902 (first the original in french, followed by my translation):
Le devoir d'arracher les misérables à la misère et le devoir de répartir également les biens ne sont pas du même ordre : le premier est un devoir d'urgence ; le deuxième est un devoir de convenance ; non seulement les trois termes de la devise républicaine, liberté, égalité, fraternité, ne sont pas sur le même plan, mais les deux derniers eux-mêmes, qui sont plus rapprochés entre eux qu'ils ne sont tous deux proches du premier, présentent plusieurs différences notables ; par la fraternité nous sommes tenus d'arracher à la misère nos frères les hommes ; c'est un devoir préalable ; au contraire le devoir d'égalité est un devoir beaucoup moins pressant ; autant il est passionnant, inquiétant de savoir qu'il y a encore des hommes dans la misère, autant il m'est égal de savoir si, hors de la misère, les hommes ont des morceaux plus ou moins grands de fortune ; je ne puis parvenir à me passionner pour la question célèbre de savoir à qui reviendra, dans la cité future, les bouteilles de champagne, les chevaux rares, les châteaux de la vallée de la Loire ; j'espère qu'on s'arrangera toujours ; pourvu qu'il y ait vraiment une cité, c'est-à-dire pourvu qu'il n'y ait aucun homme qui soit banni de la cité, tenu en exil dans la misère économique, tenu dans l'exil économique, peu m'importe que tel ou tel ait telle ou telle situation ; de bien autres problèmes solliciteront sans doute l'attention des citoyens ; au contraire il suffit qu'un seul homme soit tenu sciemment, ou, ce qui revient au même, sciemment laissé dans la misère pour que le pacte civique tout entier soit nul ; aussi longtemps qu'il y a un homme dehors, la porte qui lui est fermée au nez ferme une cité d'injustice et de haine.
De Jean Coste, Charles Péguy, éd. Acte Sud Labor L'Aire, coll. Babel, 1993, p. 55

The duty to lift the destitute off their misery and the duty to distribute wealth equally are not of the same order: The former is a pressing duty; the latter is a desirable one; not only the three terms of the republican motto, liberty, equality, fraternity, are not at the same level, but the last two themselves, have several important differences; by fraternity we are prompted to lift our brothers the men off misery; it’s a prior duty; on the contrary the duty of equality is much less pressing; as much as I am passionately disturbed to know that there are still men in misery, as much as I am indifferent to know if, out of misery, men have larger or lesser wealth; I cannot succeed to make myself passionate for the famous matter of knowing who will get in the future society, the bottles of champagne, the rare horses, the castles of the Loire Valley; I hope we’ll always find some arrangement; provided there really is a society, that is, with the provision that nobody will be banned from it, kept in exile in economic misery, kept in an economic exile, nevermind that this or that one is in this or that situation; many other problems will request the attention of citizens; on the contrary, it is enough that one man is kept knowingly, or, which is the same, is knowingly left into misery for the whole social contract to be broken; as long as there is one man outside, the door that is shut in someone’s face secures a society of injustice and hatred.

I think it illustrates very well an aspect of our societies on which we can ponder with some profit. Fraternity is really at the core of humanity and humanism, and its difference with equality is precisely parallel to the one between a social policy and Socialism.

For the french speakers (and listeners), it is also interesting to listen to today's broadcast of Repliques on France Culture:
Repliques du 2 Mai 2009: Penser la fraternité