Writing Explorations Results to a File Automatically

Hi,

I'm wondering if there is a way to write the results of an Exploration to a File using AFL. This is much the same as Export from Exploration but it would happen automatically.

Here is a screenshot of an Export from my Exploration. It uses Status("LastBarInRange"); .

Here is my code which so far only captures the last symbol and its values:

Tickers = CategoryGetSymbols(categoryWatchlist, 0);
fputsString = Date() + "," + Symbol + "," + Advance + "," + Chop + "," + Decline + "," + Undefined + "\n";
fhname = "Formulas\\Include\\BCWeekly.csv";
fh = fopen(fhname, "w");
if(fh){
	fputs("Date, Symbol, Advance, Chop, Decline, Undefined \n", fh);
	fputs(fputsString, fh);
}
else{
	printf("Error opening file");
}
fclose(fh);

I know I should have a
For statement in there somewhere but I need a little help please.

One way to write the exploration to a file is with OLE Automation – a technology that allows you to run various AmiBroker functions from an external script of your own creation. It is documented here: https://www.amibroker.com/guide/objects.html#AnalysisDoc

Another way to write the exploration to a file is with the batch capability in AmiBroker, documented here: https://www.amibroker.com/guide/h_batch.html

2 Likes

Thanks Steve. Both OLE and Batch are outside my comfort zone at the moment but at least I’ve got an idea of which way to head.

Batch is very easy Anthony. There is no coding involved, it’s all point and click.

For comparison, this is a link to the export code with the loop you were after. The batch Export function basically replaces that entire routine in one go. And you can even schedule the batch to run periodically.

You will need 6.20 or higher to get the batch functionality.

PS I like your avatar :airplane:

4 Likes

Thanks Alan. The avatar is an Attitude Indicator to remind me to bring the right attitude to the forum ( and life in general really) :slight_smile:

2 Likes

So you reach the right altitude :sunglasses:

Brilliant. Keep it up.