Random Flow Theory and FOREX - page 59

 

Experts worry about harm to hearing from MP3 players

http://www.smh.com.au/news/digital-music/turn-it-down/2007/01/04/1167777193761.html?from=rss

 
Well, it was necessary to find not something good and useful, but to dig up such ...

I suggest you read Malakhov. There's a lot of interesting stuff there for you, go ahead...

 

timbo писал(а) >>

A profitable strategy on a stationary random process is created on the count of one.

You say that on a one time basis.
Please don't be lazy and write a script in mql that would simulate a winning strategy on a process with normal distribution.
As long as I've worked with this - I've always found that it's not a trivial task at all. As a rule, when trying to get a winning by a stationary process we obtain one of two results: either mathematical expectation of the trade = 0 or profits are so small that I'd better keep my money in the bank. I think the problem may be solved so that winnings would be at least somewhat perceptible, but it is not easy.

At the same time I would like to ask people: Has anyone has a function, which returns a value with normal distribution in a range (0,1)? I killed all day yesterday, but still haven't figured out how to implement it in mql.

 
benik писал(а) >>

I would also like to ask people: does anyone have a function that returns a value with normal distribution in the range (0,1)? I killed all day yesterday, but still haven't figured out how to implement it in mql.

It's quite easy to implement on your own, using MQL function MahtRand(). As you know, it returns a pseudorandom integer with a uniform distribution in the range from 0 to 32767. And P.D.F. of normal distribution maps the numeric axis [0, inf.] to the interval [0, 1]. So, to get a normally distributed value, you just have to take an inverse mapping of the interval [0, 1] to the Oh axis. The only question is that the argument is chosen randomly. This is what MahtRand() is used for.

That is, you first load a table of P.D.F. values of normal distribution into the program numerically as [x, F(x)].

Next, you set a function that uniformly maps [1, 32767] to (0, 1), f(x) = x/32768. As you can see, the values 0 and 1 are excluded from the interval. Therefore the value x=0 should also be skipped. These marginal effects can be accounted for in different ways, but they are of little importance.

Now generate a pseudo-random series with MahtRand(), map each of the resulting values to a unit interval, and using that point as the P.D.F. value of the normal distribution F(x), find the corresponding argument x. That's it. That is a normally distributed value.

 

Yurixx писал(а) >>


Yes, this is an option. But I would still like to make a standalone function in mql. Without loading random values from outside.
As far as I know, normal distribution can easily be obtained from uniform one by taking inverse Laplace function from uniform value in interval (0,1).
Laugh all you want, but I have a problem with taking the inverse Laplace function from MathRand()/32768.

So here is a script, which by idea should output to file "RandN(0-1).csv" that very normal value in the interval (0,1).

int start()
  {
//----
      string FileName = "RandN(0-1).csv";
      int handle = FileOpen ( FileName, FILE_CSV| FILE_WRITE);
      MathSrand(GetTickCount());
      for (int i=1; i<=32768; i++)
      {
         double val = RandN(0,1);
         FileWrite( handle, val);
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

   double RandN(int a, int sigma)
   {
      double pi = 3.14159265;
      double exp = 2.71828183;
      double x = MathRand()/32768.0;
      double pow = -(MathPow( x- a,2.0)/(2*MathPow( sigma,2.0)));
      double f = (1/( sigma*MathSqrt(2* pi)))*MathPow(exp,pow);
      return ( f);
   }
Certainly it outputs some nonsense, but I already don't have forces to improve it. If someone has time and wish, you may improve it. The error here is that the RandN() function calculates the density of distribution instead of Laplace function. If someone has no trouble calculating the integral of this function, please share it with the public. It's a difficult task for me now to think how to calculate the integral in mql.
 

benik, there's something here. Can you figure it out for yourself?

 
Thanks, I'll have a look. Just won't get it right today :) My head is already full. I'll try tomorrow. <br / translate="no">
 
Ah, there's a ready-made function for a normal distribution. Yes, thank you for that.
 
benik писал(а) >>


But I'd still like to make standalone function in mql. Without loading random values from outside.
...

You may laugh, but I have a problem with taking the inverse Laplace function from MathRand()/32768.

Well actually MathRand() is MQL function. Why do you think it is from outside?

The algorithm I outlined here works at the speed of light. There's practically no computation there. And if an array of PDF values is sorted (which is quite natural since it's monotonous), then searching in that array is also instantaneous.

Your code, on the other hand, has a lot of calculations that take a lot of time. MathPow() exponentiation takes a very long time and occurs in three places. I think this algorithm would be at least 1000 times slower. When dealing with statics you will probably have to deal with large amounts of data. Speed turns out to be a very critical parameter.

The PDF of the normal distribution can indeed be taken from Stator as well. However, since you don't have arbitrary parameter values, but only a discrete set of 32768, it's better not to calculate PDF every time, but to calculate it once preliminarily using the same Stator function and put it into a sorted array. In terms of performance, this is an optimal solution.

 
timbo >> :

In mathematics, a stationary process is one in which mean and covariance are independent of time. I.e. the two main parameters are costants.

The simplest example: a process with normal distribution N(0,1). For such a process, if x(t)=2, then with a 97.5% probability x(t+1) will be less than 2. That is, the process will go down. It is not guaranteed, then in 97 cases out of 100 it will be.

A more complex example: the AR(1) process x(t)=x(t-1)*a + s(t), where a<1 and s(t) is a stationary process, noise with some finite parameters. This process will also be stationary and its parameters can be calculated from the parameters s(t) and a. Accordingly, if this process has deviated from the mean, it can always be calculated when it will return there with a given probability.

But if parameter a=1, then we get random walk, i.e. non-stationary process, and where it will end up cannot be predicted.

Of course, in the real date we will never see white noise, just as we will never see a real stationary process, but with some assumptions we can assume that the noise is still white and the process is stationary.


What is the percentage of profitable trades in real life and the ratio of average profit to average loss?

Reason: