can I buy a stock when the market is closed?

When markets are closed, you can place a market order, which is an order that allows you to open a position at the moment the market opens at the first available rate.