Please Provide me Algo code for Buy & Sell and also exits.?

Please Provide me Algo code for Trading Conditions

Buy EMA 9 cross EMA 18 and exit Long trade when EMA 4 cross EMA 9

Sell EMA 4 cross EMA 18 and exit Short trade when EMA 4 cross EMA 9

As per the above condition

Buy Script:

CROSSOVER(EMA(CLOSE,9),EMA(CLOSE,18))

Exit Long:

CROSSOVER(EMA(CLOSE,4),EMA(CLOSE,9))

Sell Script:

CROSSOVER(EMA(CLOSE,4),EMA(CLOSE,18))

Exit Short:

CROSSOVER(EMA(CLOSE,4),EMA(CLOSE,9))