AmiBroker's OLE Automation Object Model

Important note about OLE automation:

OLE automation interface is provided to control AmiBroker from the
OUTSIDE process (such as windows scripting host). While it is possible
to access Broker.Application and underlying objects from AFL
formulas
you should be very careful
NOT to
touch any user interface objects (Documents, Document, Windows, Window , Analysis
object) from AFL formula because doing so, you will be likely "Sawing Off the
Branch You're Sitting On". Especially things like switching chart tabs from
currently running chart formula are totally forbidden. Changing user interface
objects via OLE from AFL that is currently running within those user interface
parts is recipe for disaster. You have been warned.

AmiBroker object model hierarchy. V5.50

Index of objects

(1) - Analysis object is obsolete as of 5.50. It is left here for backward compatibility
and accesses Old Automatic Analysis window only(2) - AnalysisDoc object and AnalysisDocs collection are new objects introduced
in v5.50 and allow to control New Analysis window

AnalysisDoc is a new object introduced in version 5.50. It allows to access
New Analysis project documents (apx extension) and perform multithreaded
scans/explorations/backtests/optimizations
in New Analysis window in asynchronous way. Asynchronous means that Run()
method only starts the process and returns immediatelly. To wait for completion
you must check IsBusy flag periodically (such as every second) in your own
code.

Properties:

Property IsBusy As Boolean [r]

Methods:

Sub Close()

Function Export(ByVal pszFileName As
String, [ByVal WhatToExport As Variant] ) As Long

Function Run(ByVal Action As
Long) As Long

Sub Abort() (new in 6.20)

Description:

AnalysisDoc object provides programmatic control of New Analysis document/window.

IsBusy property allows to check whenever Analysis window
is busy doing analysis. You must check this flag periodically if you want
to wait for completion. Take care NOT to call this too often as it will decrease
performance. For best results check it every one second. Also you need to
check this flag if you are not sure whenever Analysis window is busy before
trying
to
call
Export()
or Run(),
otherwise
these calls
would
fail if analysis is in progress.

Close( ) method closes Analysis document/window. If there
is any operation in progress it will be terminated. To prevent premature
termination, check IsBusy property.

Export( pszFileName, whatToExport) method allows to export
analysis result list to either .HTML or .CSV file. Returns 1 on success (successfull
export)
or 0 on failure (for example if analysis window is busy). WhatToExport decides
what data should be exported: whatToExport
= 0 - exports result list (the default behavior when this parameter is not
provided),
whatToExport = 1 - exports walkforward tab.

It is important to understand that Run method just starts the process and
returns immediatelly. It does NOT wait for completion.
To wait for completion you need to query IsBusy flag periodically (such as
every one second).

The procedure to run automated backtest involves opening previously saved
Analysis project (it includes all settings that are necessary to perform
any action), call Run() and wait for completion.

Since currently you can have multiple analysis projects running, there is
an AnalysisDocs collection that represents all open Analysis documents and
allow you to open previously saved files (that contain formula, settings
and everything needed to run).

New AnalysisDoc object does not allow you to read/write settings for the
purpose - you are not supposed to manipulate UI while new Analysis window
is running. Correct way of using New Analysis window is to open existing
project file and run. If you want to modify the settings, you should write/modify
existing project file. The analysis project file (.apx extension)
is human-readable self-explanatory XML-format file that can be written/edited/modified
from
any language / any
text editor.

Properties:

Description:

Methods:

Function Add(ByVal Date As
Date) As Object

Function Remove(ByVal Item As
Variant) As Boolean

Function Retrieve(ByVal Count As
Long, ByRef Date As Variant, ByRef Open As
Variant, ByRef High As Variant, ByRef Low As
Variant, ByRef Close As Variant, ByRef Volume As
Variant, ByRef OpenInt As Variant) As Long

Properties:

Item(ByVal Item As
Variant) As Object [r/o][default]

Count As Long

Description:

Quotations is a collection of Quotation objects. It represents all quotations
available for given symbol. Quotations collection is available as a property
of Stock object.