All Sharpe calculations I have seen calculate it over time, not based on trades. They have all considered ALL bars, not just in-the-market bars. You could certainly do per-trade or in-the-market only, but that would give you a somewhat skewed indication. E.g. a system that traded once every 5 years with a 100% win rate would have a very high (infinite?) Sharpe with per-trade/ITM calculations, but significantly lower with all-bar calculations. The per-trade/ITM model would have zero Stdev, while the all-bar calc would have higher Stdev and lower per-period returns.

Basic Sharpe uses annual returns, but you can use any timeframe. You simply scale the value so the result is comparable to the standard annual Sharpe: multiply the Return / Stdev calculation times sqrt(barsperyear). So for monthly returns, multiply times sqrt(12); for daily returns, multiply times sqrt(252).