How to export chart image to a file. Was: How to run AFL formula by command line?

I wrote an AFL formula. However, I can not find the way to run this formula by command line instead of Amibroker GUI. Does anyone pass this issue? Could you please support me that?

Nhan Ngo

AFL is meant to be run from within AmiBroker. After all it is AmiBroker Formula Language.

1 Like

I wrote a formula using AFL language. Now, I would like to run the formula by command line instead of GUI. I tried to explore the way to implement it. However, it is not so clear for the way to reach my objective. Did anyone try this before? Could you please help me in this issue? Thanks.

Moderator comment: Duplicate post from the other thread moved to correct thread

This is duplicate to what you posted before How to run AFL formula by command line? Writing another post does not help or change the reality. Tomasz himself replied to your query.

CMD can run or execute on the basis of its CUI syntax. In other conventional programming languages we have access to the compiler directly, so, we can write a command line and then can call the package (ideally .exe) to execute a written program.

Codes that you write in AFL are not .exe. So a conversion is required. Just sharing to channelize your thoughts. You have to make choices:

  1. If you want to re-invent every minute detail of a chart from scratch - read Dr.Jack Xu books especially Practical C# Charts and Graphics.
  2. Or take a shortcut and convert AFL to C# using .NET for AmiBroker then using the native C# compiler you could compile the converted code from CMD or .NET itself.
1 Like

Sometimes people would get much better replies if they provided the answer to question WHY (for what purpose) they want to do something. Running AFL outside of AmiBroker makes no sense (because AFL needs AmIBroker charts, analysis and so on), but I guess original poster wanted to do something like automation, that can be of course done in other ways, but it is not clear, since he did not say.

1 Like

Thanks you (Lennon and Tomasz) for your reply in my question. The duplicate mistake is coming because I can not find my post after the submission, then I tried to post again.

I would like to explain clearly my intend as follows.
I am going to build a finance consultant service for stock investors. For implementation, I pretend to install Amibroker in web server, run my AFL formula plugin in Amibroker, and export the chart with my BUY and SELL sign. This image file will be send to customer through a mobile app in their mobile phone to making decision.

That is reason I asked you for the command line, so I can run my developed AFL formula.

I also read the .NET for Ami guide to converse the AFL code to .NET (C#). I would like to ask you whether I export the chart by .NET for Ami library function, or I need to run the plugin dll in Amibroker for exporting the chart?

Nhan Ngo

@carfirst125 For the reasons mentioned by Tomasz, you should rather entitle your thread : How to export chart image to a file, (not How to run AFL formula by command line) and why do you think you need a command line execution. If you did so, the answer (and the solution) would be very simple. Read this article form AB Knowledge Base (which is by the way easy to find using Google search):

How to export chart image to a file:

You didn't even mention, in your first two posts, that you want to export chart images, so how did you expect precise answers?


Thanks you for your support, MiLosz!

Actually my question is not only on "how to export chart image to a file?"

My case is that I already use AFL to build an formula, could be known as an indicator. A stock filter code is included in the AFL formular. Everytime when I ran the formula, I need to use Amibroker GUI by Analysis and Explore pressing to run the analysis and get the result by GUI. However, now I would like to do it by external script. I tried to find the command line to support me implement it from external script instead of Amibroker GUI.

I found that I need to do it through APX file call. The APX file is created using Amibroker::OLE::APXCreator, etc. Actually I can not find the A-Z guide for this issue. Could you please support me that I am in the right way?

Nhan Ngo

You can do it via OLE - AmiBroker's Automation Object Model. You can find many examples of using OLE on the forum.

You don't need any external creators to make APX file! It's very simple - just configure all parameters in Analysis Window according to your requirements and click "File/Save As... ProjectName.apx".

You might also find this example interesting:


Another, simpler option would be using Batch window + Scheduler (introduced in version 6.17) which allow automation of repetitive tasks - such as running scans, explorations, backtests (apx files) etc. without the need of using OLE


hi guys,

how do I activate floating windows?

i was looking at an old jscript i have, see below. It identifies all the windows. But I have 4 windows inside the Amibroker frame (normal) and 4 outside the frame (floating). It identifies 8 windows and it also identifies the correct symbols in the 8 windows but it will only export the "normal" charts and not the "floating". How to activate the floating windows for the chart to be exported?


AB = new ActiveXObject("Broker.Application");
ADS = AB.Documents;
//path = "C:\\Users\\win 10\\Google Drive\\";
path = "D:\\ExportedImages\\";

extension = ".png";

//WScript.Echo("qty:" + qty );

dt = new Date();
month = dt.getMonth()+1; 
day = dt.getDate();
year = dt.getFullYear();
hour = dt.getHours(); 
minute = dt.getMinutes();
second = dt.getSeconds();

startHour = Math.max(hour - 7,1);
endHour = Math.min(hour + 1,23);

monthStr = month.toString();
dayStr = day.toString();
yearStr = year.toString();
hourStr = hour.toString(); 
minuteStr = minute.toString();
secondStr = second.toString();

startHourStr = startHour.toString();
endHourStr = endHour.toString();

entryDateTime = yearStr + "-" + monthStr + "-" + dayStr + " " + startHourStr + ":" + minuteStr + ":" + secondStr;
exitDateTime = yearStr + "-" + monthStr + "-" + dayStr + " " + endHourStr + ":" + minuteStr + ":" + secondStr;
//WScript.Echo("exitDateTime:" + exitDateTime );

for ( n = 0; n < qty ; n++ )
	//WScript.Echo("fn:" + fn );
	AW.SelectedTab = 11;
	AW.ZoomToRange( entryDateTime, exitDateTime );
	AW.ExportImage( path + fn + extension, 550, 400);
	// set back to tab 1
	AW.SelectedTab = 1;
1 Like


Please take a look at quotes by AmiBroker

thanks for your quick reply, fx.