RSI EA Close positions in case of market crash.

 

Hi Everyone, 

Hope you are all doing well. I just wrote my first code, and I was wondering if you could give me some guidance on something I have been trying to learn. 

I have written a simple RSI EA with a particular take profit i.e. 100. 

I wanted to add an extra code additional to the take profit that enables you to say, close position buy or sell in case 'sell' position reaches 90 RSI level close position, in case buy position reaches 10 close short position. 

Why am I doing this. This is to cover it in case of a market crash where the EA opens a buy (because it has touched the level 30) but instead of going into profit the market say crashes and that position remains open and RSI reaches 10 which would mean my buy position would suffer a huge loss. I do not want to add this function through a simple stop loss because for the purpose of this I need to set that the buy and relevant sell positions close when they drastically loose at RSI levels. 

It would be highly appreciated if you could direct me to a specific place where I can find a code or resource where I can learn this. Ideally any help in writing this  very very short code for this option would be best (if it's simple). 

Many Thanks!

Reason: