You are on page 1of 6

Contents

Preface and Introduction . ..................................................................xiii


Section I Getting Started .................................................................. 1
Chapter 1 Overview of AmiBroker ................................................ 3
Chapter 2 Installation ......................................................................11
AmiBroker in Trial Mode .................................................................13
Default Database ...............................................................................13
Block Diagram of Database . ............................................................14
Database Setup - End-of-Day . .........................................................14
Free Database Using AmiQuote . ................................................15
Subscription Data Providers ........................................................31
Database Setup - Intra-Day and Real-Time Data ......................... 41
Free Intra-Day Historical Data ................................................... 41
Delayed Real-Time Data .............................................................. 43
Real-Time Data . ............................................................................ 44
Tick Data . ...................................................................................... 53
Chapter 3 30 Minutes to Useful Results . ..................................... 55
Example 1 Chart a Stock ............................................................... 57
Example 2 Apply a Trendline . ......................................................61
Example 3 Plot a Moving Average . ............................................. 65

Example 4 Make a Watchlist ........................................................ 69


Example 5 Run an Exploration . ................................................... 72
Example 6 Run a Single Stock Backtest . ..................................... 78
Example 7 Run a Portfolio Backtest . ........................................... 87
Example 8 Optimize a Trading System ...................................... 91
Example 9 Perform Walk Forward Validation ........................... 98
Example 10 Scan for Buy and Sell Signals .................................103
Section II Charting . .......................................................................105
Chapter 4 AmiBroker Chart Structure . ......................................107
Windows Layouts . ..........................................................................108
Block Diagram .................................................................................111
Chapter 5 The GUI - Graphical User Interface . .........................113
Charts ...............................................................................................116
Display a New Price Series .......................................................116
Default Chart ...............................................................................117
Active Pane . .................................................................................117
Price and Value Axis ...................................................................117
Date and Time Axis ....................................................................118
Scroll Through Dates ..................................................................118
Pane Size . .....................................................................................118
Zoom .............................................................................................119
Bar Interval (Periodicity) ............................................................119
Select a Quote ..............................................................................120
Mark a Range ...............................................................................120
Remove the Range Markers .......................................................120
Add a New Pane . ........................................................................121
Close Any Pane . ..........................................................................121
Reorder the Panes . ......................................................................121
Chart Pane Context Menu . ........................................................... 122
Parameters . ................................................................................. 122
Edit Formula ................................................................................127
Properties .....................................................................................129
Pull-down Menus . ..........................................................................130

File Menu ......................................................................................131


Edit Menu .................................................................................... 134
View Menu ...................................................................................135
Insert Menu ..................................................................................139
Format Menu . ..............................................................................141
Symbol Menu ...............................................................................142
Analysis Menu .............................................................................146
Tools Menu ...................................................................................147
Window Menu .............................................................................149
Help Menu . ..................................................................................150
Toolbars ............................................................................................151
Tools for General Use . ................................................................151
Tools for Drawing . ......................................................................154
Study Tools ...................................................................................157
Add Icons to Toolbar . .................................................................159
Tabbed Menus...................................................................................160
Re-dockable Menus .....................................................................160
Auto-hiding Sliding Menus .......................................................160
Layouts, Layouts Tabbed Menu, Layouts Context Menu . .....162
Layers, Layers Tabbed Menu, Layers Context Menu . ............163
Symbols, Symbols Tabbed Menu, Symbols Context Menu ...165
Charts (Formulas) Tabbed Menu, Charts Context Menu ......168
Notepad, Notepad Tabbed Menu, Notepad Context Menu . .170
Interpretation, Interpretation Tabbed Menu ...........................171
Alert Output, Alert Output Context Menu . ............................172
Real-Time Quote Window, Context Menu ...............................173
Time and Sales Window . ...........................................................175
Categories .........................................................................................177
Group - Market - Sector - Industry ...........................................177
Category Membership ................................................................177
Category Assignment .................................................................178
Watchlists..........................................................................................179
Adding Watchlists . .....................................................................180
Removing Watchlists ..................................................................180
Adding Symbols to Watchlists ..................................................181

