Need code in pi scannar

buy when candle close above 10sma and rsi 9 corssover rsi 14 in below 40 and macd crossover (12,26,9)
sell when close below in 10 sma and rsi 14 crossover rsi 9 in above 50 and macd crossover (26,12,9)

check my reply for the similar question from this Link