How to code? - page 295

 

this kind of indicator about Hurst Exponent

mladen:
This part :

for (i=limit-1;i>=0;i--)

{

for (int j=0;j<n;j--)

{

for (i=limit-1;0<=i<=j;i--) // you are alrady using "i" variable in in the outer loop

{

double B=0,SUM[]; // Sum is an un-initialized array and shoulde be created out of this loop.

B=B+A;

SUM[j]=B;

}

}

H=MathLog((SUM[ArrayMaximum(SUM,n,0)]-SUM[ArrayMinimum(SUM,n,0)])/S)/MathLog(n/2);

}
Commented where the error is. Without description I can not say what are you trying to achieve wiith that code, so I can not alter it.

In harmonic trading we use the Hurst Exponent as an estimate of

predictability of a price data stream. It indicates if the price action is

likely to have:-

Persistence - value 0.5 - 1 (i.e. whatever is happening now is

likely to continue)

Anti-persistence - value 0 - 0.5 (i.e. whatever is happening now

is likely to reverse)

Randomness - value around 0.5 (i.e. likely to go in any

direction)

Dear mladen,sorry,english is not my mother language,Can you help to write the complete code with the following calculation ideas?

Step_A、X= MathLog(Close/Close)

{ the value of H from a single R/S eg:

Step1、E = (1/n)*[X(0)+X(1)+X(2)+...+X(n-1) ] //din n>=10

Step2、A(0) = X(0) - E

A(1) = X(1) - E

A(2) = X(2) - E

...

A(n-1) = X(n-1) – E

Step3、SUM(0) = A(0)

SUM(1) = A(0)+ A(1)

SUM(2) = A(0)+A(1) + A(2)

...

SUM(n-1) = A(0)+A(1) + A(2) + ...+ A(n-1)

Step4、R= Maximum(SUM,n) - Minimum(SUM,n)

Step5、H = log(R/S)/log(n/2) // Let s be the standard deviation of the set of { X(0),X(1), X(2), ... X(n-1)}

}

Step_B、calculate H from the set of { X(i),X(i+1), X(i+2), ... X(i+n-1)}

Step_C、Calculate the exponential moving average of H, Let it smooth ,if the exponential moving average of H is equal to 0.5 then alert“lookout”

And make this indicator can work in Multi Time Frime, please,thanks

 

...

chenairbin

I recommenced that you read this post : https://www.mql5.com/en/forum/173010/page19 for some additional information

Since Sevciks (the one with a problem I was talking about) nor the corrected Fractal dimension index (correction made by Alex Matulich) nor Hurst exponent are not attached at that post here they are too

Also, you will notice that those versions do not match exactly the 2- Fractal dimension index equity, but I decided to leave those as they are instead of forcing it to be exactly the same

chenairbin:
In harmonic trading we use the Hurst Exponent as an estimate of

predictability of a price data stream. It indicates if the price action is

likely to have:-

Persistence - value 0.5 - 1 (i.e. whatever is happening now is

likely to continue)

Anti-persistence - value 0 - 0.5 (i.e. whatever is happening now

is likely to reverse)

Randomness - value around 0.5 (i.e. likely to go in any

direction)

Dear mladen,sorry,english is not my mother language,Can you help to write the complete code with the following calculation ideas?

Step_A、X= MathLog(Close/Close)

{ the value of H from a single R/S eg:

Step1、E = (1/n)*[X(0)+X(1)+X(2)+...+X(n-1) ] //din n>=10

Step2、A(0) = X(0) - E

A(1) = X(1) - E

A(2) = X(2) - E

...

A(n-1) = X(n-1) – E

Step3、SUM(0) = A(0)

SUM(1) = A(0)+ A(1)

SUM(2) = A(0)+A(1) + A(2)

...

SUM(n-1) = A(0)+A(1) + A(2) + ...+ A(n-1)

Step4、R= Maximum(SUM,n) - Minimum(SUM,n)

Step5、H = log(R/S)/log(n/2) // Let s be the standard deviation of the set of { X(0),X(1), X(2), ... X(n-1)}

}

Step_B、calculate H from the set of { X(i),X(i+1), X(i+2), ... X(i+n-1)}

Step_C、Calculate the exponential moving average of H, Let it smooth ,if the exponential moving average of H is equal to 0.5 then alert“lookout”

And make this indicator can work in Multi Time Frime, please,thanks
 

mladen

mladen:
chenairbin

I recommenced that you read this post : https://www.mql5.com/en/forum/173010/page19 for some additional information

Since Sevciks (the one with a problem I was talking about) nor the corrected Fractal dimension index (correction made by Alex Matulich) nor Hurst exponent are not attached at that post here they are too

Also, you will notice that those versions do not match exactly the 2- Fractal dimension index equity, but I decided to leave those as they are instead of forcing it to be exactly the same

the cod in Hurst cofficient.mq4

AppliedPrice = PRICE_CLOSE

maxY = MathMax(y[k],maxY);

minY = MathMin(y[k],minY);

should be

AppliedPrice=In(price/price)

maxY = y[ArrayMaximum(y,HurstLength,i)];

minY = y[ArrayMinimum(y,HurstLength,i)];

and then Hurst cofficient needs to be modified ,Do me a favor,Thank you very much!

 

...

chenairbin

That code is just a part of hurst calculating code

The whole block of code is this one :
for (k=1; k<HurstLength; k++)

{

y[k] = y[k-1] + x[k];

maxY = MathMax(y[k],maxY);

minY = MathMin(y[k],minY);

}

