how to back test the gap up stock

if a stock is gapped up by .5% or more than .5% and when the market open i would like to sort sell that stock so what will be the script for back testing if i book profit at half of the gap in intraday,