Controlling Analysis window "Apply-to" filters with AFL

I cannot seem to find a way to control the date filter fields in AB Analysis window through AFL.

Context: I have a piece of code that set static variables once-off on unfiltered data and then runs optimization on filtered data based on settings of "Apply-to" fields in Analysis window.

In theory what could have worked would be to read existing filters through "GetOption" or similar function, write these to a static variable, then clear the filters, run code for unfiltered data and then re-instate the filter in analysis window through "SetOption" or similar.
Any recommendations please?

@Wilz did you ever play a bit with the AmiBroker "Batch" functionality?

I'm not sure to understand what you want to do, but I think you could use a "batch" process to achieve it.
In the batch sequence you may first run a formula to perform your initial screening, and in such formula (or in a later step using your static vars) "rewrite" the "project file" (.apx - an XML file) to be loaded for the successive optimization/analysis,

A search in the forum for "batch XML" will find some posts that use this approach to address different problems.

1 Like

Instead of setting options from AFL (bad - it just blows up the code size), you should set the options in the Settings and SAVE THE PROJECT FILE (.APX) using
File->Save As... menu. Later such project can be open using File->Open.

Project file (.APX) includes everything: formula, range, apply to and settings.