piotrd
August 20, 2020, 1:39pm
1
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?
piotrd
August 20, 2020, 1:53pm
2
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) ??
piotrd:
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
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.
See Batch manual where it is mentioned that you can also use ShellExecute to run batch file.
So you could apply below code to chart pane to run batch every n-minutes of hour.
batch_file = "path_to_batch_file.abb";// batch file location
//RequestTimedRefresh(1);// if local DB
x = (Now(4)/100)%100;
_TRACEF("Now (minutes):%g", x);
run_every = 15;// run every n-minutes of hour
if ( x % run_every == 0 ) {
_TRACE("Batch run");
ShellExecute("runbatch", batch_file, "" );
}
Or instead of n-minu…
1 Like