My EA passes the strategy tester but fails forward testing.

 

The strategy that I am currently developing performs very well in the strategy tester, but when I do forward testing it fails.

How can I shorteh the gap between strategy tester data and forward testing?

 
Isaac Uriel Arenas Caldera:

The strategy that I am currently developing performs very well in the strategy tester, but when I do forward testing it fails.

How can I shorteh the gap between strategy tester data and forward testing?

It's true, the results of the backtest and forward test will most likely be different. As the common saying goes: "Past performance does not guarantee future results."

Some of the main causes of these gaps are:

1. Overfitting: Input that is overly forced to look “pretty” only on certain historical data.
2. Real Market Conditions: Backtests often use fixed spreads, whereas in live markets, spreads can widen drastically (during news or low liquidity) and there is slippage that is not present in the simulation.
3. Look-ahead Bias: A coding error that makes it appear as if the EA "knows" future prices (peeking at subsequent data) before execution.

My suggestions to narrow the gap:

1. Use a Long Time Range: Perform a backtest of at least 2-3 years (for example from January 1, 2024 to the present) to see the resilience of the strategy in various market conditions.
2. Every Tick Based on Real Ticks: This is mandatory, so that the price simulation is close to actual market movements.
3. Test on a Cent Account: If it passes the rigorous testing, start on a small real account (Cent) to see the real execution of the broker.

Additional Message:
When you start live, don't rush to judge your EA as being wrong when a loss occurs, as long as the loss is still within the drawdown limit of the backtest results. Likewise, when you make a profit, don't immediately feel that the EA is perfect. Keep monitoring long-term performance.
 
Bambang Christianto #:
1. Use a Long Time Range: Perform a backtest of at least 2-3 years (for example from January 1, 2024 to the present) to see the resilience of the strategy in various market conditions.

The appropriate length of a backtest depends on the trading frequency of the EA being tested. In other words, I use a minimum of 10 years for a swing trading strategy that trades 2 or 3 times per week. For a scalping strategy that trades over 100 times per month. I regard the test sample size as the total number of trades─not necessarily the total number of months, years, etc.

Bambang Christianto #:
2. Every Tick Based on Real Ticks: This is mandatory, so that the price simulation is close to actual market movements.

Testing on real ticks is mandatory for EA's that trade on every tick. In contrast, EA's that trade only on OHLC data can more efficiently be tested for longer periods of time on OHLC prices only. The issues of live spread and slippage can be mitigated by knowing/researching your broker-dealer's average spread and average slippage, and entering that information into the Tester. There are free utilities published in the CodeBase for collecting such data.