How do I code that if Stoch D and K should trade when they cross each other

How do I code that if Stoch D and K should trade when they cross each other

Good day all
How do I build a buy stop for Boom?
I want a trade to open when a spike kicks in, even if it is 50-100 pips away from the ask line