AFL code for buy above candle high

I need AFL code for simple Ema cross over.
When Ema cross over happens , i want to buy above that candle high and place SL below that candle low.
Target would be 2 times of range of that candle.
I tried but this executes for candle closing price