Simple to avoid a weekend gap do not have any trades or open orders after market close on friday for forex or market close for the day on stocks, indexes and pretty much all other markets. Gaps happen very very often and there is nothing you can do about it. Trick is not get caught on the wrong side of the gap meaning a market a gap can skip over you stop loss, entry orders and take profits. IF it gaps over your take profit thats generally to your benefit because if it skips over your take profit then price is moving past it and still going in your dorection so you get more profits. If it skips over your stop loss well then you are going to have a very very bad day. If it skips your entry order well the order was never filled so you just missed the trade and you cant lose what was never risked.
Best way to avoid being screwed by gaps in the market is not to leave yourself exposed in the first place to the potential of a gap. However depending on your trading style if you more of a investor then gap are just something you will have to deal with and there is ways to deal with them. When approaching the close of a market use some common sense. First before entering a trade take the amount of time you are expecting to be in the trade and when the market will close. Then consider how close your stop is to current price. The further the stop is away for current price the less likely price will gap over your stop. Then if market close is approaching take a second look at your trade. Has price been moving against you and now just a few pip/points from your stop loss? If so you might want to consider just taking the loss and avoid a potential gap over the stop leaving you in much worse shape than if you just liquidized the trade before the close.
Other things to take into consideration when dealing with potential gaps is scheduled news events. For example lets say you are in the united states and are considering a a trade in some oil contracts. Well are there some news release from OPEC that is scheduled for a time that the CME is closed. This could leave a pretty significant gap and you cant do nothing about it. So take it into consideration before hand. Also look at the asset you are looking to trade as gaps are very common and something you be expected however by looking at the asset one can typically gauge the average gap. Sure thats never going to be exact but it can give you a rough idea of how much of a potential gap you can expect.
Lastly gaps can happen at anytime for any reason typically if it is a significantly larger gap than normal it is almost always due to a news release so again as stated above look into news. It can never hurt to actually know the asset you are going to trade. I know most on here are solely technical traders and say news events mean nothing to them. I call BS right there because almost all of them will not trade around NFP. hmmmmm news means nothing but they dont trade around a major news events enough said. Then you can and will always have the unforeseen events like terrorist attacks and the like. They can happen at anytime and honestly there is nothing you can do at that point. None of us can see the future and we can do the best we can to prepare and avoid as much as we can but once you enter the trade you are at the mercy of the market and it takes no prisoners and leaves no survivors if it gets its way. However by not being overly exposed and over leveraged even when you do find yourself hung out to dry due to a gap you can get out and live to fight again another day.