# Different results from walk-forward and regular back-test

In a walk-forward optimization I shown a net % profit of 26.36 for an out-of-sample period of 3/24/2017-3/31/2017. But when I do a regular back-test for that exact same period, I produce a net % profit of 7.44. Can someone help me understand what I’m not understanding in expecting the two numbers to be the same. Thanks very much.

I’m taking one time period from a walkforward test and doing an individual test on that same period and getting different results. I need the deeper analysis of an individual test.

What is the same:

• Same AFL system
• Same input values to parameters
• Same period of time
• Same watchlist (93 symbols)

The only thing that might be different is some setting in the Backtest setting window but I’m not seeing it. One clue is that simple Backtest has 10-20% fewer trades than the Walkforward test.

Any ideas on which settings may be causing the differences?

P.S.
(Different results from walk-forward and regular back-test)[https://forum.amibroker.com/t/different-results-from-walk-forward-and-regular-back-test/1043]

It is always down to user mistake:

http://www.amibroker.com/kb/2014/05/07/why-do-backtest-results-change/

Backtester, optimizer and walk forward use EXACTLY SAME CODE in AmiBroker.
There are no difference. The code path is SINGLE for all three.

Use advice written here: How do I debug my formula? to find out what is happening (typically parameters are different than you think they are)

Is it possible that the following code is being treated differently in a WalkForward test vs. a simple Backtest? With everything else equal (AFL, ticker, timeframe), it seems during the WalkForward test that the stopTypeLoss is not executed and in the Backtest it IS executed. In both cases a value of 3 was used for MaxLossPts.

ExitAtStop = 1; //- check High-Low prices and exit intraday on price equal to stop level on the same bar when stop was triggered
MaxLossPts = Optimize( "max loss pts", 3, 3, 4, .25 );
ApplyStop(stopTypeLoss,
stopModePoint,
MaxLossPts,
ExitAtStop );
ApplyStop( stopTypeProfit, stopModePoint, ProfitTarget ); // exit when price is N points GE the entry price.
ApplyStop( stopTypeNBar, stopModeBars, HoldDays ); // exit after N bars if the profit target has not been hit.

ApplyStop is executed THE SAME way in optimization, backtest or walk forward optimization. It is SINGLE same code that handles everything.

Ok, thanks. I understand what you're saying and I read the links provided and examined my code and still can't figure out what is causing the difference. I will try testing with just 1 symbol and use the Detailed Log feature and see if that helps. In the meanwhile, is there anything in the Backtest Settings that could cause a WalkForward to work differently from a simple Backtest?

As I wrote, place some _TRACE, display variable values (most importantly opt parameters) and use methods described here
http://www.amibroker.com/kb/2014/05/07/why-do-backtest-results-change/
to find out. The reasons for potential differences are listed in the KB article. Remember that Walk forward is multi-step Optimization, not backtest.
Remember that as described in the Users' Guide: http://www.amibroker.com/guide/h_walkforward.html

"each subsequent out-of-sample test uses initial equity equal to previous step ending equity"

Depending on what your code is, your system may produce different output if initial equity (capital) changes. Values of equity used in OOS steps can be found with the Report Explorer.