Hello,

Let me try to explain you the whole process from starting

...Optimization refers to the combinatorial search over a range of system input values on price data defined over a fixed number of bars for the cases that produce the best system net profits or some other selected performance variable.

It is unavoidable because markets lack stationary in any form at all and so adaptability is essential for a trading system. By default it is equivalent to curve fitting because you are searching for ‘best fitting’ input parameters. In practice, you can use optimization results to model a more ‘adaptive’ system.

Running an optimization can be the easiest way to look for parameters which the market favors in different phases or time intervals. A simple method is to map the changes in optimum input range with a market characteristic such as volatility or trendiness. This in turns helps to build a layer of adaptability or regime analysis which is essential for any trading system.

Here are some important tips you should implement to avoid curve-fitting strategies:

Avoid unreliable simulations. Perhaps the most important thing you need to do in order to avoid curve-fitting a strategy is to completely avoid the use and optimization of systems which cannot be simulated accurately. Simulating systems that trade on time frames lower than 30 minutes or systems with very small take profit and stop loss targets (below 10 times the spread) should be absolutely avoided as the results will not be viable and a lot of curve fitting to past data will most likely take place under optimization. Not only will the results be meaningless but exploitation of backtesting interpolation errors and broker dependency will play a primordial role.

Long testing periods. Optimizations should be carried out for long periods of time, ideally 9-11 years of data should be used for the process in order to ensure that a large amount of market conditions become available. If a simple strategy yields profitable results across a ten year period then the probability of curve fitting is greatly reduced as the system has limited degrees of freedom to artificially “fit” all those different market conditions.

Keep your system symmetric. One of the first ideas new traders have when they start analyzing system development and mathematical expectancy results is to have a separate criteria for entering and exiting short and long trades (for example using an indicator cross at 20 for long entries but 15 for shorts). Although it is true that under past data up and down trends might have developed differently in currencies this cannot be guaranteed to continue in the future as these differences rely on interest rate differentials or such similar macro economic variables that inevitably change through economic cycles. Adding separate criteria for longs and shorts automatically increases the strategy’s degrees of freedom and makes it excessively prone to curve-fitted solutions.