Execute only when 'Explore' is clicked

I have a script that I use to import extrenal ASCII that I have created.

#include <pause.afl>
AB = CreateObject("Broker.Application");
fh=fopen("C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\looplim.py","w");
{fputs("count = int("+NumToStr(Param("Number of candles",25,1,1000),1.0)+")",fh);
ShellExecute("C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\KlineCallLoopAll.BAT","","",0);
pause(Param("Seconds to pause for import",14,12,40,1));
AB.Import( 0, "C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\csvFiles\\quotes.BinHist", "BinHist.format");

(pause.afl is a small script I wrote to pause the script and the .BAT file is a looper file that calls 20+ loops which in turn call data from Binance. It's not important for what I am trying to ask here)

In any case, I have 2 parameters which, in case a, import has failed for some reason, I'd like to be able to change the number of candles to get data from further back. A variation on 'backfill' if you will.

Any time I click the parameters button in the project viewer (.apx), the entire code is executed, triggering the loop.

I couldn't find it in the manual. Is there some kind of condition that I could place the above code in, so that it only executes if I click explore, for example, something like

<paste code here>


You're close. Look at the Status() function using the Status Code "action" or "actionEx".


You're a legend!! Thanks!

1 Like

I've used the function as below. My understanding is that this should trigger now when I click the Explore button, but it does not,

#include <pause.afl>
numCan = Param( "Number of candles", 25, 1, 1000 );
secPause = Param( "Seconds to pause for import", 14, 12, 40, 1 ); 
Filter = 1;
AB = CreateObject( "Broker.Application" );
fh = fopen( "C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\looplim.py", "w" );
if( fh )
    fputs( "count = int(" + NumToStr(numCan , 1.0 ) + ")", fh );
    fclose( fh );
ShellExecute( "C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\KlineCallLoopAll.BAT", "", "", 1 );
AB.Import( 0, "C:\\Program Files\\AmiBroker\\Brokers\\Binance\\Data\\symbolcsv\\klines\\csvFiles\\quotes.BinHist", "BinHist.format" );

Have I misunderstood something?


Not sure but might be:

if( Status( "action" ) == actionExplore )
1 Like

@SpandexMan, @mradtke gave you the solution. Did you not see?

Perfect, this works, thanks! Thanks @mradtke for the answer and thanks @WoodenShoes for clarifying my understanding of how to apply it.

Hey @TrendSurfer how's it going? Yeah, I did see, but I applied it without correctly understanding the documentation. Thanks. :+1:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.