Coding help - page 170

 

Yup... i don't know how absentminded i am. Thanks to your right time advice, the numbers of TB_TotalCount and VACount become correct and absolutely reasonable. But my objectives of finding VA High/Low still in trouble, my PC get crashed again with that part of coding. Trying again to understand why now.

Thanks much Mladen! Your advice gives me a partial smile after whole white night

 

Hi Mladen,

Just to inform that finally I've solved the rest of my problem. Trying to improve it more.

Although you gave me so little help as you could in this case but I find out that's sometimes the best method of teaching ones who's learning standing on their foot.

Deeply thanks from bottom of my heart, Mladen !

Happy nice days ahead to you,

fareastol

 
zilliq:
Hi Mladen,

I succeed using the relative and absolute momentum

Thanks a lot for your help, now I need to smooth the momentum for the rsx

Zilliq

Ps: If it can help someone:

//Relative Momentum on close

ind1= close-close[1]

// Absolute momentum

ind2=abs(ind1)

ind3=wilderAverage[rs](ind1)

ind4=wilderAverage[rs](ind2)

ind3=(50*(ind3+ind4))/ind4

return ind3 as "RSI",0, 30, 70, 100

Zilliq

Take a look at this post : https://www.mql5.com/en/forum/178733/page36

You have an example how it (the smoothing) can be done there

 

Thanks Mladen, I will see that

Have a nice day and thousands thanks for all your help and work

Zilliq

 

Well, if I have well understand in your indicator rsi smoother 2, you just change the wilder average by the function ismooth

And you "ismooth" the relative and absolute momentum

I do the same with Hull average but the result is not the same as you see on my picture

Do you have an idea why, or do I a mistake ?

Thanks Mladen

And the code RSI14 and RSIsmoother 45

//Relative Momentum on close

ind1= close-close[1]

// Absolute momentum

ind2=abs(ind1)

// Smooth Relative momentum with Hull average

v =(2*weightedAverage[round(rs/2)](ind1))-weightedAverage[rs](ind1)

ind3 = weightedAverage[Round(Sqrt(rs))](v)

// Smooth Absolute momentum with Hull average

v2 =(2*weightedAverage[round(rs/2)](ind2))-weightedAverage[rs](ind2)

ind4 = weightedAverage[Round(Sqrt(rs))](v2)

ind5=(50*(ind3+ind4))/ind4

return ind5 as "RSI smooth"

I replace wilder average by a T3 Tillson on both (relative and absolute momentum), with the same problem

Files:
 

It is simply a result of using different smoothing methods. Different smoothing will give different results

If you want results comparable to the rsi posted at the rsi thread you have to use that kind of smoothing used in that indicator

 

Thanks Mladen for your answer

It's strange that a smooth of the relative and absolute momentum give such a result with some exagerations with the Hull average and the T3

Can you explain with a mathematic formula (if possible) how works the smooth of the ismooth function of MT4 to obtain a smooth RSI comparable to the RSI please and I will code it after

Thanks a lot and have a nice day

Zilliq

Your MT4 code and my interpretation:

//relative momentum

double mom = iMA(NULL,0,1,0,MODE_SMA,Price,i)-iMA(NULL,0,1,0,MODE_SMA,Price,i+1);

//absolute momentum

double moa = MathAbs(mom);

//Smooth relative momentum with the "ismooth function"

double tmom = iSmooth(mom,Length,SmoothSpeed,i,0);

//Smooth absolute momentum with the "ismooth function"

double tmoa = iSmooth(moa,Length,SmoothSpeed,i,1);

if (tmoa != 0)

//And the ratio 50*(RM+AM)(AM)

rsi = MathMax(MathMin((tmom/tmoa+1.0)*50.0,100.00),0.00);

else rsi = 50;

 

Zilliq

You have the source code of it in that indicator. Just convert it to prorealtime

 

Ouch not really easy for me to interpret the ismooth function (MT4 is so complicated compare to PRT)

I try to translate the MT4 code in mathematical code to code it after on PRT

