Please help me write a Code for this strategy

My Buy Condition is – buy immediately when the price reaches the ema(50) indicator line.

I have already tried CROSSOVER ( CLOSE, EMA( CLOSE, 50)) = TRUE , but it gives buy signal only at the closing price. I want the buy signal immediately when the price reaches ema(50) and not wait for the bar to close.

My Long Exit Condition is – Sell immediately when a profit target of 10 rupees is reached. i.e. Buy Price + Rs. 10

I would also like to know how to code if the Long Exit condition is Buy Price + 1%

Thanks in advance.

Buy Script:


Sell Script: