Coding for strategy

I would like to create a coding based on Heiken ashi candles as follows :

Buy condition :

When Heiken ashi candle closes above previous Heiken ashi candle high

Sell

When Heiken ashi candle closes below previous heiken ashi candle low

Hello here is the code for your strategy.

Buy:

CLOSE > REF(HIGH, 1)

Sell:

CLOSE < REF(LOW, 1)