I believe PSAR is not giving correct results while back testing. Pls help me get the correct code for below conditions

Can u guys help me with code for below-

1. Buy- If current bar closes above PSAR and previous close should be below PSAR. Buy Exit- Current bar closes below PSAR,

2 .Sell-  If current bar closes below PSAR and previous bar close should be PSAR​, Sell Exit- If current bar closes above PSAR​

REPLACE 0.02 TO 0.01 IN PSAR AND USE 30 MIN CANDLE ONLY MAY HELP YOU