AFL Optimizer help

I am a newbie... can someone help?
why does this not work?
Sell=Optimize(BBandTop(Close,15,2) - BBandBot(Close,15,2) > 5),5,1,9,1;

Hi @rwsch,

Here's an extract from the AmiBroker 6.30 User's Guide, available via "Help,Help contents" from the AB main menu:

SYNTAX Optimize( " description ", default, min , max, step )
RETURNS NUMBER
FUNCTION Defines optimization process parameters. With normal backtesting, scanning, exploration and comentary modes the optimize function returns default value, so the above function call returns default ; In optimization mode optimize function returns successive values from min to max (inclusively) with step stepping. " description" is a string that is used to identify the optimization variable and is displayed as a column name in the optimization result list. default is a default value that optimize function returns in exploration, indicator, commentary, scan and normal back test modes min is a minimum value of the variable being optimized max is a maximum value of the variable being optimized step is an interval used for increasing the value from min to max
EXAMPLE variable = optimize("my optimization var", 9, 2, 20, 1 );

The syntax you've supplied above doesn't look anything like the example from the guide.

And, it's not clear why you would use the result from Optimise(), which returns a single number (not an array), to dictate when to exit a trade (the "Sell" variable is an array, and is used by AB to indicate when to exit a Long trade).

The users' guide also has a definition of the "sell" variable, which you can find by entering "keywords sell" in the "Search" tab of the guide.

Perhaps you're looking for something like " Back testing your trading ideas", which you can find in the guide from the "Contents" tab, or via the "Search" tab.

Also, if you could follow the code formatting guidelines in the links below, it would help other people to understand your code more easily: