Waiting for the New Candle

I would like to know how to wait for the current candle to close to trigger the signals. for example, in the following code :-

xMa = MA(C, 21);
Buy = Cross(C,xMa);
Sell = Cross(xMa,C);

I am using 5 min time frame. When the prices are fluctuating widely in the same candle more signals will be triggered for the above afl. As a solution to this, how can I wait for the next candle to open.

Moderator comment: added code tags and fixed missing parameter in MA call

You can just move the Buy and Sell signal to the next bar.

This code will work on any timeframe.

xMa  = MA( C, 21 );
Buy  = Ref( Cross( C, xMa), -1);
Sell = Ref( Cross( xMa, C), -1);

Kindly use code tags henceforth, its mandatory on this forum.