Sorting Symbols in a Watchlist .................................................182


Removing Symbols from Watchlists ........................................183
Erasing Watchlists .......................................................................183
Hiding and Unhiding Empty Watchlists . ...............................184
Using Watchlists in Automatic Analysis Window .................184
Importing a Watchlist from a File .............................................186
Exporting a Watchlist to a File ..................................................187
Renaming Watchlists ..................................................................187
Charts (Formulas) ...........................................................................190
Basic Operations ..........................................................................190
Averages .......................................................................................195
Bands . ...........................................................................................198
Basic Charts . ............................................................................... 200
Custom . ....................................................................................... 203
Equity . ......................................................................................... 203
Include ......................................................................................... 204
Indicators ..................................................................................... 205
Systems ........................................................................................ 224
Section III Analysis........................................................................ 227
Chapter 6 - Technical Analysis . ....................................................... 229
Chapter 7 - Trading System Development . .................................... 233
Define the Objective Function ...................................................... 234
Decide What to Trade and How to Trade It ................................ 235
Design the Trading System ........................................................... 235
Determine the Length of the In-Sample Period ......................... 236
Determine the Length of the Out-Of-Sample Period ................ 236
Decide What to Optimize ............................................................. 237
Perform Walk Forward Runs . ...................................................... 237
Evaluate the Out-Of-Sample Results ........................................... 238
Trade the System ............................................................................ 239
Monitor the Results . ...................................................................... 239
In Summary .................................................................................... 239

Chapter 8 - AFL - AmiBroker Formula Language . ....................... 242


AFL Editor . ..................................................................................... 243
Pull-Down Menus ...................................................................... 243
AFL Editor Toolbar . ................................................................... 246
AFL Editor Context Menu . ....................................................... 248
AFL Language .................................................................................249
Arrays ...........................................................................................249
BarCount . .................................................................................... 250
Array Operations ....................................................................... 250
Language Basics ..........................................................................252
Operators ..................................................................................... 253
Operator Precedence . ................................................................ 254
Array Subscript Operator . ........................................................ 256
Compound Statements (Blocks) ............................................... 256
Conditional If IIF) . ..................................................................... 256
Variables ...................................................................................... 257
Reserved Variables ..................................................................... 257
User Defined Functions, Procedures, Scope . ............................. 258
Local, Global ............................................................................... 259
Flow Control ................................................................................261
Flags ..............................................................................................269
AFL Function Reference . .............................................................. 271
Lowest / Highest . ....................................................................... 271
Math Functions . ......................................................................... 275
Moving Averages, Summation ................................................. 285
Statistical Functions ................................................................... 289
Basic Price Pattern Detection .....................................................294
Composites .................................................................................. 300
Indicators ..................................................................................... 304
Exploration / Indicators ..............................................................319
Date / Time .................................................................................. 342
Time Frame Functions ................................................................352
Information / Categories ............................................................361
Referencing Other Symbol Data . ..............................................372

File Input / Output Functions ....................................................378


String Manipulation .................................................................. 386
Trading System Toolbox .............................................................394
Low-level Graphics . ................................................................... 421
Miscellaneous Functions . ......................................................... 443
Chapter 9 - Analysis .......................................................................... 477
Quick Review . .................................................................................478
Automatic Analysis . .......................................................................481
Main Window ..............................................................................481
Settings Button............................................................................. 484
Explore Button ............................................................................ 493
Backtest Button ........................................................................... 496
Context Menu ............................................................................. 502
File Button . .................................................................................. 508
Equity Button .............................................................................. 508
Report Button .............................................................................. 509
Optimize Button ..........................................................................511
Walk Forward ..............................................................................518
Commentary ....................................................................................524
Chapter 10 - Write It Yourself ............................................................529
Appendix A Glossary.................................................................... 545
Appendix B Industries and Sectors..............................................557
Appendix C Resources...................................................................561
Appendix D Block Diagram .........................................................567
Index .................................................................................................. 569
Order Information . .............................................................................591