RSI of Moving Average - page 35

 

It was bout the same time (the Cyprus)

 

Checked it : Cyprus "shave" was at the end of March. Already in June they started to announce changes in metatrader 4 (it took them 1 month to come up with the solution for the money they lost there. And now we are forced to use this only because they were laundering money through Cyprus

 
mladen:
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);

}

I'm using your code as a replacement iMA and iMAOnArray like this

if (!detrend)for (i=limit; i >= 0; i--) mab = iCustomMa(Before_Mode,Close,Period_Before,i,0);

than sometimes (not always) I'm getting this on the screen (see vertical green rsi plot)

Files:
notok.jpg  380 kb
 
fajst_k:
I'm using your code as a replacement iMA and iMAOnArray like this

if (!detrend)for (i=limit; i >= 0; i--) mab = iCustomMa(Before_Mode,Close,Period_Before,i,0);

than sometimes (not always) I'm getting this on the screen (see vertical green rsi plot)

Are you using averaging more than once in the code?

 

But when I use just iMA than is ok

if (!detrend)for (i=limit; i >= 0; i--) mab = iMA(NULL,0,Period_Before,0,Before_Mode,0,i);

I think its related to ticks and real time work as vertical rsi green line occurs only in case of RT streaming.

Any idea ??

Krzysztof

Files:
ok.jpg  378 kb
 
mladen:
Are you using averaging more than once in the code?

Yes, later I'm using it again

 
fajst_k:
Yes, later I'm using it again

The multiply the constants in this part :

#define _maWorkBufferx1 1

#define _maWorkBufferx2 2

#define _maWorkBufferx3 3

#define _maWorkBufferx5 5

(the 1,2,3 and 5) with the number of instances you are using it and use different instance number for each new instance (the last parameter) and then try it out. It has to work correctly

 
mladen:
The multiply the constants in this part :
#define _maWorkBufferx1 1

#define _maWorkBufferx2 2

#define _maWorkBufferx3 3

#define _maWorkBufferx5 5
(the 1,2,3 and 5) with the number of instances you are using it and use different instance number for each new instance (the last parameter) and then try it out. It has to work correctly

and now is OK.

Thanks, Krzysztof

 
fajst_k:
and now is OK. Thanks, Krzysztof

Good One more mql trap avoided. Happy coding and trading

 

Wilder RSI results

fajst_k:
Here are results for RSIOMA EA non detrend setting for 6 pairs for 1 week 1 min data. Seems to be slightly profitable

Krzysztof

USDJPY Gross profit 67.74 Gross loss -85.46

GBPUSD Gross profit 118.30 Gross loss -133.40

GBPJPY Gross profit 127.93 Gross loss -217.59

EURUSD Gross profit 194.50 Gross loss -77.30

AUDUSD Gross profit 126.80 Gross loss -97.50

AUDJPY Gross profit 163.33 Gross loss -126.12

PF 1.08

and here you have the results for the same data, the same settings only that instead of MT4 RSI, Wilder RSI is used. Immediate improvements of PF by more than 100%.

Stop loss was set 1st to 30 than 60 average ranges. Enjoy !!!

Krzysztof

sltp30 lb 1440 pb 0.2

AUDJPY Gross profit 274.66 Gross loss -104.28 10

AUDUSD Gross profit 174.40 Gross loss -136.60 12

EURUSD Gross profit 97.20 Gross loss -137.60 19

GBPJPY Gross profit 388.60 Gross loss -4.52 13

GBPUSD Gross profit 222.20 Gross loss -127.20 26

USDJPY Gross profit 168.65 Gross loss -75.74 15

PF 2.26 trades 95

sltp60 lb 1440 pb 0.2

AUDJPY Gross profit 180.12 Gross loss -19.84 6

AUDUSD Gross profit 128.80 Gross loss -69.60 10

EURUSD Gross profit 85.60 Gross loss -231.00 18

GBPJPY Gross profit 308.05 Gross loss -4.52 11

GBPUSD Gross profit 181.00 Gross loss -55.80 22

USDJPY Gross profit 169.35 Gross loss -35.55 12

PF.2.52 trades 79