Gaps just reflect differences in valuation after more time than usual has passed between the former bar and the current one. You can also basically get a huge gap intraday between one trade and another if something triggered valuation to instantly change. If you will lose too much on an overnight gap then you are too highly leveraged and are at risk even intraday IMO. Remember price is simply the market's current valuation of the instrument. This will change even without afterhours/premarket trading or whatever.
So, what determines the difference between the closing price and the opening price the next day? Is it related to after hours trading and early trading? Is it based on the volume, price, bid and ask? Or is there an algorithm that determines the opening price based on the orders to buy and sell? The orders lined up in the Servers that will be filled once the bell rings? Would it be safe to safe that the opening prices are determined by computers and not by traders on the floor?
Earning and news catalyst. The highest probability of predicting a gap up is to buy before earning and chart analysis.
When the prices go too high or too low, that is the time when the markets can have a gap. There is no trading activity in this time period. The possible causes for this gap can be:- public announcement of company’s profits some positive news released by the company. Changing views of the trading analyst buying and selling pressures among traders.
Gaps happen when information dissemination is faster than the quoting system. It doesn't only happen when the market is closed. It sometimes happens in liquid instruments during regular market hours as well when there's a big news announcement.