# Value in an array for 2 matching arrays

8

I have an expert that enables to take entries on the market. The expert calculates the CCI and the moving average 100 from past 150 periods and gets a value in memory . Whenever the price is above the moving average, and the previous price has open and close on upper and lower to the moving average 100 , it stores the MA 100 value for the Bar  in an array . The second indicator launches the confirmation and the buy order is sent .  How to store the MA 100 for the most current bar where the price is above the MA 100 ? The expert has two choice : storing the indicated value or set it to 0 .

I have tried this EA :

```   if( OrdersTotal() >= 0 )
{

MMHigh[151] =  0 ;
THigh[151] = 0     ;
datetime TH10P = 0, TL10P = 0  ;
int B010[151], B010P[151] ;

if (iHigh(Symbol1[ag10P],PERIOD_H1,150) >= iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,150)
&& iLow(Symbol1[ag10P],PERIOD_H1,150) <= iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,150)
&& iLow(Symbol1[ag10P],PERIOD_H1,149) > iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,150))
{

MMHigh[149] = iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,150) ;
THigh[149] = iTime(Symbol1[ag10P],PERIOD_H1,150) ;
BaShiftH10[149] = 150  ;
B010[149] = 1010 ;

}
else
{

MMHigh[149] = 0 ;
THigh[149] = 0  ;
B010[149] = 20 ;

BaShiftH10[149] = 500 ;

}

for( int ag1 = 148 ; ag1 >= 0 ; ag1--)
{

if (B010[ag1+1] == 1010 )
{

if (iLow(Symbol1[ag10P],PERIOD_H1,ag1) >  MMHigh[ag1+1] )
{

MMHigh[ag1] =  MMHigh[ag1+1] ;
BaShiftH10[ag1] = BaShiftH10[ag1+1]  ;
B010[ag1] = 1010 ;

}

else
{
MMHigh[ag1] = 0 ;
B010[ag1] = 20 ;
BaShiftH10[ag1] = 500 ;

}
}

if( B010[ag1+1] == 20  )
{

if (iHigh(Symbol1[ag10P],PERIOD_H1,ag1+1) > iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,ag1+1)
&& iLow(Symbol1[ag10P],PERIOD_H1,ag1+1) < iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,ag1+1)
&& iLow(Symbol1[ag10P],PERIOD_H1,ag1) > iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,ag1+1))
{

MMHigh[ag1] = iMA(Symbol1[ag10P],PERIOD_H1,PERIODMA,0,MODE_SMA,PRICE_CLOSE,ag1) ;
THigh[ag1] = iTime(Symbol1[ag10P],PERIOD_H1,ag1) ;

B010[ag1] = 1010 ;

BaShiftH10[ag1] =  ag1  ;

}

else
{

MMHigh[ag1] = 0 ;
THigh[ag1] = 0  ;
B010[ag1] = 20 ;

BaShiftH10[ag1] =    500  ;

}

}

}

}

```

The EA indicates 500 after the 10th value . How to get the value of MA 100 stored for the last occurence of the Bar Shift on an array?

will have to set this for the next EA

8

and gets a value in memory . Whenever the price is above the moving average, and the previous price has open and close on upper and lower to the moving average 100 , it stores the MA 100 value for the Bar  in an array . The second indicator launches the confirmation and the buy order is sent .  How to store the MA 100 for the most current bar where the price is above the MA 100 ? The expert has two choice : storing the indicated value or set it to 0 .

How to fix this ?

Thank you