Please help me coding…. > Buy Nifty when crossing 8 Day exponential moving average

Please help me coding….> Buy Nifty when crossing 8 Day exponential moving average from down is keeping stoploss of 27 points from buy price and target 70 points from buy price.

And sell when Nifty price crossing 8 Day exponential moving average from above keeping stoploss of 27 points from our sell price and target 70 points from sell price.

you can use price alert indicator https://zerodha.com/expert-advisors/code/price-alert-indicator

and the syntax of EMA is 

EMA(CLOSE,8)

If i use EMA(CLOSE,8) in buy level it gives me something different value, whereas i need EOD 8 Day EMA value.
plz suggest what should be the code to get end of the day (EOD) ema

you need to select chart timeframe as day candles you will get EMA of close of candle

ok done. but how to write code for buy nifty above 8 Day EMA & sell nifty below 8 Day EMA