Can anyone help me with creating the following strategy

I need to back test how Nifty 50 stocks have performed when their closing price is down by more than 5% from its 20 period EMA. Basically the entry happens when the latest close price is down by 5% from its 20 period EMA. Can anyone help me??

I think this will help you with your requirement. add stoploss and target profit as you require to test