Something interesting, old thread - page 54

 
dr.house7:
if I were as good as you, I would love to do this

So this is a big problem for me, cause I need to use the MA array in the calculation

if (cciValue2[0] > maValue2[0]) {cci2 = " 0 "; cocci2 = Blue; ucci2 = 1; dcci2 = 0;}

Try calculating ma value like this :

maValue1 = SimpleMA(rates_total-i-1,period1,cciValue1);

and do not set the cciValue1 array as series

 
mladen:
Try calculating ma value like this :
maValue1 = SimpleMA(rates_total-i-1,period1,cciValue1);
and do not set the cciValue1 array as series

Well I did try again and again without success...I don't understand how metaeditor calculate arrays

What's wrong now?

Files:
mah_mod_3.mq5  10 kb
 
dr.house7:
Well I did try again and again without success...I don't understand how metaeditor calculate arrays What's wrong now?

Doc

The loop already goes from 0 to rates_total so no need for rates_total-i-1Here is the version that works (with some other changes too)

Files:
mah_mod_3_1.mq5  10 kb
 
mladen:
Doc The loop already goes from 0 to rates_total so no need for rates_total-i-1Here is the version that works (with some other changes too)

Thank you, I replace this with 0 and now works

if (cciValue1[rates_total-1] > ExtBLBuffer[rates_total-1]) {cci1 = " 0 "; cocci1 = Blue; ucci1 = 1; dcci1 = 0;}

else if (cciValue1[rates_total-1] < ExtBLBuffer[rates_total-1]) {cci1 = " 0 "; cocci1 = Red; ucci1 = 0; dcci1 = 1;}

else {cci1 = " 0 "; cocci1 = Yellow; ucci1 = 0; dcci1 = 0;}

 

Good morning!

Well I tried it a little bit more but it doesn't work. Instead of rates_total-1 I need to have 0 here

if (cciValue1[0] > ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Blue; ucci1 = 1; dcci1 = 0;} else if (cciValue1[0] < ExtBLBuffer[0]) {cci1 = " 0 "; cocci1 = Red; ucci1 = 0; dcci1 = 1;}
 
dr.house7:
Good morning! Well I tried it a little bit more but it doesn't work. Instead of rates_total-1 I need to have 0 here

Doc

You can not chose a "mixture". If the array is set as series then you can use 0,. If it is not set as series, then you must use rates_total-1

 
mladen:
Doc You can not chose a "mixture". If the array is set as series then you can use 0,. If it is not set as series, then you must use rates_total-1

Dear Mladen,

in the previous page of this thread I asked you how to call the SMA

Re:

Originally Posted by dr.house7

Mladen,

I have a doubt...I call the MA like this

Code:

maValue1 = SimpleMA(i,period1,cciValue1);

so it's not an handle, how could I use the "ArraySetAsSeries" function? I need to keep the price of CCI, that's my weak point

Doc

Now i'm in this situation, I have the CCI correct but the SMA nope...how could I make this SMA working like the CCI (handle- set as series etc.) to be able to place "0" in the calculation bars?

 
dr.house7:
Dear Mladen,

in the previous page of this thread I asked you how to call the SMA

Now i'm in this situation, I have the CCI correct but the SMA nope...how could I make this SMA working like the CCI (handle- set as series etc.) to be able to place "0" in the calculation bars?

Doc

You must rewrite 2 of the functions used in your code. Your StdDev_Func() and SimpleMA() functions are forcing you to work the way it is written now. You have to rewrite the StdDev_Func() and SimpleMA() to use arrays that are set as series in order to be able to work like that.

 
mladen:
Doc You must rewrite 2 of the functions used in your code. Your StdDev_Func() and SimpleMA() functions are forcing you to work the way it is written now. You have to rewrite the StdDev_Func() and SimpleMA() to use arrays that are set as series in order to be able to work like that.

ok,

so I need to place this after rates_total

double workSma[][2];

double iSma(double price, int period, int i,int bars, int instanceNo=0)

{

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

if (period<2) return(price);

//

//

//

//

//

workSma = price;

if (i>=period)

workSma = workSma+(workSma-workSma)/(double)period;

else { workSma = 0; for(k=0; k=0; k++) workSma += workSma;

workSma /= k; }

return(workSma);

}

then I need to make something like that for std dev ?

 
dr.house7:
ok,

so I need to place this after rates_total

double workSma[][2];

double iSma(double price, int period, int i,int bars, int instanceNo=0)

{

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

if (period<2) return(price);

//

//

//

//

//

workSma = price;

if (i>=period)

workSma = workSma+(workSma-workSma)/(double)period;

else { workSma = 0; for(k=0; k=0; k++) workSma += workSma;

workSma /= k; }

return(workSma);

}
then I need to make something like that for std dev ?

no, it's not that

Reason: