Code this strategy

I want to make a code which work on particular range like 10 candles. Suppose on 6th candle 5sma cross 50sma. Now i want to check whether stochastic crossover exist in 1-5 and 6-10 range of candles. Conditions give True if both crossover exist between range of 10 candles. Can I use loop ? If yes then please code this or give me proper syntax of loop with some examples.

As per above condition 

CROSSOVER(SMA(CLOSE, 5), SMA(CLOSE, 50)) AND 
CROSSOVER(SOPK(9, 3, 9, SIMPLE) , SOPD(9, 3, 9, SIMPLE) )

Incomplete… This condition will run only on last candle not on range of 10 candles… Please read question again properly