Batch runs multiple times when called from AFL

I prepared a batch procedure with only 3 positions: Load Project -> Explore -> Export to file (html).
I need to run it every 1 minute that is why I prepared simple formula that will be run (Explore - Auto-Repeat) automatically:

_SECTION_BEGIN("Batch_Start");
ShellExecute( "runbatch", "C:\\AmiBroker\\Formulas\\Custom\\Batch_1.abb", "" );
_SECTION_END();

When I press Explore, it runs multiple times and open around 20+ batch windows (Batch procedure works OK when I run it from Batch window). What should I do to force it to open and execute Batch procedure only once?

I added this:

_SECTION_BEGIN("Batch_Start");
z=1;
while (z==2)
{
ShellExecute( "runbatch", "C:\\AmiBroker\\Formulas\\Custom\\Batch_1.abb", "" );
z=z+1;
}
_SECTION_END();

And it works fine (runs only ones) - but I don't know why code in the first post doesn't work properly (runs multiple times) ??

You apparently have "Apply to" setting set to "Filter" or "All Symbols".
So run it on first symbol only.

_SECTION_BEGIN("Batch_Start");
if ( Status( "stocknum" ) == 0 )
    ShellExecute( "runbatch", "C:\\AmiBroker\\Formulas\\Custom\\Batch_1.abb", "" );
_SECTION_END();

BTW you could also apply it to chart to run it every n-minutes.

1 Like