Create .apx file


  1. Is there any way to create multiple .apx programmatically.
    To be clear I need many ( say 100) .apx files (for Batch run) with
    a) Different time range with same afl parameters.
    b) Different afl parameters with Different time range.

Here by afl parameters, I mean different values of any given formula.

  1. Is there any way to modify afl parameters as per result of back test / optimization.


One way to modify the parameters is to put the parameters in an include file. Then #include the file in your main AFL file. You can update the parameters in the include file without changing the apx file.

To programatically change the date / time range, you could save the apx file once, then write a script to repeatedly use a tool like sed to replace text while writing a new apx file.


APX files are written in XML format, so it’s feasible to edit them using a text editor like Notepad++. But be aware that not only is this NOT RECOMMENDED by Amibroker, it is also highly discouraged. It’s also not supported.

1 Like

Just create a apx template whereby the strings that you intend to change with known markers. When you run the script just replace the markers with the desired values using string function and save the apx template to final apx that your script will use.


Thanks everybody for fast & useful responses.
I acknowledge advice from Amibroker and especially from TJ that .apx file should not modify from Outside of Amibroker. This is only for experiment purpose.

I successfully created many .apx files by VbScript. Thanks Again.

Now I have another question related to VbScript

During course of experiment with VbScript, I stuck at converting readymade .js scripts to VbScript.
Original .js file given by TJ works perfectly well.

My code is

Set  AB = CreateObject("Broker.Application" )
Set objApx = AB.AnalysisDocs.Open( "D:\Test\Analysis1.apx")

If objApx Then
 	objApx.Run( 2 ) 
End If
while ( objApx.IsBusy )
    WScript.Sleep( 500 ) 

objApx.Export( "D:\test1.csv" )  

WScript.Echo ( "Completed"  )


Here in this code If I omit "If … End If " condition then it works ok. What is wrong in this code and also How can I trap Error such as try…Catch mechanism.

My bad. You are using Basic script. I thought you are running JavaScript.

Using my knowledge from MS Excel VBA, objApx is not a Boolean variable and the If… End If statement expect a Boolean variable. Please try this if this will work. Before the Set objApx=… statement, add this statement : objApx = “”. In the If… End If statement, If objApx <> “” then… Going the Example 1 in the link, End If statement should be at the last line.