Walk-forward OOS no trades

Hi, I have a problem with walk-forward. When there are no trades in the IS period for a value of the parameter that I am optimizing, the OS period also shows no trades even though there are positive values in the IS period.

Attached to the first picture of the IS optimization:

I attach an image of the WF where you can see the OOS at zero:

What am I doing wrong?
Thanks!

Which optimization target did you select at the Walkfoward tab (in Analysis settings) ?

Recovery factor

Create your own metric and make sure it is not null

Thank, I´ve tried with this code but i have the same error:

SetCustomBacktestProc("");

/* Now custom-backtest procedure follows */

if( Status("action") == actionPortfolio )
{
    bo = GetBacktesterObject();

    bo.Backtest(); // run default backtest procedure

    st = bo.GetPerformanceStats(0); // get stats for all trades 
    
     expectancy = st.GetValue("WinnersAvgProfit")*st.GetValue("WinnersPercent")/100 +
                st.GetValue("LosersAvgLoss")*st.GetValue("LosersPercent")/100;

    // Here we add custom metric to backtest report
    bo.AddCustomMetric( "Expectancy ($)", expectancy );
    }

I think the error is thrown because in the periods that for the parameter that I am optimizing there are no trades, the choice of the target does not do well.

Does anyone have any other ideas?
:pray:

Check if you have data for those periods AND if system produces any signals for those periods. Zero trades usually means your system did not generate any entry signals in given date range. Run regular backtest in that single OOS range to see.

Thanks @Tomasz,

If you see my post #1 in the first image, you can see that in IS the system generates two periods without operations and others with operations, but later in the OOS it chooses a parameter that has not generated operations, but there are other parameters that have generated operations and which are profitable.

The same thing always happens when there is some parameter value that does not generate operations, but there are other parameter values that do.

I think that the problem is when ordering the rank of the target chosen in WF, but i don't know how to fix it.

Do as I told you. Change the DEFAULT values in the code to those coming form IIS step (AmiBroker Knowledge Base » Using optimum parameter values in backtesting) then run the backtest over problematic period. Read this: How do I debug my formula? There is "divide and conquer" approach that you should be using.

If I change the default values that come from the ISS and run the backtest of course they work, but I want amibroker to automatically choose the best value when running the walk-forward. This does not happen when some parameter value shows no operations.

I'll look at this in detail How to i debug my formula, to see if I can see what I'm doing wrong.

Thanks.

"It works" and "it does not work" is meaningless. Precision is the key.
Instead of "it works" you should write (example):
"If I change parameter values to x=12 and y=56 and date range to 2022-01-01 ... 2022-03-01 then backtest produces three trades, here is a screenshot"

That is THE MEANINGFUL information expected on this forum when asking questions. Please follow this advice: How to ask a good question

Your case is OPERATOR error, you need to go into detail to understand yourself what is going on with your own code. Having yourself check the details quickly reveals the problem. Insisting on somebody else to help without having any information won't work.

Excuse me, but my English level is not very good, although I know that is not an excuse for you.

I thought I was accurate enough in my first post. Post I wrote after quite some time of research and head-butting against my screen.

I guess you are tired of answering to carefree people, that is not my case. Still I thank you again, even if you get angry your answers are very helpful.

Smile once in a while, it's very healthy :kissing_heart:

It is not about me being tired. You simply can't do a test run of somebody's formula, if you DO NOT HAVE that formula and you don't know the data set used. This is that obvious. What I am tired of is explaining it over and over again, that no-body is able to help without formula. It is like you come to your doctor and refused to give him information, but expecting help.

3 Likes