minuteCounter is a variable which gets incremented every update (every minute) and whenever it exceeds 5 minutes, your logic runs and the variable is reset. The not get_open_orders(stock) makes sure that you don't send orders for a stock for which you already have orders sent for. That's a good precaution if you don't want to bother properly accounting for outstanding orders, because otherwise, if your existing orders and the new ones you send both get filled, you'll exceed your desired position.
Note that instead of the minute counter variable as suggested by James Jack, I'd just do
if get_datetime().minute % 5 != 0: # Only run when the minute is divisible by 5 .
return # And don't execute the rest of this function
stock = context.stocks
prices = history(bar_count = 13, frequency = '1m', field = 'price')