As you can see it is looping which is functionally equivalent to ArrayMaximim() and ArrayMinimum() you are proposing, You can not look at those 2 lines of code (the MathMin() and MathMax()) neglecting the loop that they are executed in

Applied price refers to the price that is going to be used in calculation (the usual ones : close, open, high, low, median, typical and weighted) Their difference is calculated otherwise (there is no such price as In(price/price))

chenairbin:
the cod in Hurst cofficient.mq4

AppliedPrice = PRICE_CLOSE

maxY = MathMax(y[k],maxY);

minY = MathMin(y[k],minY);

should be

AppliedPrice=In(price/price)

maxY = y[ArrayMaximum(y,HurstLength,i)];

minY = y[ArrayMinimum(y,HurstLength,i)];

and then Hurst cofficient needs to be modified ,Do me a favor,Thank you very much!
 

mladen

mladen:
chenairbin

That code is just a part of hurst calculating code

The whole block of code is this one :
for (k=1; k<HurstLength; k++)

{

y[k] = y[k-1] + x[k];

maxY = MathMax(y[k],maxY);

minY = MathMin(y[k],minY);

}

As you can see it is looping which is functionally equivalent to ArrayMaximim() and ArrayMinimum() you are proposing, You can not look at those 2 lines of code (the MathMin() and MathMax()) neglecting the loop that they are executed in

Applied price refers to the price that is going to be used in calculation (the usual ones : close, open, high, low, median, typical and weighted) Their difference is calculated otherwise (there is no such price as In(price/price))

Erik Long said on this site Fractal Dimension Index by Erik T. Long

We can also estimate the value of H from a single R/S value by:

H = log(R/S)/log(n/2) // is it correct ?

For the markets, I use logarithmic returns instead of percentage changes in prices:

St = ln(Pt/P(t-1))

Where St = logarithmic return a time t Pt = Price at time t //such price as In(Close/Close)

can you fix the cod along with Erik Long

i use the follow cod in Hurst coefficient.mq4,and it works well with the site(http://www.stator-afm.com/hurst-exponent.html) saids

Anyway, what Hurst apparently found, was that the plot had a slope closer to 0.7 (rather than 0.5).

maxY = y[ArrayMaximum(y,HurstLength,0)];

minY = y[ArrayMinimum(y,HurstLength,0)]; }

double iValue = 0; if (sums !=0) iValue = (maxY - minY)/MathSqrt(sums/HurstLength);

double hurst = 0; if (iValue > 0) hurst = MathLog(iValue)/ MathLog(HurstLength/2);

how about when it modified along with Erik Long?

For the markets, I use logarithmic returns instead of percentage changes in prices:

St = ln(Pt/P(t-1))

Where St = logarithmic return a time t Pt = Price at time t //such price as In(Close/Close)

i am looking forward to hearing from you ? thanx

 
ymkoh:
Thank for the info!

I've tried most of them but none can work.

examples:- EA Trading TF H1 VQ input 240.

It only works on Trading TF H1 VQ input 0 default.

Attached screenshot show example trading TF H1 buysell signal trigger by VQ indicator H4 timeframe. (No EA attached)

vq7.mq4

I'm having a difficulty. someone help me..please help me..how to code??

 

...

Take a look at this section for start : Lessons

april:
I'm having a difficulty. someone help me..please help me..how to code??
 

...

This might help : this is the original description of FDI (and Hurst exponent) calculation by Erik Long published in TASC May 2003

chenairbin:
Erik Long said on this site Fractal Dimension Index by Erik T. Long

We can also estimate the value of H from a single R/S value by:

H = log(R/S)/log(n/2) // is it correct ?

For the markets, I use logarithmic returns instead of percentage changes in prices:

St = ln(Pt/P(t-1))

Where St = logarithmic return a time t Pt = Price at time t //such price as In(Close/Close)

can you fix the cod along with Erik Long

i use the follow cod in Hurst coefficient.mq4,and it works well with the site(Hurst Exponent) saids

Anyway, what Hurst apparently found, was that the plot had a slope closer to 0.7 (rather than 0.5).

maxY = y[ArrayMaximum(y,HurstLength,0)];

minY = y[ArrayMinimum(y,HurstLength,0)]; }

double iValue = 0; if (sums !=0) iValue = (maxY - minY)/MathSqrt(sums/HurstLength);

double hurst = 0; if (iValue > 0) hurst = MathLog(iValue)/ MathLog(HurstLength/2);

how about when it modified along with Erik Long?

For the markets, I use logarithmic returns instead of percentage changes in prices:

St = ln(Pt/P(t-1))

Where St = logarithmic return a time t Pt = Price at time t //such price as In(Close/Close)

i am looking forward to hearing from you ? thanx
Files:
fdi.gif  118 kb
 

One more help about Hurst cofficient.mq4

mladen:
This might help : this is the original description of FDI (and Hurst exponent) calculation by Erik Long published in TASC May 2003

Many thanks,i am newer in the area of mql4 , Please help to improve cod with Erik Long’s price。

For the markets, I use logarithmic returns instead of percentage changes in prices:

St = ln(Pt/P(t-1))

Where St = logarithmic return a time t Pt = Price at time t //such price as In(Close/Close)

 

anyone there to correcting my mql 4 code ?

as mentioned above,

i just edit my mql4 code, but it seem not working,

there are a lot error in my mql4 code,

just wish someone here to correct my mql 4 code.

please, i really need ur help.

Reason: