Max spread

 
Hello guys, help me please, what mt4 script Should looks like if i need this option for expert:
MaxSpread=30
Step for spread=10
So if spread is going more then 40 or below 20 - ea stop trading
Thanks in advance

 

Like this maybe?

int spread=SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);
if(MathAbs(spread-MaxSpread)<=SpreadStep) OpenTrade();