Code for Pi based on Volume

I want to use the below condition on EOD chart.

Buy- If Volume is greater than avg. volume of previous 5 days and current price is more than previous day closing.

VOLUME>SMA(VOLUME,5) AND LAST>REF(CLOSE,1)