Explore with different parameters values

I was wondering if I want to explore or scan with parameters say

x=param("MA length",10,1,100);
buy=cross(c,ma(c,x);

Where I need to run the explore with x have values each time starting from 10 to 50, what is the best way to do the same with only one exploration, and x would be updated automatically in afl

I don't want to create multiple batches
I don't want to update parameter every time manually
I want one conslidated explore or scan result.

Do I need to define a matrix and file for parameters and load them from afl, is run sequence helpful ?
I would like to get your suggestions only because I plan to do same for multiple formulas and I want to make it efficient also.

@mmha why are not using the optimization feature of Amibroker?

In such a case, plese, check also this past post from @Tomasz about a feature to automatically include the optimal parameters in your formulas.

1 Like

Hi @beppe Thanks for suggestion, Actually I don't want to optimize it
Ok I have developed pattern identification using zigzag
With different zigzag percent I can get different patterns detected
I need to look into all of them, so actually I need all exploration with different values not an optimized one.

Optimize mode does not return one set of iteration.

As @beppe wrote, use optimize mode, it will output all iteration valid for x, eg. 1 to 100

Also, you didn't mention if you tried Optimize and whether it didn't meet your requirement OR you never tried it in the first place.

@mmha, you can probably achieve this using scripting. The general idea is to automate the process using an external script (e.g., in Python, PowerShell, or a batch file) that performs the following steps in a loop:

  1. Read a file with parameters, or dynamically generate parameter values based on the current loop count (e.g., x from 10 to 50).

  2. Modify/recreate a very simple .afl include file to update the parameter/s (x) accordingly.

  3. Run the exploration in a AB batch, using/invoking a .apx project that references the main formula including the modified .afl file.

  4. Still in the AB batch, save the exploration result to a .csv file.

  5. Rename the .csv file based on the parameter value or loop step (e.g., explore_x_10.csv, explore_x_20.csv, etc.).

After the loop completes, read and consolidate all .csv files into a single dataset for further analysis (e.g., using Excel or what is more appropriate).

2 Likes

Thanks @beppe your suggestion fits perfectly as solution for my problem.

One thing I tried to read was about sequence for now I see the example by Tomasz is about sequence of scan, explore but what about explore multiple times, if I conclude it can't be done, absolutely your suggestion would be the way to go.

1 Like

@nsm51 Thanks for suggestion, but you seem to ignore part of the description my goal, I don't want to optimize the value I want consolidated exploration with different parameters.

You can have 2 or more explorations as part of #pragma sequence too. But actually running optimise is not bad idea as it gives you iteration for free. But you can use batch or sequence as well

1 Like

@Tomasz Thanks a lot will try that

@Tomasz @nsm51
About optimization, I didn't get the point yet
All I know is that I can add custom metrics, but here there is no metrics
this is exploration column that I need to show in every iteration
And actually I need all the detection not one of them

//Psuedo code
zigzag=optmise("zigzag",1,1,20);
isTriangle=TrianglePatternIdentificationLogic(zigzag); 
AddColumn(isTriangle,"TrianglePatternDetected");

Ok found it, how lazy ami I !
Add custom column to optimization results - AFL Programming - AmiBroker Community Forum

@Tomasz Is there a way to add delay between exploration
Or if I want to export the result to csv using afl
I'm now using static variable to increase the zigzag value and also to hold the different explore result in every iteration by concatenation it works for few detection but I believe it will have string overflow if lots of signals.

What happens is it explore with zigzag store the values in static variable
Increase zigzag do explore again and concatenate the value
But I mean if I can export result to csv would be better in every iteration
Or Have some delay in pragma sequence between explore,explore actions

Result so far.

Sure you can export results after exploration automatically if you run batch. But even easier way to achieve desired effect is to write directly to CSV file using either fopen / fputs / fclose or newly introduced fappend function .

1 Like

@Tomasz So happy to accomplish this,
RunSequence, staticvars, and fopen

@Tomasz Is there a limit for #pragma sequence
I noticed it only run 9 sequences.