This is an updated version of the FRASMA, earlier discussed. The original logic of it is left untouched, I merely updated it to take into account the calculation of the fractal dimension after the corrections I made in FGDI. Also, following a request from a reader, I added a parameter "shift" who simply translates the FRASMA either to the right (when "shift" is a positive integer) or to the left (when "shift" is a negative integer).

Here is how the FRASMAv2 with a shift set to 10 looks like:

The script for metatrader of FRASMAv2 can be found here.

## Sunday, April 26, 2009

## Sunday, April 19, 2009

### From D.H. Lawrence to Messiaen

Let me start this post by a quote from Lawrence's "Aaron's rod", towards the end of the chapter "Florence", wherein the hero Aaron plays a piece of solo flute for the Marchesa, who used to be a dilettante singer (contralto), but is now (after WW1) in a sort of downbeat mood, and feels nausea when listening to music (especially the orchestral one):

It is always difficult to discuss such a passage without, somehow, destroying its charm. I will therefore limit myself to providing a few directions through which its understanding may be deepened (or so it is for me).

First, I'd like to qualify a little the rather harsh judgment about the piano, by referring to composers such as Satie (one may also relate the mediaeval flavour of what Aaron plays to Satie's world) or Mompou, who found a voice for it that does not deserve to be called

On the other hand, the piano indeed has a tendency towards grandiloquence, from which the flute seems immune. One may think of Japanese music, and of the often central part played by the shakuhachi (wooden flute), and that may be the best approach to enter the "out-of-life" world (though I disagree with this characterization) Lawrence is talking about in this passage. The wonderful recording by Lily Laskine and Jean-Pierre Rampal came readily to my mind while reading these lines.

But before the "Catalogue d'oiseaux", even before "Le merle noir", there was Messiaen's "Preludes pour piano", whose first piece is called "La Colombe", already a bird, even if this one is a metaphor for Messiaen's mother. This piece, at least for me, particularly resonates with Lawrence's point.

...And there, in the darkness of the big room, he put his flute to his lips, and began to play. It was a clear, sharp, lilted run-and-fall of notes, not a tune in any sense of the word, and yet a melody, a bright, quick sound of pure animation, a bright, quick, animate noise, running and pausing. It was like a bird's singing, in that it had no human emotion or passion or intention or meaning--a ripple and poise of animate sound. But it was unlike a bird's singing, in that the notes followed clear and single one after the other, in their subtle gallop. A nightingale is rather like that--a wild sound. To read all the human pathos into nightingales' singing is nonsense. A wild, savage, non-human lurch and squander of sound, beautiful, but entirely unaesthetic.

What Aaron was playing was not of his own invention. It was a bit of mediaeval phrasing written for the pipe and the viol. It made the piano seem a ponderous, nerve-wracking steam-roller of noise, and the violin, as we know it, a hateful wire-drawn nerve-torturer.

After a little while, when he entered the smaller room again, the Marchesa looked full into his face.

"Good!" she said. "Good!"

And a gleam almost of happiness seemed to light her up. She seemed like one who had been kept in a horrible enchanted castle--for years and years. Oh, a horrible enchanted castle, with wet walls of emotions and ponderous chains of feelings and a ghastly atmosphere of must-be.

She felt she had seen through the opening door a crack of sunshine, and thin, pure, light outside air, outside, beyond this dank and beastly dungeon of feelings and moral necessity. Ugh!--she shuddered convulsively at what had been. She looked at her little husband.

Chains of necessity all round him: a little jailor. Yet she was fond of him. If only he would throw away the castle keys. He was a little gnome. What did he clutch the castle-keys so tight for?

Aaron looked at her. He knew that they understood one another, he and she. Without any moral necessity or any other necessity. Outside--they had got outside the castle of so-called human life. Outside the horrible, stinking human castle Of life. A bit of true, limpid freedom. Just a glimpse.

It is always difficult to discuss such a passage without, somehow, destroying its charm. I will therefore limit myself to providing a few directions through which its understanding may be deepened (or so it is for me).

First, I'd like to qualify a little the rather harsh judgment about the piano, by referring to composers such as Satie (one may also relate the mediaeval flavour of what Aaron plays to Satie's world) or Mompou, who found a voice for it that does not deserve to be called

