Different timeframes reading at the same time (indicator)

 
I'm working on this code

fasterMANow = iMA(NULL, 0, 8, 0, 1, PRICE_CLOSE, 0);
fasterMAPrevious = iMA(NULL, 0, 8, 0, 1, PRICE_CLOSE, 1);
fasterMAafter = iMA(NULL, 0, 8, 0, 1, PRICE_CLOSE, -1);
slowerMAnow = iMA(NULL, 0, 21, 0, 1, PRICE_CLOSE, 0);
slowerMAprevious = iMA(NULL, 0, 21, 0, 1, PRICE_CLOSE, 1);
slowerMAafter = iMA(NULL, 0, 21, 0, 1, PRICE_CLOSE, -1);
DfasterMAnow = iMA(NULL, PERIOD_D1, MA, 0, MAMode, PRICE_CLOSE, 0);
DfasterMAprevious = iMA(NULL, PERIOD_D1, MA, 0, MAMode, PRICE_CLOSE, 1);
DMACDcur = iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CLOSE, MODE_MAIN, 0);
DMACDprev = iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CLOSE, MODE_MAIN, 1);
DMACDpprev = iMACD(NULL,PERIOD_D1,12,26,9,PRICE_CLOSE, MODE_MAIN, 2);
if ((DMACDcur > DMACDprev) && (DMACDprev > DMACDpprev) && (DfasterMAnow > DfasterMAprevious) && (fasterMANow > slowerMAnow) && (fasterMAPrevious < slowerMAprevious) && (fasterMAafter > slowerMAafter)) {
CrossUp[pos] = 5;
}

So the code its: If 3 consecutive higher macd hist bars and if ma higher than previous, and 8/21ema crossover (current fast higher than current slow, previus faster lower than previous slow and after fast higher than after slower), pos is the current counted bar and 5 is because i draw it on an indicator with 10 level.
But as shown in the next image, its not working well...





There is a crossover in the 4h chart that should draw an arrow IF the macd has three higher preious bars but as seen in the 2nd image the macd hasnt 3 higher prev bars.
Am I using bad the PERIOD_D1 stuff or something? any suggestion?
 
The index of bar must be always positive value, 0 or great but not negative.
This is wrong line:
fasterMAafter = iMA(NULL, 0, 8, 0, 1, PRICE_CLOSE, -1);
 
thnkx i will look into it later, do you know how to use crossover conditions, i mean something better than just if fastemacurrent >= slowemacurrent && fastmapre < slowemapre?
 
Still not working, the crossover arrow is draw ok but it should be draw ONLY if the 1d macd dropped 3 bards o make 3 bars higher, and as the last image still doing the same :(