RSI of Moving Average - page 33

298

Krzysztof

You might want to read this post : https://www.mql5.com/en/forum/183208/page2

It might save you some time (I was looking for my coding error for 1 whole day only to find out that the error was not in my code at all)

regards

Yes, RSIOMA using both iMA and iMAOnArray and after replacing RSI implementation with Wilders

one (so like in MATLAB) MT4 chart still does not match MATLAB chart, its only 'more or less'

similar.

Krzysztof

155990

fajst_k:
Yes, RSIOMA using both iMA and iMAOnArray and after replacing RSI implementation with Wilders

one (so like in MATLAB) MT4 chart still does not match MATLAB chart, its only 'more or less'

similar.

Krzysztof

Here is a set of basic averages that are all working correctly

When I replaced the iMA() and iMAOnArray() calls to calls to these functions, in the case I had those errors, all became OK. Might help, who knows

//------------------------------------------------------------------

//

//------------------------------------------------------------------

//

//

//

//

//

#define _maWorkBufferx1 1 //

#define _maWorkBufferx2 2 // to be multiplied with the ttal numeber

#define _maWorkBufferx3 3 // of averages instances that will be used

#define _maWorkBufferx5 5 //

double iCustomMa(int mode, double price, double length, int i, int instanceNo=0)

{

int r = Bars-i-1;

switch (mode)

{

case 1 : return(iEma(price,length,r,instanceNo));

case 2 : return(iSmma(price,length,r,instanceNo));

case 3 : return(iLwma(price,length,r,instanceNo));

default : return(iSma(price,(int)length,r,instanceNo));

}

}

//

//

//

//

//

double workSma[][_maWorkBufferx2];

double iSma(double price, int period, int r, int instanceNo=0)

{

if (ArrayRange(workSma,0)!= Bars) ArrayResize(workSma,Bars); int k = period; instanceNo *= 2;

//

//

//

//

//

workSma[r] = price;

if (r>=period)

workSma[r] = workSma[r-1]+workSma[r]-workSma[r-period];

else { workSma[r] = 0; for(k=0; k=0; k++) workSma[r] += workSma[r-k]; }

return(workSma[r]/k);

}

//

//

//

//

//

double workEma[][_maWorkBufferx1];

double iEma(double price, double period, int r, int instanceNo=0)

{

if (ArrayRange(workEma,0)!= Bars) ArrayResize(workEma,Bars);

//

//

//

//

//

double alpha = 2.0 / (1.0+period);

if (r>0)

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

else workEma[r] = price;

return(workEma[r]);

}

//

//

//

//

//

double workSmma[][_maWorkBufferx1];

double iSmma(double price, double period, int r, int instanceNo=0)

{

if (ArrayRange(workSmma,0)!= Bars) ArrayResize(workSmma,Bars);

//

//

//

//

//

if (r<period)

workSmma[r] = price;

else workSmma[r] = workSmma[r-1]+(price-workSmma[r-1])/period;

return(workSmma[r]);

}

//

//

//

//

//

double workLwma[][_maWorkBufferx1];

double iLwma(double price, double period, int r, int instanceNo=0)

{

if (ArrayRange(workLwma,0)!= Bars) ArrayResize(workLwma,Bars);

//

//

//

//

//

workLwma[r] = price;

double sumw = period;

double sum = period*price;

for(int k=1; k=0; k++)

{

double weight = period-k;

sumw += weight;

sum += weight*workLwma[r-k];

}

return(sum/sumw);

}
298

I replaced iMA and iMAOnArray with your code and now there is a match with MATLAB printout. Have a look

Thanks !!!

Krzysztof

Files:
rsioma_1.jpg 25 kb
r1.jpg 353 kb
r2.jpg 347 kb
155990

fajst_k:
I replaced iMA and iMAOnArray with your code and now there is a match with MATLAB printout. Have a look

Thanks !!!

Krzysztof

Krzysztof

I am glad that you too finally got to solution

But your case, the same as mine, is showing one very sad fact : that metatrader is having very serious errors and that it can not be trusted at all. A trading platform in which we can not trust a simple moving average? Then what can we trust? They had some problems with the older builds (before this "new" metatrader 4) but this is anything but encouraging for any trader to use

1232

Guys, you have proved what I have suspected. That new metatrader 4 is so full of errors that it does not deserve to be called an application at all. It is not a release version. It is not a beta. It is not an alpha. It is a sub-zero version

298

Krzysztof

I am glad that you too finally got to solution

But your case, the same as mine, is showing one very sad fact : that metatrader is having very serious errors and that it can not be trusted at all. A trading platform in which we can not trust a simple moving average? Then what can we trust? They had some problems with the older builds (before this "new" metatrader 4) but this is anything but encouraging for any trader to use

Yes, if the basics are not working is a big problem. On the other hand is conflict on interests here, FOREX is a game with minus sum so someone must loose that other will win and for sure

its not a broker interest to have perfect trading platform that a lot of traders will win....

until 1st law suit against broker which distribute buggy MT4. This, I believe would solve

this situation quick...

Krzysztof

155990

fajst_k:
Yes, if the basics are not working is a big problem. On the other hand is conflict on interests here, FOREX is a game with minus sum so someone must loose that other will win and for sure

its not a broker interest to have perfect trading platform that a lot of traders will win....

until 1st law suit against broker which distribute buggy MT4. This, I believe would solve

this situation quick...

Krzysztof

It probably is going to be the case

Frankly, the error with moving averages is hard to believe. I mean, I suppose that they have good coders involved in new metatrader 4 development there. So, why are those things wrong then? Or I am wrong assuming that the coders there are doing their coding job as they should?

298

Good coders are expensive and usually as company grows they are replaced by cheaper but worse or not experienced coders. But coders are not a problem here but regression testing so test of existing basic functionality. Seems that they don't do it, most likely they even don't have proper test instructions to do it....Who will check them in Russia if they follow common rules....until 1st law suit...if they will get a fine or ban then they will change the approach.

3231

I think that with a law suit it is hard. In Russia the are untouchable for law suit coming outside the Russia. And it is hard to imagine that somebody fro Russia will do it : if they do not lack money (minority) then they are already "compensated". And those that lack money simply can not do anything

4412

what if THEY are not in Russia???...........