Need help with the strategy


Please help me code this afl:sweat:

Buy when rsi(close,14) crosses above 30
and when buy signal generates buyprice should be the average of high of previous bar (ref(close,-1) and close of previous to previous bar (ref(close,-2)

actulay i want to use robo trader to fully automate and it only buy at market price.
So i need code which can throw limit price when buying