How to overcome overfitting

 
There are 5 parameters in the trading model. After optimizing the parameters with MQL5 cloud network, the performance is very good in the sample, but the performance outside the sample is very general. Is there a way to overcome the over-fitting?
 
You need to optimize using "forward start" testing. My EA has approx 30 parameters and using weeks of automated testing one set of parameters is profitable when the EA is started one day shifted forward for 30 days in total and runs for 3 years in the backtest. The profits are fluctuating quite a lot but not a single loss in these 30 tests, which each started one day later than the previous one.
 
@Mrerwin my suggestion is to start by identifying if the problem is really overfitting and not the quality of the strategy itself, or other technical factors, such as latency and other differences of operation between backtesting and the real market.
Reason: