Need Code for my Strategy

I am experimenting a Strategy and i need a script code for a Bollinger Band strategy mainly for Day trading. say Buy if 5 min candlestick make crossover & closes above BBM and to SELL if it makes crossover & closes below BBM?

i have created BUY SIGNAL
SET A = CLOSE
SET B = BBM(CLOSE,14,2,EXPONENTIAL)
SET A > SET B

but when i run this as expert advisor, it gives me Buy Signal even if the close was already made crossover 2 candlesticks back and presently almost reached to BBT and vice versa for SELL signal.

What i want is, an immediate signal from the system only when candle closes above or below BBM and not to generate false signal of Buying / Selling when they already in the Upper Band / Lower Band.

for the immediate signal use LAST insterd if CLOSE, As LAST indicates the current market proice/ LTP