AmiBroker 5.20 User's Guide Copyright (C)1995−2008 AmiBroker.com. All rights reserved. Table of Contents Copyright 1 Introduction 2 About AmiBroker Editions .2 Quick Tour 3 Getting started 7 Hardware requirements 7 Supported operating systems 7 Installation and running 7 Getting help 8 Tutorial .10 Basic operations .11 Adding a new symbol .11 Removing a symbol 11 Splitting a stock 11 Deleting quotation 12 Adding/removing symbol from favourites .12 Merging quotations of two symbols 12 Metastock importer window 13 Beginners' charting guide .17 How to use drag−and−drop charting interface 26 User interface customization 34 Working with chart sheets and window layouts 38 Using layers 41 Using Web Research window .46 Using account manager 51 Using fundamental data 55 How to get quotes from various markets 58 How to set up AmiBroker with eSignal feed (RT version only) .60 How to set up AmiBroker with myTrack feed (RT version only) .62 How to use AmiBroker with external data source (Quote Tracker) .65 How to set up AmiBroker with IQFeed feed (RT version only) .66 How to use AmiBroker with Interactive Brokers TWS .71 How to use AmiBroker with external DDE data source 77 How to work with Real−Time data plugins 83 How to use AmiBroker with external data source (Quotes Plus, TC2000/TCNet/TC2005, FastTrack, Metastock) .87 How to update US quotes automatically using AmiQuote 90 How to download quotes manually using AmiQuote 93 Understanding AmiBroker database concepts .94 Background 94 AmiBroker database structure 94 What about the external data? .95 Understanding categories .96 Working with sectors and industries .97 Working with watch lists 104 Understanding how AFL works .111 Creating your own indicators 115 AmiBroker 5.20 User's Guide i Table of Contents Tutorial Using graph styles, colors, titles and parameters in Indicators .119 How to create your own exploration .129 How to write your own chart commentary .132 Using studies in AFL formulas 135 Back−testing your trading ideas .137 Portfolio−level backtesting 148 Reading backtest report 156 How to optimize trading system 157 Walk−forward testing 166 Back−testing systems for futures contracts 168 Pyramiding (scaling in/out) and mutliple currencies in the portfolio backtester 171 Using formula−based alerts 176 Using interpretation window 178 Multiple Time Frame support in AFL .178 Video Tutorials (on−line) .184 AmiBroker Reference Guide .185 Windows .185 Chart window pane 186 Parameters window 187 Study drawing tools 189 Line study properties window .196 Text box properties window .197 Formula Editor 198 Risk−Yield Map window .203 Database Settings 203 Intraday Settings window .205 Preferences window .207 Customize tools window .218 Symbol tree window .218 Information window 218 Notepad window .221 Quote Editor window 221 Symbol Finder window (F3) .222 Financial data window 222 Profile view pane 223 Special fields encoding scheme .223 Assignment organizer window .224 Composite recalculation window 224 Categories window .225 ASCII Import Wizard 226 Metastock importer window 229 Portfolio management window .230 Real−time quote window 231 Easy alerts window 232 Bar Replay window 235 Formula Editor 236 Quick review window 241 AmiBroker 5.20 User's Guide ii Table of Contents AmiBroker Reference Guide Automatic analysis window 242 Filter settings window .244 System test settings window 244 System test report window .251 Commission window 255 Commentary window 255 Plugins window 256 Indicator Maintenance Wizard 256 Log window 258 Menus .258 File menu .259 Edit menu .261 View menu .262 Insert menu 265 Format menu 268 Symbol menu .269 Analysis menu 270 Tools menu 271 Window menu 272 Help menu 273 AFL Editor menu 274 Automatic Analysis result list context menu .277 Chart context menu 278 Layouts context menu 279 Formula (chart) context menu 279 Layers context menu 280 Keyboard shortcuts .283 Import ASCII .284 How does it work? 284 Format definition commands 285 Comments 297 Usage examples 298 Default behaviour .299 User−definable file types and formats 300 Ticker aliases .300 AmiBroker's OLE Automation Object Model .300 Index of objects 301 ADQuotation .301 ADQuotations .301 Analysis 302 Application 303 Window 304 Windows .304 Commentary .305 Document .305 Documents .305 Market 306 Markets 306 AmiBroker 5.20 User's Guide iii Table of Contents AmiBroker Reference Guide Quotation 306 Quotations 306 Stock 307 Stocks 308 Practical Examples: 309 AmiQuote's OLE Automation Object Model 311 Index of objects .311 Document .312 Technical analysis guide 313 Introduction .313 Basic tools 313 Price charts 313 Trend lines .314 Moving averages 315 Regression channels 316 Fibonacci Retracement 317 Fibonacci Time Zones 317 Bollinger bands 317 Indicators 318 Accumulation/Distribution .318 Advance−Decline line (AD−Line) .319 ADX / Directional Movement Index 319 CCI − Commodity Channel Index .320 Chaikin Oscillator .320 MACD − Moving Average Convergence/Divergence .321 Money Flow Index 321 Negative Volume Index 322 OBV − On Balance Volume 322 Parabolic SAR (Stop−And−Reverse) .323 RS − Relative Strength (comparative) 323 RSI − Relative Strength Index 323 ROC − Price Rate Of Change 324 Stochastic Slow 325 TRIN − Arms Index .325 TRIX − TRIple eXponential 326 Ultimate Oscillator 326 VAP − Volume At Price histogram .327 Relative Performance chart 327 AmiBroker Formula Language (AFL) .328 AFL Reference Manual .329 Introduction .329 Basics .329 Lexical elements 329 Language structure 330 Keywords .343 AFL Function Reference − Categorized list of functions 357 AmiBroker 5.20 User's Guide iv Table of Contents AmiBroker Formula Language (AFL) AFL Function Reference − Alphabetical list of functions 364 #INCLUDE − preprocessor include command .371 #INCLUDE_ONCE − preprocessor include (once) command 372 #PRAGMA − sets AFL pre−processor option 373 ABS − absolute value .374 ACCDIST − accumulation/distribution 376 ACOS − arccosine function 377 ADDCOLUMN − add numeric exploration column .378 ADDSUMMARYROWS − add summary row(s) to the exploration output 381 ADDTEXTCOLUMN − add text exploration column .383 ADDTOCOMPOSITE − add value to composite ticker 385 ADLINE − advance/decline line 387 ADVISSUES − advancing issues .388 ADVVOLUME − advancing issues volume 389 ADX − average directional movement index 390 ALERTIF − trigger alerts 391 ALMOSTEQUAL − rounding error insensitive comparison 393 AMA − adaptive moving average .394 AMA2 − adaptive moving average .396 APPLYSTOP − apply built−in stop .397 ASC − get ASCII code of character 401 ASIN − arcsine function 402 ATAN − arc tan .403 ATAN2 − calculates arctangent of y/x 404 ATR − average true range 405 BARINDEX − get zero−based bar number 407 BARSSINCE − bars since 409 BBANDBOT − bottom bollinger band .411 BBANDTOP − top bollinger band .412 BEGINVALUE − Value of the array at the begin of the range 413 CATEGORYADDSYMBOL − adds a symbol to a category .414 CATEGORYFIND − search for category by name .415 CATEGORYGETNAME − get the name of a category 416 CATEGORYGETSYMBOLS − retrieves comma−separated list of symbols belonging to given category 417 CATEGORYREMOVESYMBOL − remove a symbol from a category .419 CATEGORYSETNAME − set the name of category (group, market, watch list, industry) .420 CCI − commodity channel index 421 CEIL − ceil value 423 CHAIKIN − chaikin oscillator 424 CLIPBOARDGET − retrieves current contents of Windows clipboard .425 CLIPBOARDSET − copies the text to the Windows clipboard .426 COLORHSB − specify color using Hue−Saturation−Brightness 427 COLORRGB − specify color using Red−Green−Blue components .429 CORRELATION − correlation 430 COS − cosine .431 COSH − hyperbolic cosine function .432 CREATEOBJECT − create COM object 433 AmiBroker 5.20 User's Guide v Table of Contents AmiBroker Formula Language (AFL) CREATESTATICOBJECT − create static COM object 434 CROSS − crossover check 435 CUM − cumulative sum 437 DATE − date .440 DATENUM − date number .442 DATETIME − retrieves encoded date time .443 DATETIMECONVERT − date/time format conversion .444 DATETIMETOSTR − convert datetime to string 446 DAY − day of month .447 DAYOFWEEK − day of week .448 DAYOFYEAR − get ordinal number of day in a year .449 DAYSSINCE1900 − get number of days since January 1st, 1900 .450 DECISSUES − declining issues .452 DECVOLUME − declining issues volume 453 DEMA − double exponential moving average 454 EMA − exponential moving average 456 ENABLEROTATIONALTRADING − Turns on rotational−trading mode of the backtester .460 ENABLESCRIPT − enable scripting engine .462 ENABLETEXTOUTPUT − enables/disables text output in the Chart Commentary window 463 ENCODECOLOR − encodes color for indicator title 464 ENDVALUE − value of the array at the end of the selected range 466 EQUITY − calculate single−symbol equity line 467 EXP − exponential function 471 EXREM − remove excessive signals .472 EXREMSPAN − remove excessive signals spanning given number of bars .474 FCLOSE − close a file 475 FDELETE − deletes a file .476 FEOF − test for end−of−file 477 FFT − performs Fast Fourier Transform .478 FGETS − get a string from a file .481 FGETSTATUS − retrieves file status/properties 483 FLIP − .485 FLOOR − floor value 486 FMKDIR − creates (makes) a directory 487 FOPEN − open a file 488 FOREIGN − access foreign security data 489 FPUTS − write a string to a file 492 FRAC − fractional part 494 FRMDIR − removes a directory 495 FULLNAME − full name of the symbol .496 GAPDOWN − gap down .498 GAPUP − gap up 499 GETBACKTESTEROBJECT − get the access to backtester object 500 GETBASEINDEX − retrieves symbol of relative strength base index 501 GETCATEGORYSYMBOLS − retrieves comma−separated list of symbols belonging to given category 502 GETCHARTBKCOLOR − get the RGB color value of chart background .503 GETCHARTID − get current chart ID .504 AmiBroker 5.20 User's Guide vi Table of Contents AmiBroker Formula Language (AFL) GETCURSORMOUSEBUTTONS − get current state of mouse buttons .505 GETCURSORXPOSITION − get current X position of mouse pointer .509 GETCURSORYPOSITION − get current Y position of mouse pointer .510 GETDATABASENAME − retrieves folder name of current database 512 GETEXTRADATA − get extra data from external data source 513 GETFNDATA − get fundamental data 515 GETOPTION − gets the value of option in automatic analysis settings .517 GETPERFORMANCECOUNTER − retrieves the current value of the high−resolution performance counter .519 GETPLAYBACKDATETIME − get bar replay position date/time .521 GETPRICESTYLE − get current price chart style 522 GETRTDATA − retrieves the real−time data fields 523 GETRTDATAFOREIGN − retrieves the real−time data fields (for specified symbol) .525 GETSCRIPTOBJECT − get access to script COM object 527 GETTRADINGINTERFACE − retrieves OLE automation object to automatic trading interfac 528 GFXARC − draw an arc .529 GFXCHORD − draw a chord 530 GFXCIRCLE − draw a circle 531 GFXDRAWTEXT − draw a text (clipped to rectangle) .532 GFXELLIPSE − draw an ellipse .535 GFXGRADIENTRECT − draw a rectangle with gradient fill .536 GFXLINETO − draw a line to specified point .537 GFXMOVETO − move graphic cursor to new position .538 GFXPIE − draw a pie .539 GFXPOLYGON − draw a polygon 540 GFXPOLYLINE − draw a polyline 541 GFXRECTANGLE − draw a rectangle .542 GFXROUNDRECT − draw a rectangle with rounded corners 543 GFXSELECTFONT − create / select graphic font 544 GFXSELECTPEN − create / select graphic pen 545 GFXSELECTSOLIDBRUSH − create / select graphic brush .546 GFXSETBKCOLOR − set graphic background color .547 GFXSETBKMODE − set graphic background mode 548 GFXSETOVERLAYMODE − set low−level graphic overlay mode .549 GFXSETPIXEL − set pixel at specified position to specified color .550 GFXSETTEXTALIGN − set text alignment .551 GFXSETTEXTCOLOR − set graphic text color 553 GFXTEXTOUT − writes text at the specified location 554 GROUPID − get group ID/name .555 HHV − highest high value .556 HHVBARS − bars since highest high .560 HIGHEST − highest value 561 HIGHESTBARS − bars since highest value .562 HIGHESTSINCE − highest value since condition met .563 HIGHESTSINCEBARS − bars since highest value since condition met 564 HOLD − hold the alert signal 565 HOUR − get current bar's hour 566 IIF − immediate IF function .567 AmiBroker 5.20 User's Guide vii Table of Contents AmiBroker Formula Language (AFL) INDUSTRYID − get industry ID / name 574 INSIDE − inside day .575 INT − integer part .576 INTERVAL − get bar interval (in seconds) .578 INWATCHLIST − watch list membership test (by ordinal number) 580 INWATCHLISTNAME − watch list membership test (by name) .581 ISCONTINUOUS − checks 'continuous quotations' flag state .582 ISEMPTY − empty value check 583 ISFAVORITE − check if current symbol belongs to favorites .584 ISFINITE − check if value is not infinite 585 ISINDEX − check if current symbol is an index 586 ISNAN − checks for NaN (not a number) .587 ISNULL − check for Null (empty) value 588 ISTRUE − true value (non−empty and non−zero) check .589 LASTVALUE − last value of the array 590 LINEARRAY − generate trend−line array 593 LINEARREG − linear regression end−point .595 LINREGINTERCEPT − 596 LINREGSLOPE − linear regression slope 597 LLV − lowest low value .598 LLVBARS − bars since lowest low .601 LOG − natural logarithm .602 LOG10 − decimal logarithm .603 LOWEST − lowest value 604 LOWESTBARS − bars since lowest .605 LOWESTSINCE − lowest value since condition met .606 LOWESTSINCEBARS − barssince lowest value since condition met .607 MA − simple moving average .608 MACD − moving average convergence/divergence .613 MARKETID − market ID / name .614 MAX − maximum value of two numbers / arrays 615 MDI − minus directional movement indicator (−DI) 617 MEDIAN − calculate median (middle element) 618 MFI − money flow index .619 MIN − minimum value of two numbers / arrays 620 MINUTE − get current bar's minute 622 MONTH − month 623 MTRANDOM − Mersene Twister random number generator .624 MTRANDOMA − Mersene Twister random number generator (array version) 625 NAME − ticker symbol 626 NOTEGET − retrieves the text of the note .630 NOTESET − sets text of the note .631 NOW − gets current system date/time .632 NUMTOSTR − convert number to string 633 NVI − negative volume index .635 NZ − Null (Null/Nan/Infinity) to zero 636 OBV − on balance volume .637 OPTIMIZE − define optimization variable .638 AmiBroker 5.20 User's Guide viii Table of Contents AmiBroker Formula Language (AFL) OPTIMIZERSETENGINE − select external optimization engine 641 OPTIMIZERSETOPTION − set the value of external optimizer engine parameter 642 OSCP − price oscillator 643 OSCV − volume oscillator 644 OUTSIDE − outside bar .645 PARAM − add user user−definable numeric parameter 646 PARAMCOLOR − add user user−definable color parameter .651 PARAMDATE − add user user−definable date parameter .654 PARAMFIELD − creates price field parameter .655 PARAMLIST − creates the parameter that consist of the list of choices 657 PARAMSTR − add user user−definable string parameter .658 PARAMSTYLE − select styles applied to the plot 659 PARAMTIME − add user user−definable time parameter 661 PARAMTOGGLE − create Yes/No parameter .662 PARAMTRIGGER − creates a trigger (button) in the parameter dialog .664 PDI − plus directional movement indicator .665 PEAK − peak 666 PEAKBARS − bars since peak .667 PERCENTILE − calculate percentile 668 PLOT − plot indicator graph .669 PLOTFOREIGN − plot foreign security data 676 PLOTGRID − Plot horizontal grid line 677 PLOTOHLC − plot custom OHLC chart .678 PLOTSHAPES − plots arrows and other shapes .680 PLOTTEXT − write text on the chart 683 PLOTVAPOVERLAY − plot Volume−At−Price overlay chart .685 PLOTVAPOVERLAYA − plot multiple−segment Volume−At−Price chart 686 POPUPWINDOW − display pop−up window .688 PREC − adjust number of decimal points of floating point number 689 PREFS − retrieve preferences settings 690 PRINTF − Print formatted output to the output window 692 PVI − positive volume index .694 RANDOM − random number 695 REF − reference past/future values of the array 697 RELSTRENGTH − comparative relative strength 704 REQUESTTIMEDREFRESH − forces periodical refresh of indicator pane .705 RESTOREPRICEARRAYS − restore price arrays to original symbol 707 RMI − Relative Momentum Index .708 ROC − percentage rate of change .709 ROUND − round number to nearest integer .711 RSI − relative strength index 713 RWI − random walk index 715 RWIHI − random walk index of highs .716 RWILO − random walk index of lows .717 SAR − parabolic stop−and−reverse .718 SAY − speaks provided text .719 SECOND − get current bar's second .721 SECTORID − get sector ID / name 722 AmiBroker 5.20 User's Guide ix [...]... system and automatic bug reporting .953 How to purchase AmiBroker ? 957 Credits 959 xii Copyright AmiBroker 5.20 User's Guide Copyright © 1995−2008 Tomasz Janeczko /AmiBroker. com All rights reserved AmiBroker, AmiQuote, AmiFeed, AmiBroker. com and AmiBroker logo are trademarks of Tomasz Janeczko /AmiBroker. com Microsoft, ActiveX, JScript, VBScript, Internet Explorer,... referred to as "main AmiBroker directory" Getting started 7 AmiBroker 5.20 User's Guide Introduction If setup program asks you to restart machine please do so to allow to replace system components After installation, you can start AmiBroker from Windows' standard Start−>Programs− >AmiBroker >AmiBroker menu Just after starting AmiBroker splash window shows up, then for few seconds AmiBroker loads its... send an empty e−mail to: amibroker subscribe@egroups.com To unsubscribe please send an empty e−mail to amibroker unsubscribe@egroups.com Checking these places first will help me focusing on developing new features in AmiBroker In case of Getting help 8 AmiBroker 5.20 User's Guide Introduction problems not covered in above resources please don't hesitate to contact me at: support @amibroker. com Getting... will guide you through most important aspects of using AmiBroker The next chapter − Reference guide − provides detailed description of every window and more technical documentation covering ASCII importer and automation interface In the Technical analysis guide you will find material that will introduce you to the world of charting and technical indicators The next part of the guide describes AmiBroker. .. ticker to the alias field of the "new" ticker Deleting quotation 12 AmiBroker 5.20 User's Guide Tutorial Beginners' charting guide Introduction AmiBroker 4.20 brings new charting engine with object−oriented manipulation of all drawings Now you can simply move, resize, cut, copy, paste and delete all drawing objects with ease This chapter will guide you though most important aspects of using charting tools... information Configurability AmiBroker is designed to be configurable and customizable in almost every area It is not tied Quick Tour 6 AmiBroker 5.20 User's Guide Introduction to particular exchange or data provider Thanks to flexible import methods and scripting you will be able to adopt it easily to your favourite market(s) Also technical analysis tools built in into AmiBroker allow you to change... Tour 5 AmiBroker 5.20 User's Guide Introduction • Test long, short or both long and short trades • Maximum−loss stop, profit−target stop, trailing−stop, N−bar (time) stop • Realistic back−testing • Ability to control position size from your formula (Read more ) • Create your own composites and scan/backtest them • Detailed reporting giving you imporant statistics of your system Optimization: AmiBroker. .. Commentary window 872 AFL Scripting Host .872 Basics 872 Requirements .872 Enabling AFL Scripting Host 873 xi AmiBroker 5.20 User's Guide Table of Contents AmiBroker Formula Language (AFL) Further information .877 Component Object Model support in AFL 877 Introduction 877 Calling functions defined... Installation and running Install AmiBroker using it's setup program − it is available for download from http://www .amibroker. com/download.html After downloading double click on the program's icon This will launch the setup program − you can safely accept all default values by clicking "Next" on each page and "Install" on the last page By default AmiBroker is installed to "C:\Program Files \AmiBroker" directory.. .AmiBroker 5.20 User's Guide Table of Contents AmiBroker Formula Language (AFL) SELECTEDVALUE − retrieves value of the array at currently selected date/time point 723 SETBACKTESTMODE − Sets working mode of the backtester . Credits 959 AmiBroker 5. 20 User's Guide xii Copyright AmiBroker 5. 20 User's Guide. Copyright © 19 95 200 8 Tomasz Janeczko /AmiBroker. com AmiBroker 5. 20 User's Guide Copyright (C)19 95 200 8 AmiBroker. com. All rights reserved. Table of Contents