Can you iterate through a fixed list of hold periods?

Wondering the options for iterating through an AFL a number of times changing only the hold period (5 in this example).

Buy = YourBuyCriteria;
Sell = 0;
ApplyStop(stopTypeNBar, stopModeBars, 5);

I guess you could save a separate AFL which is the same base code excepting the unique hold periods, and then run them all in a batch.

But I have a lot of screens I’d like to do this with. If possible, it would be better if I could somehow call my screen and then match it up with another AFL or script that iterates through all the various hold periods (without having to save a separate ALF for each hold period I want to test).
Could this be done? I know Amibroker can do anything. I should say, is there a fairly simple way to do this?

Example

SetOption( "GenerateReport", true );

holdperiod = Optimize( "Hold period", default = 5, min = 5, max = 30, step = 1);

Buy = YourBuyCriteria;
Sell = 0;
ApplyStop(stopTypeNBar, stopModeBars, holdperiod );

PS: don’t forget code tags next time.

2 Likes

Ah great. Thanks so much for the help, fxshrat. Noted on code tags.