*ponderous*or*nerve-wracking*, and Messiaen, who seemed to echo the comparison of Lawrence with birdsongs, by composing his "Catalogue d'oiseaux", and that one was mostly composed for piano, even though, the first piece of this collection can be said to be "Le merle noir", itself composed primarily for the flute (with a piano accompanying).On the other hand, the piano indeed has a tendency towards grandiloquence, from which the flute seems immune. One may think of Japanese music, and of the often central part played by the shakuhachi (wooden flute), and that may be the best approach to enter the "out-of-life" world (though I disagree with this characterization) Lawrence is talking about in this passage. The wonderful recording by Lily Laskine and Jean-Pierre Rampal came readily to my mind while reading these lines.

But before the "Catalogue d'oiseaux", even before "Le merle noir", there was Messiaen's "Preludes pour piano", whose first piece is called "La Colombe", already a bird, even if this one is a metaphor for Messiaen's mother. This piece, at least for me, particularly resonates with Lawrence's point.

## Friday, April 17, 2009

### Fractal dimensions...And a Fractal Graph Dimension Indicator

I have already alluded to the possible confusion with regard to what the fractal dimension exactly is, and even though I try to always clarify the kind of fractal dimension I am considering in a given context, I never provided with a detailed discussion of this problem. So here it is, I am going, in this overview, to discuss the various definition of this entity, and give some references which examine their relationship in more detail.

Eventually, I shall provide with a new indicator that slightly improves on the previous calculation of the fractal dimension of a graph.

This is the oldest and most mathematically convenient definition of the fractal dimension of an object, but it is also extremely difficult to calculate exactly for most object, especially those who are not exactly self-similar, which is basically the case of all interesting objects in any applied domain.

We first need to define a measure of an object F as such:

Where a δ-cover is a countable (or finite) collection of sets of diameter at most δ that covers F.

The s-dimensional Hausdorff measure of F is then defined as:

The Hausdorff Dimension is then defined as:

The difficulty in computing this quantity lies in the definition of a δ-cover. The sets of the collection are indeed not necessarily having a diameter of δ, on the contrary, it will be frequent to have an optimal collection (in the sense of optimizing equation (1)) that will have sets with a diameter much smaller than δ, and to explicit the logic behind such a construction is only possible for extremely simple sets (typically, sets that are explicitly built through a well-known iterative process). That is obviously not the case of sets found in practice as a model of a real phenomenon.

This difficulty can be overcome by the Box-counting Dimension to which I come now. For more details about the Hausdorff Dimension see Chapter 2 in [FALC03].

The Box-counting Dimension can be defined simply as:

Where can be any of the following (not exhaustive list):

- The smallest number of closed balls of radius δ that cover F;

- The smallest number of cubes of side δ that cover F;

- The number of δ-mesh cubes that intersect F;

- The smallest number of sets of diameter at most δ that cover F;

- The largest number of disjoint balls of radius δ with centres in F.

From the definition of both the Hausdorff and the Box-counting Dimension, it is easy to see intuitively (from equation (1)) that:

For a formal proof of that and more detail about the Box-counting Dimension, see Chapter 3 in [FALC03].

There are some other alternatives to define the fractal dimension, but so far, I have not seen applications of those to finance, and therefore, I will not mention them here, see [FALC03] for a short overview of those.

I have already referred to the code written by iliko that implemented a calculation of the fractal dimension. This computation is actually inspired from this article that provides with a method to estimate the Box-counting Dimension (and not directly the Hausdorff Dimension as it is claimed in the article itself)(see equation (6) in the article).

I however noticed two slight mistakes in iliko's code:

- At line 199:

Instead of :

It should be :

- At line 213:

Instead of :

It should be :

After correction however, there is not much change in the indicator itself.

In addition I added a calculation of the standard deviation of the fractal dimension so estimated. It is also given in the article as equations (10) and (11); and that may provide information for a more precise entry point for a trade.

The MQ4 file of the FGDI Indicator can be downloaded from this address in the MQL4 Community forum.

Here is a daily EUR/USD chart representing this new indicator along with the FRASMA, and the original fractal dimension by iliko (lower window):