Please can you confirm my interpretation of the different line below each line before I code it on PRT

Thanks a lot Mladen

Zilliq

double iSmooth(double price,int length, double speed, int r, int instanceNo=0)

{

if (ArrayRange(workSmooth,0)!=Bars) ArrayResize(workSmooth,Bars); instanceNo *= 5; r = Bars-r-1;

if(r<=2) { workSmooth[r] = price; workSmooth[r] = price; workSmooth[r] = price; return(price); }

//

//

//

//

//

_______________________________________________________________________

double beta = 0.45*(length-1.0)/(0.45*(length-1.0)+2.0);

beta = 0.45*(length-1.0)/(0.45*(length-1.0)+2.0)

_______________________________________________________________________

double alpha = MathPow(beta,speed);

alpha = beta^speed

_______________________________________________________________________

workSmooth[r] = price+alpha*(workSmooth[r-1]-price);

Filt0 = price+alpha*(Filt0[1]-price);

_______________________________________________________________________

workSmooth[r] = (price - workSmooth[r])*(1-alpha)+alpha*workSmooth[r-1];

Filt1 = (price - Filt0 )*(1-alpha)+alpha*Filt1[1]

_______________________________________________________________________

workSmooth[r] = workSmooth[r] + workSmooth[r];

Filt2 = Filt0 + Filt1

_______________________________________________________________________

workSmooth[r] = (workSmooth[r] - workSmooth[r-1])*MathPow(1.0-alpha,2) + MathPow(alpha,2)*workSmooth[r-1];

Filt3=Filt2-Filt4[1]*(1-alpha)*(1-alpha)+alpha*alpha*Filt3[1]

_______________________________________________________________________

workSmooth[r] = workSmooth[r] + workSmooth[r-1];

Filt4=Filt3+Filt4[1]

_______________________________________________________________________

return(workSmooth[r]);

return Filt4

 
zilliq:
Ouch not really easy for me to interpret the ismooth function (MT4 is so complicated compare to PRT)

I try to translate the MT4 code in mathematical code to code it after on PRT

Please can you confirm my interpretation of the different line below each line before I code it on PRT

Thanks a lot Mladen

Zilliq

double iSmooth(double price,int length, double speed, int r, int instanceNo=0)

{

if (ArrayRange(workSmooth,0)!=Bars) ArrayResize(workSmooth,Bars); instanceNo *= 5; r = Bars-r-1;

if(r<=2) { workSmooth[r] = price; workSmooth[r] = price; workSmooth[r] = price; return(price); }

//

//

//

//

//

_______________________________________________________________________

double beta = 0.45*(length-1.0)/(0.45*(length-1.0)+2.0);

beta = 0.45*(length-1.0)/(0.45*(length-1.0)+2.0)

_______________________________________________________________________

double alpha = MathPow(beta,speed);

alpha = beta^speed

_______________________________________________________________________

workSmooth[r] = price+alpha*(workSmooth[r-1]-price);

Filt0 = price+alpha*(Filt0[1]-price);

_______________________________________________________________________

workSmooth[r] = (price - workSmooth[r])*(1-alpha)+alpha*workSmooth[r-1];

Filt1 = (price - Filt0 )*(1-alpha)+alpha*Filt1[1]

_______________________________________________________________________

workSmooth[r] = workSmooth[r] + workSmooth[r];

Filt2 = Filt0 + Filt1

_______________________________________________________________________

workSmooth[r] = (workSmooth[r] - workSmooth[r-1])*MathPow(1.0-alpha,2) + MathPow(alpha,2)*workSmooth[r-1];

Filt3=Filt2-Filt4[1]*(1-alpha)*(1-alpha)+alpha*alpha*Filt3[1]

_______________________________________________________________________

workSmooth[r] = workSmooth[r] + workSmooth[r-1];

Filt4=Filt3+Filt4[1]

_______________________________________________________________________

return(workSmooth[r]);

return Filt4

As far as I see that should be it, but bare in mind that I never worked with prorealtime