How can I make my EA not to pass my sl

 
When am using my EA on crash1000 and I opened a buy position, the ea will not stop at stop loss if there is rapid bearish candle, it passes sl and closes down sl by far. Which code can I use to make sure that my EA stop at sl and not pass because even if i use position close below sl or does not stop there.
 

as far as i know there is no solution price is not a continuous   matter you can't enter or exit at the price you want you have to work with ask and bid

so  at one tick the price is under SL and the tick after the price is over LS so ea or human close it with current bid /ask price

 
you can set the sl level on the opened trade instead of virtual sl, that's the best you can do, or you can simply change to a better broker
 
As far as I know...

You need a counter party who is willing to buy your sell. That's market rules.

So if price moves fast and hard, buyers are missing. That's why price can move so drastically.

A solution could be to watch spread and momentum. As soon as these parameters surpass a threshold, you should begin to close your position gradually when going against you. Even if it is not at SL jet. This way, you can make sure, the losses get spread over a certain time.

To achieve good results you could use pending orders to create a scale out ladder on the move.

The threshhold could be derived from former market behaviour, giving you a dynamic value that triggers this process.

A good way to test is the CHF-Crash in 2015.