Eventually, I shall provide with a new indicator that slightly improves on the previous calculation of the fractal dimension of a graph.

**1)**__Hausdorff Dimension (or Besicovitch-Hausdorff Dimension).__This is the oldest and most mathematically convenient definition of the fractal dimension of an object, but it is also extremely difficult to calculate exactly for most object, especially those who are not exactly self-similar, which is basically the case of all interesting objects in any applied domain.

We first need to define a measure of an object F as such:

Where a δ-cover is a countable (or finite) collection of sets of diameter at most δ that covers F.

The s-dimensional Hausdorff measure of F is then defined as:

The Hausdorff Dimension is then defined as:

The difficulty in computing this quantity lies in the definition of a δ-cover. The sets of the collection are indeed not necessarily having a diameter of δ, on the contrary, it will be frequent to have an optimal collection (in the sense of optimizing equation (1)) that will have sets with a diameter much smaller than δ, and to explicit the logic behind such a construction is only possible for extremely simple sets (typically, sets that are explicitly built through a well-known iterative process). That is obviously not the case of sets found in practice as a model of a real phenomenon.

This difficulty can be overcome by the Box-counting Dimension to which I come now. For more details about the Hausdorff Dimension see Chapter 2 in [FALC03].

**2)**__Box-counting Dimension (or Kolmogorov Entropy, Entropy Dimension, Capacity Dimension, Metric Dimension, Logarithmic Density and Information Dimension)__The Box-counting Dimension can be defined simply as:

Where can be any of the following (not exhaustive list):

- The smallest number of closed balls of radius δ that cover F;

- The smallest number of cubes of side δ that cover F;

- The number of δ-mesh cubes that intersect F;

- The smallest number of sets of diameter at most δ that cover F;

- The largest number of disjoint balls of radius δ with centres in F.

From the definition of both the Hausdorff and the Box-counting Dimension, it is easy to see intuitively (from equation (1)) that:

For a formal proof of that and more detail about the Box-counting Dimension, see Chapter 3 in [FALC03].

There are some other alternatives to define the fractal dimension, but so far, I have not seen applications of those to finance, and therefore, I will not mention them here, see [FALC03] for a short overview of those.

**3)**__Fractal Graph Dimension Indicator__I have already referred to the code written by iliko that implemented a calculation of the fractal dimension. This computation is actually inspired from this article that provides with a method to estimate the Box-counting Dimension (and not directly the Hausdorff Dimension as it is claimed in the article itself)(see equation (6) in the article).

I however noticed two slight mistakes in iliko's code:

- At line 199:

Instead of :

*for( iteration=0; iteration < g_period_minus_1; iteration++ )*It should be :

*for( iteration=0; iteration <= g_period_minus_1; iteration++ )*- At line 213:

Instead of :

*fdi=1.0 +(MathLog( length)+ LOG_2 )/MathLog( 2 * e_period );*It should be :

*fdi=1.0 +(MathLog( length)+ LOG_2 )/MathLog( 2 * g_period_minus_1)*After correction however, there is not much change in the indicator itself.

In addition I added a calculation of the standard deviation of the fractal dimension so estimated. It is also given in the article as equations (10) and (11); and that may provide information for a more precise entry point for a trade.

The MQ4 file of the FGDI Indicator can be downloaded from this address in the MQL4 Community forum.

Here is a daily EUR/USD chart representing this new indicator along with the FRASMA, and the original fractal dimension by iliko (lower window):

## Thursday, April 9, 2009

### A trading strategy using the Fractal dimension

On this forum, somebody is proposing an Expert Advisor for MT4, with an automated strategy to enter the market that uses the Fractal Dimension.

I believe some improvements can be made, and I have shared my thoughts on the thread itself, and will continue to do so as it develops.

I believe some improvements can be made, and I have shared my thoughts on the thread itself, and will continue to do so as it develops.

## Friday, April 3, 2009

### Canon cancrizans

Here is a mathematical illustration of the "canon cancrizans" from J. S. Bach’s “Musical Offering” (1747), that will refresh the memory of Douglas Hofstadter's "Gödel, Escher, Bach: an Eternal Golden Braid" readers:

Canon 1 a 2

Canon 1 a 2

Subscribe to:
Posts (Atom)