Heiken Ashi bars stratagy need code help

Hello Sir ,

Buy : When 20 EMA cross over, MACD crossover and Heiken Ashi bar and become Green.
Sell: immediately when Heiken Ashi bar turn to Red end.

Sell: When 20 EMA slope under and Heiken Ashi become green to red.

Kindly help with code on above condition. I have Zerodha account from past 7 year.

For the above given condition

Buy:

SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
SET HAO = (REF(OPEN,1)+REF(CLOSE,1))/2
SET A = MACDSignal(13, 26, 9, SIMPLE)
SET B = MACD(13, 26, 9, SIMPLE)
CROSSOVER(A, B) = TRUE AND CLOSE>EMA(CLOSE,20) AND HAC>HAO

Sell:

SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
SET HAO = (REF(OPEN,1)+REF(CLOSE,1))/2
CLOSE<EMA(CLOSE,20) AND HAC<HAO