A Mi

June 28, 2016 | Author: masmid | Category: N/A
Share Embed Donate


Short Description

Download A Mi...

Description

AmiBroker is the ideal program for you to use to chart and develop trading systems for your favorite markets — stocks, mutual funds, exchange traded funds, commodities, or Forex. It is powerful, flexible, inexpensive, and easy to use. This book is for: • • •

Someone new to AmiBroker looking for detailed instructions and examples to get set up and started. An experienced AmiBroker user who wants a printed reference to commonly used tools. Someone looking for an introduction to the AFL language, and using AmiBroker to write trading systems.

Topics covered include: ‫״‬ ‫״‬ ‫״‬ • ‫״‬

Writing trading systems Testing trading systems Optimizing trading systems Validating trading systems

Installing AmiBroker Setting up free databases Setting up subscription databases Setting up real-time databases Charting stocks, funds, futures Applying chart tools

Chapter 3 - 3 0 Minutes to Useful Results ‫ ־‬has 10 example projects t h a t parallel the tutorials, each of which can be done in just a f e w minutes. 1. 2. 3. 4. 5.

Chart a Stock Apply a Trendline Plot a Moving Average Make a Watchlist Run an Exploration

6. 7. 8. 9. 10.

Run a Single Stock Backtest Run a Portfolio Backtest Optimize a Trading System Perform Walk Forward Validation Scan for Buy and Sell Signals

Dr. Howard Bandy has both the formal education a n d practical experience required to write this book. He has degrees in mathematics, physics, engineering, and computer science. He was a university professor of computer science and mathematics, vicepresident and designer of the major product for a company that produced p r o g r a m s for stock selection and timing, and senior research analyst for a commodity trading advisor where he held a Series 3 license. He is the author of the very well received Quantitative Trading Systems - a book that uses AmiBroker to illustrate more advanced trading system topics. He is a regular and popular speaker and author on topics of trading system design and testing. $US 39.95 ISBN

This is the book you need if you are looking for a step-by-step introduction to AmiBroker. 9

978-097918381-2

1 o u r 1y 1odo i c

Introduction to

AmiBroker

Introduction to

AmiBroker Advanced Technical Analysis Software for Charting and Trading System Development Howard B. Bandy Blue Owl Press

Copyright © 2008 by Howard B. Bandy All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise without the prior written permission of the copyright holder, except brief quotations used in a review. AmiBroker is a trademark of AmiBroker and Tomasz Janeczko. Windows, Excel, and Notepad are trademarks of Microsoft. Premium Data is a trademark of Norgate Investor Services. QP3 and QP Feed are trademarks of Quotes Plus. DTN IQ Feed is a trademark of DTN.

ISBN-10: 0979183812 ISBN-13: 9780979183812 LCCN: 2008905105 Published by Blue Owl Press 3700 S. Westport Avenue, #1876 Sioux Falls, SD 57106 Published 2008 Printed in the United States 12 11 10 09 08 10 9 8 7 6 5 4 3 2 1

DISCLAIMER

This book is an educational document. Nothing in this book is intended as, nor should it be construed to be, investment advice. The views expressed herein are the personal views of Dr. Howard B. Bandy. Neither the author nor the publisher, Blue Owl Press, have any commercial interest in any of the products mentioned. All of the products described were purchased by the author at regular retail prices. Investing and trading is risky and can result in loss of principal. Neither this book in its entirety, nor any portion thereof, nor any follow-on discussion or correspondence related to this book, is intended to be a recommendation to invest or trade mutual funds, stocks, commodities, options, or any other financial instrument. Neither the author nor the publisher will accept any responsibility for losses which might result from applications of the ideas expressed in the book or from techniques or trading systems described in the book. The programs used as examples have been tested and are believed to be correct. Even so, this book may contain typographical errors and other inaccuracies. Past performance, whether hypothetical, simulated, backtested, or actual, is no guarantee of future results. Results will depend on the specific data series used. Please verify the accuracy and correctness of all programs before using them to trade.

ACKNOWLEDGEMENTS

Tomasz Janeczko, author of AmiBroker. Thank you for creating an outstanding program, and for graciously allowing use of materials published in the AmiBroker user documentation. Bruce Robinson and William Barack. Thank you for the many stimulating discussions, encouraging comments, and conference presentations, all of which helped motivate and shape this book. Robert Grigg. Thank you for the many stimulating discussions and exchange of ideas, and for raising awareness of AmiBroker in Australia. Particular thanks for permission to use the schematic of AmiBroker that you developed.

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 Free Database Using AmiQuote

14 15

Subscription Data Providers Database Setup - Intra-Day and Real-Time Data

31 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

Ill

Chapter 5 - The GUI - Graphical User Interface Charts

113 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 AFL Editor

242 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

Preface and Introduction

This book is intended to be a tutorial. Topics included and detail covered involved compromises b e t w e e n elementary and advanced, narrow and broad, superficial and in-depth. Those chosen are practical examples of tasks that you will be p e r f o r m i n g regularly. For additional tutorials, watch the on-line tutorial videos, available at http://www.amibroker.com/tutorials. For a more complete reference, see the AmiBroker User's Guide and the AmiBroker Reference, both available at http://www. amibroker.com. This book is task oriented, rather t h a n software oriented. M a n y operations can be performed in more than one way. W h e n m a k i n g a choice, clarity was chosen over efficiency. This book is not intended to be read cover-to-cover, as a novel would be read. It is intended to be a series of tutorials and reminders covering operation of AmiBroker. The examples use a lot of screen capture images, annotated w i t h n u m bered steps, highlights, and arrows. The book includes reference to all the functions, indicators, and tools d o c u m e n t e d in the User's Guide and in the Help system. INTENDED AUDIENCE

People wanting: •

Description of AmiBroker.



Description of the capabilities of AmiBroker.



Tutorial on installing and setting up AmiBroker.



Tutorial on setting up databases w i t h free data. xiii

xiv

Introduction to AmiBroker •

Tutorial on setting up subscription end-of-day databases.



Tutorial on setting up real-time data feeds.



Tutorial on the basic charting.



Tutorial and reference on the Graphical User Interface - GUI.



Tutorial on applying formulas and indicators to charts.



Tutorial on the AmiBroker Formula Language - AFL.



Introduction to technical analysis.



Introduction to design of trading systems.



Tutorial on backtesting trading systems.



Tutorial on optimizing trading systems.



Tutorial on validating trading systems.



Examples of trading systems.



Printed reference for AmiBroker structure, menus, tools.

ASSUMPTIONS

While this book is intended to be a tutorial on AmiBroker, the reader is expected to be reasonably familiar with: •

Computer operations.



Basic techniques used with the Windows operating system, such as the menu system, drag-and-drop, navigating through the file system.



A basic text editor, such as Windows Notepad.



A spreadsheet, such as Excel.



Basic trading methods and terminology.

W H A T YOU WILL FIND IN THIS BOOK

An overview of AmiBroker - its features and capabilities. Tutorials describing the installation of AmiBroker, setting up databases using free end-of-day and intraday data, setting up databases using subscription end-of-day data (for US and Australian markets), and setting up databases using subscription real-time data. SECTION I - GETTING STARTED.

There are ten examples of useful things you can do with AmiBroker in just a few minutes, even if you are using the trial version. These range from manipulating the charts to applying on-screen indicators to testing and optimizing trading systems. Everything is laid out, click-byclick, with screen captures to illustrate each step.

Preface and Introduction Each of the m e n u s and toolbars that work with charting is expanded and explained. SECTION II - CHARTING.

TOPICS INCLUDE:



Displaying charts.



Adding visual studies, such as trendlines, to a chart.



Adding formulas and technical indicators to a chart.



Using parameters with indicators.

S E C T I O N I I I — A N A L Y S I S . The Analysis section begins with a short introduction to technical analysis and trading system development.

That is followed by an introduction to AFL - AmiBroker Formula Language, including its structure and syntax. AFL is used to write code to create your own custom charts and trading systems. This section is part tutorial, part programming manual, part reference manual. The use of the Automatic Analysis tools, including backtest, optimization, and walk forward validation, are explained. Several ready-to-use programs you can use as starting points for your own system development are included. THE APPENDIXES. INDEX.

Provide reference material.

Menus, commands, tools, and techniques are extensively in-

dexed. W H A T Y O U WILL N O T FIND I N T H E T H I S BOOK

AmiBroker has so much to offer that this book could easily have been expanded by several hundred pages. Readers looking for coverage of topics such as the Custom Backtester, Dynamic Data Exchange, lowlevel graphics, scripting, and the Automated Trading Interface will have to wait for another book. Readers looking for coverage of topics such as different types of trading systems, trading system testing, trading system validation, and the creation of C++ routines and Dynamic Link Libraries are referred to the author's companion book, Quantitative Trading Systems (see Appendix C, Resources). SOME

CONVENTIONS

AmiBroker can be used with any tradable, including stocks, mutual funds, closed end funds, exchange traded funds, commodities, futures,

xvi

Introduction to AmiBroker

and Forex. For ease of writing and reading, the terms stock, symbol, issue, or ticker are often used to mean any tradable issue. When it is important to distinguish between different tradables, specific details are given. AmiBroker is distributed and used world-wide. With the exception of setting up the database to reflect the local tradables and exchanges, most of the operations of AmiBroker are independent of location. The author resides in the United States and most of his experience is with trading in the US, which may shape some of the perspective of this book. Apologies in advance for any inadvertent mistakes or misleading statements due to his limited background - no discrimination of any kind is intended. VERSIONS USED

AmiBroker 5.10.0 and later. AmiQuote 2.00. AmiBroker is regularly expanded and improved. During the life of this edition of this book, the features, capabilities, screens, and commands, will undoubtedly change somewhat. Every attempt was made to write in such a way that the book will be useful for a long time and will not soon become obsolete as new versions of the program are released. But there will be changes in the program that are not reflected in the book. For the latest and official documentation, please refer to the latest editions of the AmiBroker User's Guide, the on-line help files, and the tutorials, all of which can be found on the AmiBroker web site: http://www. nmibroker.com. THE AUTHOR

Dr. Howard Bandy: •

Has university degrees in mathematics, physics, engineering, and computer science.



Has specialized in artificial intelligence, applied mathematics, modeling and simulation.



Was professor of computer science and mathematics, and a university dean.



Designed and programmed a well-known program for stock selection and timing.



Was a senior research analyst for a CTA trading firm.

Section I

Getting Started

1 2 Introduction to AmiBroker

AmiBroker

You are visitor #

573881

e J a n u a r y 1st, 2002

for Windows 95/98/Me/NT/2k/XP mws

\ ttawrfed 1

‫יי‬

harts

‫ םי‬x

-V-nteb ; \ Utytn '. j Charts J Averages J Bands J Basic Charts J Custom ‫ ב‬Equity J Include J Indicators J Systems / Example / ExampleRotational

Symbol

Analysis O

look i

ffilndow 5.•

‫״‬

‫ ו‬3

Help : ‫ י !נסי׳‬s A f !

'J "DJI (Daily) x / "DJI - Daily 8/31/2007 Open 13240 8, Hi 13472 3. Lo 13240 8, Close 13357 7 (0 9%) Vol"27.316.100 M^cio&e/16) = 13.1

12,837,1, (Version 5.10.2. Build date Jun 15 2008) UNREGISTERED- DOES NOT SAVE CHANGES! Advanced technical analysis sottwa Copyright ® 1995-2008 AmiBroker.cc 1

Kebfuan,

interpretation

For more information visit;

http //www.amibroker a

Technical support:

[email protected]

Bug reports

[email protected]

This progra

;s Microsoft active scripting technologies

August‫־‬ ‫ ״•״>״‬J | | |

™Wl»l

‫ג׳‬

‫ם י‬

Interpretation jffoiapad I Price Date: 8/31/2007 Price and moving averages: ~DJI(DOW JONES INDUSTR) has : closed above Its Short time movng average. Short Bme movng average is currently below mid-time, AND below long dme moving averages. The relationship between price arid moving averages is: neutral

,,.. 111 i l l

120 0; ^ 60.0j«‫׳‬ 0 0! ®

mm ^ roi *

| 1‫׳‬DJI-RSI( 15) = 51.59

vY

M

• M :\ Sheet 1 / 1. ‫׳‬

/

70 O t )

wv^

1 . •'>. V.I 1e AmiBroker > AmiQuote > AmiQuote.

7. Using AmiQuote's File menu, select Open. Then select the file with the tickers you want to get historical data for, R U S S E L L I O O O . tls, and click Open. H AmiQuote

« ct ‫ט‬

ca ! •

i Source: Si j!

-

Untitled



From:

-

. •

•>

*‫א‬

¥

jYahoo Historical { 1/ 1/1995

Automatic import

M (EOD. stocks, funds. US & International (50))

jJ

0

To:

j 7/26/2008

‫״־‬J —f

p*

‫פ‬

^ervel (Quote.com/Forex):

‫ ״י‬j Run eveiy:

j ‫י‬

r‫ ״‬All s e s s i o n s (Quote.com only)

Look in: ji-S AmiQuote

jpJ

m-

® ct 6

C^ Download JSl RUSSELL2000.TLS DJINDUSTRIALS.tls >§ SPlOO.tls :^DJTRANS.tls SPSectorETF.tls DXJTIL.tls Cj FTSElOO.tls 3 NASDAQlOO.tls ':rj,AS*.tri»l.2tBB080e.«jB

34 mins/1 mins

East Coast USA Server W e s t Coast USA Server Australian Server European Server

AmiBroker Files The following files are applicable for users of the AmiBroker charting software ONLY Only download them if you have AmiBroker installed on your PC, More information about these files can be found at AmiBroker FAQ AmiBroker A S X Workspace Setup with ©ICS classifications, AmiBroker groups and extensive watchlists Setup ArnBrok8r-ASX-PrBmtumDaia‫־‬y1 41.exe

0.8 MB

4 rnins/1 mins

East Coast USA Server W e s t Coast USA Server Australian Server European Server

Market Analyst Files The following files are applicable for users of the Market Analyst charting software ONLY, Only download them if y o u have Market Analyst installed on your PC,

Market Analyst

All versions of Market Analyst have a bug related to dates prior to January 1900 This historical installer replaces just the W o r l d Indices with data that extends after this date This file is only required if you have Market Analyst installed on your 2.3 MB computer. This file is NOT applicable the HomeTrader version of Market Analyst as it has no MetaStock reading capabilities BislallHlstory WorlfcaiMS MwkatAmilyst aWOBlO me

10 mins/1 tnins

Ea^t Cojjst LISA Server W e s t Coast USA Server Australian Server European Server

To download a program or history installer, click on the corresponding server closest to you (Australia. Europe or USA) Choose to Save the file to your Windows Desktop, or to some other location where you can find it readily

Click on the server nearest to you (Australia, Europe or USA). 5. Save the files and accept all the defaults for file locations. 6. The Program Installer and History Installer must be in the same subdirectory on your computer. 7. Insure that AmiBroker is not running. 8. Locate the program installer, run it and follow the prompts. The program installer will recognise the history installer and offer to install the history for you as part of the process. If the files are too large for your communications, you may prefer to order a data history CD which will be sent out to you by ordinary mail.

1 2 Introduction to AmiBroker Execute the files in this order: 1) Program Installer. 2) Historical Data Installer. 3) AmiBroker Setup. W‫ ׳‬Norgate Premium Data File

Edit

©

B

View a

re$;

c

Favorites 0

Tools

,j C:\Documents and Sett1ngs\Howard\pesktop\Norgate Premium Data x

Folders [ | j $ Desktop a at m

Help

‫ \ י © ־ ׳ ־‬/ ) s e a r c h ! ^ Folders |

My Documents y My Computer

Name

*

CpAmiBroker-ASX-PremiumData-vl.41.exe ‫יי‬ ]lpInstellHistory.ASX.tr ial.20080808.exe — ^gj setup. pre m iu mdata.exe

Size : Type 844 KB Application 3,223 KB Application

My Network Places jgl Recycle Bin

‫ש‬

ASCII Downloads

i!

Misc Folders

yBSSSSSSSS ij~) Quotes Plus Setup

£ i C i Unused Desktop Shortcuts

When the AmiBroker Setup runs, it will open a browser-based FAQ page explaining how to install the interface necessary for AmiBroker to use the Premium Data files.

© e

Installation

39 ‫ו‬

AmiBroker Setup will establish a database in the AmiBroker directory, but it will not be usable yet. Here is how to connect the two:

Look in:

My R e c e n t

&

Documents

Desktop

J

My Documents

Q AmiBroker

0 ,t

m -

O AmiQuote QASX-PremiumData QCodeGen !OData O DataAsD istr touted I^DataRusselllOO• OeSignal JQ For mats iQFormulas QlntraDay Q Layouts ii^j Notes O P i Continuous Contracts © P I Data Q Plug ins O Q P End of Day O Reports O Scripts

My Computer

My Network Places

File name:

|

OperT"

Files of type:

10. Start AmiBroker. 11. Using the Tools menu, click ASX-Premium Data. This will r u n a script with seven stages that takes several minutes. Tools | Window

yelp

‫ ׳‬Database Purify,,, i: Indicator Maintenance,,, Bar Replay &

Preferences... Save preferences Plug-ins... Customize... | Auto-update quotes (AmiQuote only) | Sharenet Downloader f Cleanup database ASX-PrerniumData

12

Introduction to AmiBroker 12. Using the File menu, select Open Database, select ASXPremiumData, click OK. Browse for Folder Please select workspace directory C :\Program F i les\A m Broker\ASX-Pre rn iu mData £9

AmiBroker as Q AmiQuote CodeGen SB Si Data DataAsDistributed m fcg DataRusselllOOO eSignal ^ Formats Si Q Formulas ® IntraDay

13. Here is AmiBroker with BHP in the chart window. L AmiBroker - [BHP - BHP BILLITON LIMITED ORDINARY - Daily] File

Edit

• » B @

View

Insert

Format

«

Symbol O

Analysis

!0013

Window

Help

O [



BHP (Daily) • BHP - Dally 8/13/2008 O p e n :-a; 65. Hi 37,1 0 36 :6‫׳‬, C l o s e 36 76 ( 1 2%) Vol 11,177.735 a - [ ! . : ‫ ׳ ׳ ״‬: ‫ ׳‬I5j = 37 66, Mid MA(f

A, A"

'•rAh

1‫־‬/



50.0: 48.0 48.0

A‫^^־‬..

^

EliHAil

39.7846

I&IHII

V^/l

V

38 4063n H37.65870 35 5447D

1

Sep

'Oct

'Nov

'Dec

'2008

'Feb

1

'Mar

1

Apr

May

'Jun

'Jul

'Aug

| BHP - MACD(12,26) _ = J .03, Signal( 12,26,9) = - 1 . 0 8 , EMA(MACD( 12.26), 15) = - 1 4 1

I B0 1 20; 0 60

ttlllllli.

= 48 96,; •

BHP - RSI(15) = 41 54, EMA(RSI(15),15) = 41 75



= 35 18 p,

1

fSep .

1

"• 1 l

• ••‫י‬

• F 1

05‫ז‬

,

Nov

1

Dec

'2608

' S h e e t 1 , S h e e t 2 ‫ ן‬Sheet 3 ^ Sheet •4

Teb f

1

Tviaf

Apr

Titey

Sheet 5 \ Sheet 6 ), sheet 7 , 1

1

h.

1

Jun

Qui

lAug

. 1

‫ן י י‬:.‫׳'׳‬- • 1 • ‫ז‬.‫ו‬,.‫ו^י‬. -

r\

: . F1

,1.1 ,1:.g

Installation

41 ‫ו‬

DATABASE SETUP - INTRADAY A N D REAL-TIME D A T A

Intraday data is data with bars shorter than a full trading day. Taking great care and using a data vendor that supports it, it is possible to combine intraday and end-of-day data in the same database. But most AmiBroker users who use intraday data maintain a separate intraday database. The next few pages describe setting up intraday and real-time data. FREE INTRADAY HISTORICAL DATA

If you are interested in developing systems with intraday data, but are not ready to commit to a real-time data subscription, you can download intraday bars into an AmiBroker database and work with them. If your systems test out to be profitable, you will eventually need real-time data to execute them. There are several sources of free intraday historical data. Visit http:// www.lntroductionToAmiBroker.com/resonrces and scroll down to the data area for links to some of them. AN Futures sells intraday data for the emini S&P 500, e-mini NASDAQ 100, e-mini Russell 2000, Euro, and Yen in 1 minute bar and tick resolution. Visit them at: http://wzow.anfutures. com/. They have a demo file, ES0206MG.csv with 1 minute bars for the e-mini S&P June 2002 contract - 3/6/2002 through 6/12/2002. The third column is the date, with 20306 meant to be 2002, March, 6. ES01MIG.I,20306.15:50.1165.5,1165.5,1165.5.1165.5,8.1159.5 ES01MIG.I,20306.15:51.1165.5.1165.5,1165.5,1165.5.3.1159.5 ES01MIG.I,20306.15:52.1165.5,1165.5.1165.5,1165.5,9,1159.5 ES01MIG,I,20306,15:53.1164.25,1164.25.1164.25,1164.25,6.1158.25 ES01MIG.I,20306,15:54,1162.25,1162.25,1162.25,1162.25,1.1156.25 ESOIMIO.I,20306,15:55,1164.5,1164.5,1164.5,1164.5.3.1158.5 ES01MIG.1,20306.16:20.1164.25.1164.25,1164.25,1164.25,1.1158.25 ES01MIG.I.20306.16:21,1164.1164,1164.1164,1.1158 ESOIMIG.I,20306,16:24,1164.25.1164.25,1164.25,1164.25,1.1158.25

AmiBroker can accept many date formats, but not that one, so a spreadsheet is used to transform the date into one of the acceptable formats and 20306 becomes 2002-03-06. The Excel formula to do this is: =‫״‬200‫&״‬LEFT(C1,1)&‫״‬-‫&״‬MID(C1,2,2)&‫״‬-‫&״‬MID(C1,4,2), where the 20306 is in cell CI. Make a copy of the original data file, replace the date, and save it with a new name, for example E S 0 2 0 6 M O D . C S V . The following procedure will set up a database into which we will load the e-mini S&P intraday data. This is the same procedure used to set up the Quotes Plus end-of-day database, so the illustrations will be omitted.

12

Introduction to AmiBroker 1. In AmiBroker, from the File menu, select New, then Database.

Working first in the top half of the window: 2. In Destination Folder, choose a meaningful name for the database - such as IntraDay. 3. Uncheck Load this database at startup. 4. Click Create. Now working in the bottom half of the window: 1. Data Source: (local database) 2. Local data storage: Enable 3. Number of bars: 100000 4. Base time interval: 1 minute 5. Accept the defaults for Intraday settings 6.

Click OK

The database is established, but has no data in it. The ASCII importer will load the data from the csv file using the ASCII Import Wizard in the following procedure: 1. In AmiBroker, from the File menu, select Import Wizard. 2. Click Pick Files. 3. Navigate to the location of your modified file and select it. 4. Click Open. 5. Click Next. 6. Fill in the fields. Here you can define the fields in the d a t a file. U s e c o m b o - b o x e s to select appropriate field type. Hover the m o u s e a b o v e the controls to s e e additional hints. Column 1

Column 2

Column 3

Column 4

Column 5

Column 6

Column 8

Column 9

Column 10

Column 11

Skipfirst:

[0

Separator:

jComma(.)

1

Group:

| Group 255



Watch list

Column 7

Column 12

j lines.

0 LL oo g errors ® [*/!Automatically a d d new symbols

•‫ו‬

‫ ח‬Calculate

Additional commands:

composites

F 1 N o quotation d a t a P‫ |־‬Allow negative prices

D a t a file sample: ES01 MIG.I.2002-03-06.15:50.1165 5.1165.5.1165.5.1165.5,8.1159 5 | ES01 MIG.I.2002-03-06,15:51.1165.5.1165.5,1165.5.1165.5.3.1159.5 IES01 MIG.I.2002-03-06.15:52.1165.5,1165.5.1165.5.1165.5.9.1159.5 ;ES01 MIG.I.2002-03-06.15:53.1164.25.1164.25,1164 25.1164 25,6.1158.25

I

< Back

|[

Next >

]

j

Cancel

)

[

Help

Installation

43 ‫ו‬

7. Click Next. 8. Click Finish. The data will be imported and the active chart will display the intraday data you just loaded.

9.

In AmiBroker, Save Database.

If you were going to import data from this vendor regularly, you cou Id set up a macro in the spreadsheet to convert the date field, and set up a custom ASCII format in AmiBroker specifically for that file format. But, eventually, you will need a real-time data feed to create 1 minute bars throughout the trading day. DELAYED REAL-TIME D A T A

Some data vendors offer real-time data that has been delayed 15, 20, or 30 minutes. It is priced lower than non-delayed real-time data, and often is free. From the perspective of a developer of trading systems, about the only reasons to use delayed real-time data are to try out a data service or to build up a tick-based database. And, since most of the high quality data services have a trial period, you can try the real thing for the same amount of effort. Trying to place trades using delayed real-time data is dangerous to your wealth — a lot can happen in 15 minutes.

44

Introduction to AmiBroker

REAL-TIME D A T A

Real-time data can be expensive. Prices range from about $50 to several h u n d r e d per month for the basic service which includes a limited number of tickers. There are additional charges for extra services, such as charting packages, Level II quotes, or getting data for a larger number of issues. Exchange fees, which are set by the exchange that clears trades for the tickers listed by them, are also added. There are different levels of exchange fees for professional and non-professional traders. Exchange fees can add up to several hundred dollars a month. Most real-time data vendors have trial periods, but the exchange fees charged during the trial are usually not refundable. Also, check your Internet communications capacity and your communication vendor's fair use policy. Monitoring about ten symbols in the real-time quote window causes traffic of about 50 MB per hour. Done every trading day of the month, this will exceed the fair use limits of some vendors. As mentioned earlier, some vendors support combining end-of-day and intraday data in the same database. But that can be tricky. These steps describe separate intraday databases. Quotes Plus Real-Time Data The procedure to set up a real-time data feed using Quotes Plus is: 1. Begin with a visit to Quotes Plus' website: http://www.qp2.corn/ joomla/index.php. 2. Pull down the Products menu, select QPFeed, and click Free Trial.

3. Fill in the contact information. You will receive an email from Quotes Plus containing a User ID, Password, and the URL link to a download utility.

Installation

45 ‫ו‬

4. Follow the link to the download utility and download the qpfeed_setup.exe file. 5. Execute that file to start the installation. 6. Enter your User ID and Password when requested. 7. Accept all the defaults. 8. Click Finish to the final dialog and the program will close. The procedure to connect AmiBroker to the QPFeed is: 1. Start AmiBroker. 2. You will see a message saying that there is a new plug-in from qpfeed. Click OK. —

:



‫ז‬

: — —

‫ — י‬: :

IE

‫ל‬

AmiBroker You are using following NON-CERTIFIED third-party plugins:

qpfeed_ami.dll - qpFeed Real Time Data Plug-in, vl.0.92 by Quotes Plus www.quotes-plus.com 1

AmiBroker.com makes NO REPRESENTATIONS on features / performance of such third party plugins. Entire use of non-certified third-party plugins is AT YOU? OWN RISK. This message will not appear anymore unless you install new non-certified plugins

1

3.

°K

|

Using the File menu, select New, then Database.

Working in the top half of the box: 1. In the Database folder box, enter the n a m e you want for your new real-time database. 2. Check or uncheck, as you wish, Load this database at startup. 3. Click Create. AmiBroker database maintains infromation about symbols, industry groups, watch lists, It is necessary even if you are using external data General Database folder: -‫ ו‬C:\program Files'\Arn!Broker\0P RealTime J v ‫ ] ׳‬Load this database at startup

j

Browse...

I

Create

Data sourc8 Data source: Local data storage:

Number of bars: (260 daily bars is about one year worth) Base time interval:

J

End-Of-Day Inlraday settings

(approx. 19 years, 156 KB per symbol)

j 1"

©

12

Introduction to AmiBroker

Now working in the bottom half of the Database settings box: 1. Pull down the Data Source menu and select QPfeed Real Time Data Plugin. 2. Click Enable local data storage. 3. Enter 25000 for number of bars. 4. Pull d o w n the Base Time Interval menu and select 1 minute. 5. Click Configure. The configuration menu will appear. 6. Select the categories you want to receive. 7. Check Exclude symbols without quotes. 8. Click Retrieve. 9. Click Close. Return to the Database settings screen. 10. Click OK. Database settings AmiBroker database maintains infromation about symbols, industry groups, watch lists. It is necessary even if you are using external data General Database folder:

[

| Load this database at startup

Data source Data source: Local data storage:

Number of bars: (260 daily bars is about one year worth)

Quotes Plus plugin configuration D a t a b a s e setup Select c a t e g o r i e s to retrieve (all items belonging to given c a t e g o r y will be a d d e d to the d a t a b a s e ) :

0 -

0

Stocks

[y*l Indexes ‫ ח‬Sector/industry a s s i g n m e n t s [ I Mutual funds ‫ ח‬Cash futures I

| Commodity futures (continuous)

!Volume Crossover ‫׳יי‬

PI Only s y m b o l s with issue_status = 0 0‫ ־־‬Exclude s y m b o l s without q u o t e s

•Q Options ‫ ח‬U n a d j u s t e d (raw) d a t a

Installation

47 ‫ו‬

At this point, you have a database established to store 1 minute bars and the QPFeed ready to supply data. To bring up a chart: 1. Using theAmiBroker Symbol menu, select New. 2. Type in a symbol, say SPY. In a few seconds the chart will appear. ix AmiBroker - [SPY - S6 P DEP RECEIPTS - 1 - m i n u t e ] ‫ צ‬Efe D

tf

Edit e

j

yiew ft

Insert

Format

;,

Charts

Symbol O

6

Analysis O S !

Help

lools SPY

SPY ( 1 - m i n u t e ) x S P Y - 1 - m i n u t e 8 / 1 4 / 2 0 0 8 2 : 0 5 : 0 0 PM O p e n 1 2 9 . 7 9 . Hi 1 2 9 . 8 4 . Lo 129 7 8 " c i 0 s e 129^8 ( 0 . 0 % ) Vol

Averages | f DEMA - Double / DispMA - Displ; / EMA - Exponen / Linear Regress / MA - Simple M! / TEMA - Triple f f / TSF - Time Sei / Wllders - Wilde / WMA - Weight! !3: D Bands / Bollinger Bands / Keltner Bands / Percent Bands S LJ Basic Charts / Open Interest ( / Price / Price (all in on< / Price (foreign) / Relative Perfor / Volume / Volume (color) / Volume At Pric! tei LJ Custom / AlertlfTest / ATC Trading Fi / Liquidity / RelativeStrengl / SimpleSystem / SimpleSystem f Unnamed 1 / Unnamed 2 ‫י‬

'8/13/2008 >

For Help, press F1

>13:00

'13:45

'14:30

'15:15

1

8/14/2008'10:30

•I \ S h e e t 1 / ‫ ׳‬S h e e t 2 \ Sheet 3 \ Sheet 4 \ Sheet 5

"11:15

'12:00

Sheet c - s M

>12:45

'13:30

<

Undefined, Undefined, Services, Advertising 9 QP RealTime

Introduction to AmiBroker

48

DTN IQ Real-Time Data The procedure to set up a real-time data feed using DTN IQ Feed is: 1.

Visit the DTN IQ Feed web site at: http://www.iqfeed.net ) W e l c o m e to l a F e e d ! - Fast, Reliable, Affordable. Datafeeds and API. - Mozilla Firefox File

Edit

‫״‬

View

History

,‫;ן‬,'‫׳״‬

Bookmarks ,'

Tools

Help

: : /http://www.1qfeed.net

Snagit 123' j I Windowjautoscroll] v Ask for File Name #

iOFEED If you want customer service that answers the phone, your best bet is IQFeed. I cannot stop praising them or their technical support. They are always there for you, and they are quick. I have used ****** too but the best value is iQFeed." - Comment from Public Forum "With HUGE volume on AAPL and RIMM (or 2 days, everyone in a trading room was whining about freezes, crashes and lag with **»‫**״‬, RealTick, TS and Cyber. InvestorRT with IQFeed was rock solid. I mean SOLD!" - Comment from Public W e l c o m e to IQFeed! You are about to find out how nice it is to work with a company like DTN! It all starts with our Sales Reps who will make sure you are setup with the data you need at the best price possible. We know you expect "service after the sale" too! Our 800M Customer Supportl'me is nearly always answered on the first ring, we respond to emails within 1 hour, and we offer real-time chat on our website. You won't find a company more committed to ensuring your success as a trader/ A b o u t IQFeed

For T r a d e r s 13

For D e v e l o p e r s

Have a Q u e s t i o n for S a l e s ? Call 800-475-4755 Email [email protected]

D

mm

GUCKTOCHAT

ONLINE

NMI

Support

i

Developers

— Sen/ices

Symbol Guide

Fees

/ /

Compatible S o f t w a r e G e t F r e e Trial N o w Add S e r v i c e s $ 1 0 0 Referral Credit

'

Symbol Look-Up

Developer Login Developer Registration

4

Download Client Support F o r u m s Live C h a t Contacts Other Products

ONLINE

2. Click Get Free Trial Now. Complete the application forms. The trial is exactly the same as the subscription version. The trial turns into a subscription at the end of the trial period, unless you call to cancel it. DTN will send an e-mail with your User ID and PIN. 3. Return to that web site and Click Download Client. The current version is a file named iqfeed_client_4_4.exe, and is about 3 MB.

Installation 4.

49 ‫ו‬

Run iqfeed_client_4_4.exe. Accept al I the defaults. When you click finish on the final screen, the iqfeed program will be installed on your computer. f IQFeed Client 4.4.0.3 Setup

ffih

D ' ‫ ' ״‬SI

W e l c o m e to the IQFeed Client 4.4.0.3 Setup W i z a r d This wizard will guide you through Ihe installation of IQFeed Client 4.4.0.3. It is recommended that you close all other applications before starting Setup, This will make it possible to update relevant system files without having to reboot your computer, Click Next to continue.

|

Next >

j

[

Cancel

|

To set up an AmiBroker real-time database using DTN IQFeed: 1.

In AmiBroker, using the File menu, select New, then Database.

Working in the top half of the box: 1. In the Database folder box, enter the name you want for your new real-time database. 2. Check or uncheck, as you wish, Load this database at startup. 3. Click Create.

Introduction to AmiBroker 1w working in the bottom half of the Database settings box: 1. Pull down the Data Source menu and select DTN IQfeed data Plugin. 2. Click Enable local data storage. 3. Enter 25000 for number of bars. 4. Pull d o w n the Base Time Interval menu and select 1 minute. 5. Click Configure. The configuration menu will appear. 6. Note that DTN IQ has a bad tick filter. Accept the defaults. Click OK Return to the Database settings screen. 7. Click OK. Database settings AmiBroker database maintains infromation about symbols, industry groups, watch lists. It is necessary even if you are using external data General Database folder:

Installation The IQ Connect Login will appear. 8. Enter your Login. 9. Enter your Password or PIN. 10. Click Connect. Your computer will communicate with the DTN IQ server. IQ. Connect Login

g]

4.4

‫ ־‬Login: ]229999

— P a s s w o r d or P i n : j****

Quit

F~ S a v e L o g i n A n d P a s s w o r d / P i n F

Automatically Connect

Idle

As your agreement for the receipt and use of market data

‫י׳‬

provides, D T N , the Securities Markets and Content P r o v i d e r s (1) r e s e r v e all r i g h t s t o t h e d a t a t h e y m a k e a v a i l a b l e ; (2) d o n o t g u a r a n t e e t h a t d a t a ; a n d ( 3 ) s h a l l n o t

To bring up a chart: 1. Using theAmiBroker Symbol menu, select New. 2. Type in a symbol, say SPY.

m

Enter a new symbol name Enter one or more tickers to odd (comma separated)

1 1

1

1 Cancel

1

51 ‫ו‬

Introduction to AmiBroker

52

In a few seconds the chart will appear. Add other symbols, open the Realtime Quote Window, and continue. A AmiBroker - [OQQ.Q - POWERSHRS QQQ TR SR1 ETF - 1 -minute] ‫& צ‬le

Format

Edit



y0

Symbols

‫ן‬ ‫י‬

%

x

Symbol 0

l-M

Analysis O 3

Xools

Window

QQQQ

;

Help

‫׳י‬.,

ft ‫־‬fe‫׳‬

!

Ss A S>

ihdwm

9,i.



<

Undefined, Undefined, Services, Advertising # IQ RealTime

01:

••

‫״‬

Installation

53 ‫ו‬

T I C K DATA

Tick data refers to market data that represents the time and transaction price, and perhaps the volume, of every trade. Depending on the exchange and the data vendor, the tick data stream may also include other information, such as changes in the bid price, the asked price, the volume on each side. Just as it is possible to make display bars that represent a given amount of time, say 1 minute, it is possible to display bars that represent a given number of ticks, say 15 ticks. In the opinion of this author, tick data is not appropriate for use by individuals and small trading companies. The highest quality tick data includes an information packet for every transaction. Some of the difAcuities with tick data include: high cost; very high volume of transactions; erroneous transactions (called bad ticks - see example below); dropping of transactions when exchange activity increases (fast market conditions) or when communications capacity is reached. . AmiBroker - [SPY - Sa P DEP RECEIPTS -1 -minute] 2 Eiie

Edit

yiew

Insert

Format

D«B0

Symbol

®

Analysis

Tools

Window

8 1 , SPY

Help

‫י‬,

m

SPY ( 1 - m i n u t e ) x °

J S P Y - l - m i n u t e 8 / 1 4 / 2 0 0 8 2:29:00 PM O p e n 129.72, Hi 129.76, Lo 129 69, C l o s e 129 7 ( - 0 . 0 % ) Vol 144,361 MA(CI0se,15)

i7i

130.20;

/ik

128.S3B0 •0

-t?

60

#

s u a 129 4 0

kSi 129.00 126.00 126 6 0 j 1fB/14/20Q8 9/14/20Q8'1 12:45 12:45 •

TFi^

rfMO

T345

!14:15

T^OO

•I \ S h e e t 1 ^ Sheet 2 ^ Sheet 3 '). s h e e t 1 \ 5heet 5 ). S h e e t 6 ^ Sheet 7 \ s h - s - I

Realtime Quote T‫״‬, £ Open XLB XLE XLF XLI XLK XLP XLU XLV XLY

39,64 72.90 20.46 35.07 23.41 28.54 37.17 32.91 30.04 •

' 1T3M : 9 0O

\\ |‫ ץ‬List

-eip, press F

High

Low

Last

Change

% Ch...

Volume

39.80 74.38 21.26 35.73 23,75 28.89 37.17 33.57 31.28

39.06 71.36 20,38 34,89 23,28 28.35 36.65 32.89 30.01

39.48 72.32 21.05 35.47 23.66 28.74 36.87 33.41 30.97

‫־‬0.20 -1.18

‫־‬0.50% ‫־‬1.61%

8,075,...

0.48

+2.33%

0.15

+0,42%

0.20

+0,85%

0.17

+0.60%

90,46... 5,628,... 3,419,... 3,427,... 2,594,.,, 2,453,... 4,008,...

/ L i s t 2 V List 3

‫־‬0.27

‫־‬0.73%

0.11

+D.33%

0,57

+1.87%

\List4\ LBt5X

Trad...

28,17...

List 6 \ List 7 \ List 8

X: 8/14/2008 1:06:00 PM, Bar: 2491 Y: 129.5398

150 100 500 100 200 100 110 100 100

X u<

<

Bid

Bid size

Ask

39.47 72.32 21,04 35.47 23.66 28.73 36.87 33.40 30.96

31

39.48 72.33 21.05 35.48 23.67 28.74 36.88 33.41 30.97

36

2,581 191 73 959 364 21 380

Asks...

52w ...

52v>.

9 3 356

128 1,199 77 25 804 185 ,‫נ‬

Undefined. Undefined, Services, Advertising > QP ReafTime

>::

jfc

54

Introduction to AmiBroker

Tick data is best used by larger organizations that have high capacity equipment, redundant data feeds, and staff devoted to monitoring and correcting the data. To use tick data in AmiBroker, the Professional version is requ i red. If you want to experiment with very frequent data, try working with 1 minute bars instead of tick data. This book will not discuss tick data further.

Chapter 3

30 Minutes to Useful Results

You have installed AmiBroker and the Data database. This chapter describes ten things you can do with AmiBroker - even while it is in Trial Mode - each in only a few minutes. •

Example 1 - Chart a Stock



Example 2 - Apply a Trendline



Example 3 - Plot a Moving Average



Example 4 - Make a Watch list



Example 5 - Run an Exploration



Example 6 - Run a Single Stock Backtest



Example 7 - Run a Portfolio Backtest



Example 8 ‫ ־‬Optimize a Trading System



Example 9 - Perform Walk Forward Validation



Example 10 - Scan for Buy and Sell Signals

None of these is intended to be a complete description of the features used in the example. But working through them should give you a bet55

56

Introduction to AmiBroker

ter feeling for the capabilities and ease of use of AmiBroker, and provide some experience as you read about other features. Examples build. Later examples assume you can perform tasks described in earlier examples.

57

30 Minutes to Useful Results EXAMPLE 1 - C H A R T A STOCK

In this example, you will chart a stock, change its periodicity, chart a new stock, scroll, and zoom. ^

gg.

To start AmiBroker, either:

Mozilla Firefbx

Jasc Paint Shop Pro 8

PowerPoint

AmiBroker

A

iA



Double-click the AmiBroker icon that was placed on your desktop during installation.



Using the Windows Start menu, select AmiBroker, then AmiBroker.

©

S

Windows Explorer

Excel

lH

AmiQuote

J j ^ AmiBroker —— i l l Read M e Snaglt 8

| § | Release N o t e s

Dragon NaturallySpe..

[ | g User's Guide

AmiBroker will display the default chart window.

0le

Edit

yiew

Insert

Fermat

Symbol

Analysis

Q ^ B S I

OB,

Symbols

Window

Help

-

£.-

/ /

a • J I (Daily) » "DJI - Daily 8 / 3 1 / 2 0 0 7 O p e n 1 3 2 4 0 . 9 , Hi 1 3 4 7 2 3, Lo 1 3 2 4 0 . 8 , C l o s e 1 3 3 5 7 7 (0.9%) Vol 2 7 , 3 1 6 , 1

I 5ym.,, | Lay,,, j La a U All l«t LJ Markets & Cj Groups iji l_J Sectors ® U Watrh lists O Favourites 8

lools

" * 14,00• 13.178:2

I Indexes « "Oil

I2.837.1j

12,400;

12,000: 1

Interpretation

‫ז‬

x

1

Feb

1

Mar

Fen Help. pre ‫׳;׳‬, F 1

Jun

1

TJUT

Aug 180.0

120,0!

/Y

Price Date: 8 / 3 1 / 2 0 0 7

1

1

May

1 " D J I - M A C D ( 1 2 , 2 6 ) = - 4 9 1 6 , S i g n a l ( 1 2 , 2 8 , 9 X = - 8 2 64

Interpretation 'v :• :‫׳‬, :

Price a n d moving averages: A D J I ( p O W JONES INDUSTR) h a s closed a b o v e its S h o r t time moving average, S h o r t time moving average is currently below mid-tjme, AND below long time moving a v e r a g e s . The relationship b e t w e e n price a n d moving a v e r a g e s is: neutral in

1

Apr

80,01

JSfiijllllilllUUiii... ,

1

‫ יי‬I] || 111 ‫" י י‬111111 ‫י‬

1

If " ‫״‬

•DJI - R S I ( 1 5 ) = 51 59

vq

‫ יג‬pf

r va

w

M 1

..

Feb

‫ן‬.

‫\״‬i ‫׳‬ Hvlir

1

*Apr

1

May

1

‫ ־‬J u n

rJ 1

Jul

\ SHEET 1 J^ Sheet 2 ^ Sheet 3 ^ Sheet 4 ^ Sheet 5 ^ Sheet ‫ י‬s i - 1 NYSE, Git‫!׳‬.:

v 1

yy

Aug <

•vIvhm‫־‬t1:-.1ru|

The chart window has three panes. The top pane has the price of the Dow Jones Industrial Average in candlestick format. Applied to those

58

Introduction to AmiBroker

prices are several indicators - some moving averages and a set of Bollinger Bands. The middle pane has an MACD indicator. The bottom pane has an RSI indicator. The prices are from the data that is installed in the default database named DATA. The chart is displaying Daily data, one bar for each trading day. To display the data in weekly format, click the Weekly view icon in the View toolbar. 4 AmiBroker - [‫׳‬DJI - DOW JONES INDUSTR - Daily] E'le

Edit

‫ ם‬e & y @

!$ew

m

Insert

Symbol

Analysis

Iools

\A£indow

Help

X

Symbols

‫י‬

‫ ן‬Sym... j Lay...

Format

X x

jlay

M CA AH its • Markets ?1 LJ Groups » - C 3 Sectors !1 D Watch lists : i_J Favourites S LJ Indexes •

‫׳‬TOI

Interpretation Interpretation j Notepad Price Date: 8 / 3 1 / 2 0 0 7 Price a n d m o v i n g averages: A D3I(DOW JONES INDUSTR) h a s c l o s e d a b o v e its S h o r t t i m e moving average. S h o r t time moving a v e r a g e is c u r r e n t l y b e l o w m i d - t i m e , AND b e l o w l o n g time m o v i n g a v e r a g e s . T h e relationship b e t w e e n pr r i c e a n d m o v i n‫ע‬g

,

a v e r a g e s is: n e u t r a l in

v

1

Feb :

I

1

Mar



1

Apr

May

1

Jun

Qui

'Aug

M \ S h e e t 1 ^ Sheet 2 ^ Sheet 3 ^ Sheet 4 ^ Sheet 5 \ Sheet- s M

Weekly quotation view

<

NYSE, Group 4, Services, Advertising

To choose a new symbol to plot: 'L AmiBroker - [ ' D J I - DOW JONES & File D

Edit

»‫ ־‬H @

View #

Insert

Format

Symbols

9 x

; Symbols j layouts 1 layers j Charts. j

# AXP # BA # CAT #‫ ׳‬DD $ ]WAIT DISNEY-DISNE^ # GM

$ HD # HON # HPQ

Symbol

^

‫*־""" י י‬

£ ‫״‬

DJI

1. Click the Symbols tabbed menu. 2. Expand the All category by clicking on the + sign. The list will expand to show all of the ticker symbols in the database. 3. Click one of the entries, say DIS.

30 Minutes to Useful Results

59

Since the charts were last displayed using weekly bars, they remain in weekly bars when the new symbol is plotted. Return the chart to daily bars by clicking on the Daily view icon in the View toolbar.

Using the Scroll Bar in the lower right corner of the window, scroll back in time (to the left) to display earlier data. 70.D

/A W 1AL / ^ xjJA V y M 1

1

Jul

Xsh‫־‬s,S \-

5

.,

Aug <

, Recreational Acth • Data

•m

o

h d

30.0

= HHV( H i g h , N e w l O D a y L o w = L o w | | Report.

r]

Explore Optimize

j !‫ך*־‬

F i ! 1 ' ‫־‬

‫ו‬

h I 1

|

Parameters ] j

Settings...

j

Class

Results

‫ש‬

| Ticker

Date/...

10 D a y High

10 D a y Low

;Ready

1.

Click Explore. L. Automatic Analysis - Example5.afl Formula file

] 0

jC:\Program Files\AmiBroker\Formulas\Custom\Example5.afl

|

Apply to

Range

Q a l l symbols

O all quotations

[

O current symbol ®usefilter

O ‫ ח‬last quotations

| Back Test

[ Define..

| Run every:



Du

# DIS 4 EK # GE • GM 0 HD F HON * HPQ

Note that the bottom pane will show the new price chart and the equity curve that results from applying that trading system to that symbol. It is not necessary to click Backtest ‫ ־‬when the new symbol is selected, all of the indicators in all of the panes are recomputed and re-displayed, including the result of applying the trading system. The final equity is in the green box in the right-hand margin.

>

B A - C = 93 2 1 , e q u i t y = 1 2 . 9 1 2 17

, //VS,,/1"' ws^f• Feb

n®r

104.0

p g g i

W f•‫־‬

°

0 5 / 96 0 92.0 80.0

f h 1

108.0

1

Apr

Exit AmiBroker.

‫׳‬Miy

Tun

Qui

1

Aug

30 Minutes to Useful Results

87

EXAMPLE 7 - RUN A PORTFOLIO BACKTEST

This example will apply a trading system to a portfolio and view the portfolio equity. Start AmiBroker. Using the Formula Editor: 1. Open Example6A.afl. 2. Change it to make it agree with the program shown below. 3. Save the new program as Example7A.afl. '

L. [C:YProgram Files\AmiBroker\Formulas\Custom\Examp.. I

Eile

Edit

D t f U

Ioob

Help

#

151

*‫י‬

«

Example7A

‫ * ׳>״‬9 ‫״‬

// // // // if //

Example7A.afl A t r a d i n g system based on the c r o s s o v e r of two moving a v e r a g e s . Buy when t h e f a s t e r moving a v e r a g e c r o s s e s up through the slower moving average.

// // /'/

S e l l when t h e f a s t e r c r o s s e s down t h r o u g h moving average.

// //

This version for use with

Buy = Cross( Sell = Cross(

!

moving average the slower

adds m u l t i p l e a portfolio.

SetOption( "MaxOpenPositions", P o s i t i o n S i z e = 2 / •10‫;־‬ F a s t M A = M A ( C, S l o w M A = M A ( C,

Is 1

positions

2

);

5 ) ; 20 );

FastMA,

S l o w M A );

SlowMA,

S a v e the file

FastMA

);

Ln 12, Col 1

4. Click the Analysis icon. ExampleTA is loaded into Automatic Analysis as the Formula File. 5. In the Apply to area, check Use filter. 6. Click Define. 7. Clear all fields. 8. On the Include tab, Watchlist entry, select Basic Materials. 9. Click OK. 10. In the Range area, check All quotations.

Introduction to AmiBroker 11. Click the Settings button. The Backtester Settings dialog box will open. 12. Click the Report tab. 1) Click Trade list. 2) Click OK. Backtester settings General: T r a d e s

Stops ; Report Portfolio :'Walk-Forward i

Reporting Result list shows:

@ T r a d e I1f?t

‫״׳‬

O Detailecnog O Summary Risk-free rate for Sharpe ratio:

j5

Distribution charts spacing (%)

j5

0 MAE/MFE distribution charts (Professional Edition only) ‫ ח‬Generate detailed reports for each symbol in individual backtest (slow) |v1 Include trade list in the report @ Warn before running time-consuming optimizations

13. Click Backtest. The Results window shows trades. , Automatic Analysis - Example7A.afl Formula file ; i C:\Program Files\AmiBrokeAFormulas\Custom\Example7A afl

O a " symbols

;

Pick ] | Edit

Range

Apply to Q current symbol : ®usefilter

Scan

! {«> all quotations O

, |

Def

n

O n last d a y s Qfrom:

n Run e v e i y

to:

• Wait for backfill (RT only)

Explore

Back Test :‫]־׳י‬

‫׳‬Qst quotations

Beport..

: 7/ 1/2004

‫יי‬

]

Optimize

j"]

File

‫|׳י‬

V

Eguity

v

*

[ 1/ 1/2007

Parameters

Fl Sync chart on select

'I

Settings...

|

Close

Results

|

‫ש‬

Ticker

Trade

AA DD XOM AA XOM AA AA DD DD XOM XOM XOM IP IP XOM IP IP XOM IP AA AA

Leng Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long Long

Date 11/1/2004 11/2/2004 1/18/2005 3/17/2005 1/7/2005 4/11/2005 5/9/2005 5/6/2005 5/20/2005 5/31/2005 7/8/2005 7/25/2006 7/20/2005 8/11/2005 8/11/2005 8/22/2005 9/7/2005 9/1/2005 10/27/2005 10/24/2005 1/27/2006

Price

Ex. date

31 87 41.09 50.22 30.9 59.62 30.51 28.88 46.42 45 73 55.35 58.5 59.03 31.64 30.91 60 32 30 74 30 91 61 04 27 91 2368 31.15

!1/3/2004 1/7/2005 3/15/2005 3/23/2005 4/13/2005 4/15/2005 5/11/2005 5/13/2005 5/25/2005 6/30/2005 7/18/2005 8/4/2005 8/9/2005 8/15/2005 8/19/2005 8/23/2005 9/22/2005 10/4/2005 1/5/2006 1/17/2006 2/21/2006

Ex. Pr.. 3127 4545 59.13 29.75 57 96 28.68 27 95 45.02 45 49 566 57 27 57,63 30.9 30 68 58 21 29 92 29 96 59 92 33.39 2898 38 2

%chg

Profit

% Profit -1 88% 10.61% 17 74% -3.72% -2.78% -600% -3.22% -3.02% -0.52% 2.26% -2.10% -2.37% -2.34% -0.74% -3.50% -2.67% -3 07% -1.83% 19 63% 22 38% -3 05%

-1:8854 " -94 13 530.51 10 61% 17 74% 925 81 -3.72% -211.43 -155.24 -2 78% -6.00% -332.05 -171 69 ‫־‬3.22% -3.02% -‫ ו‬60 80 -0.52% -27,1 ‫ו‬ ‫ ו‬16.35 2,26% -2.10% -‫ו‬09.55 -2.37% -120.61 -2.34% -120.57 -074% -37 46 -176 12 -3,50% -2.67% -131.45 -3 07% -148.55 -1 83% -89.22 19 63% 931 32 22 38% 1.061.64 -3 05% -175.05

>

e ;(38 rows) Profit = 1439.75 ( 1 '4.40%), CAR 4,62% ‫ ־‬. MaxSysDD 1 9 . 1 8 % - ) 2 2 4 1 . 9 0 - ‫־‬

St 151 12 10 18: 93 18‫־‬ 18. 11• 11: S3 89 86. 16: 16: 83. 161 151 79. 16! 21 1B•

)

. CAR/MDD 0.24 ‫ ־‬. *winners 2 ) 1 0 ‫ ־‬E

89

30 Minutes to Useful Results

Looking carefully at the results, there are times when there are two positions, times when there is only one, and times when there are none. When processing a portfolio backtest, AmiBroker starts out with 100% cash and knows the maximum number of positions it can hold simultaneously (2 in this case). The code in ExampleTA tells AmiBroker to divide the available f u n d s into two, giving each 50%. The trading system is applied to each of the ticker symbols in the watchlist. When the first (in chronological order) buy signal occurs, one position is taken and as many shares as possible are purchased with 50% of the funds. Whenever there is a sell signal for that symbol, those shares are sold and the cash made available for another purchase. In the mean time, when the next buy signal occurs, the remaining 50% is used to buy shares in that stock. The buying and selling, using f u n d s and returning funds, continues for the length of time specified. Plotting the portfolio equity gives a graphic view of the process. 1.

Click the Equity button. ‫״‬£, Automatic Analysis - Example7A.afl C:\Program Fi!es\AmiBroker\Formu!as\Custom\Example7A.afl Apply to

Range

O

© a l l quotations

symbols

O current symbol ©usefilter

1

Scan

] | [

O n last quotations I Defini

O n last d a y s Ofon1‫׳‬:

[ I ] Run eveiy •

Wait for backfill (RT only)



Sync chart on select

Beport... 7/ 1/2004

Eflui

1/ 1/2007

"

Explore

K

AA DD ; XOM AA

Trade Long Long Long Long

^Ptek

-‫~־־״־‬mfr

File Settings



Results Ticker

‫*־‬,j

Qptimize

Date

Price

Ex. date

11/1/2004 11/2/2004 1/18/2005 3/17/2005

"31 87 41.09 50.22 30.9

11/3/2004 1/7/2005 3/15/2005 3/23/2005

Ex. Pr... 31.27 45.45 59.13 29.75

% chij

Profit

-1.88% 10.61% 17.74% -3.72%

-94 13 53051 925 B1

% Profit

St

4 88% 151 10.61 So 12 1 ?74% 10 72% 3• 43 211‫ ־‬IB

A new pane opens at the bottom of the chart window. The two positions are evident, one above the other. When a stock position is held, the plot is blue. When cash is held, the plot is green. The chart shows the ebb and flow of positions - sometimes two, other times one, other times none. The dark brown area at the bottom shows the drawdown. For this run, the final equity was $11,439. The d r a w d o w n when the test period ended was $831. Drawdown is the decrease in equity from the highest high equity value.

90

Introduction to AmiBroker i W - 1 •.••• -

B.000

-

4.000

-

2.000

-

0

Final Equity

B B E 1

Drawdown Blue Securities Held

Green Cash Held

To read the report for this run, click the Report button. This run was made allowing a maximum of two simultaneous positions. The code can be modified to study the effect of allowing fewer or more positions. Using Formula Editor, modify Example7A to agree with the code that follows, and save it as Example7B.afl.

File

Edit

• (£ U

l o o Is #

*

Help % §§

*‫י‬

Example7B

‫׳ נ־&• ׳>״‬

// // if // // //

Bxample7B.afl A ‫־‬trading system c r o s s o v e r of two Buy w h e n t h e f a s t crosses up throug average.

// // /./ // /I

S e l l when t h e f a s t e r moving a v e r a g e c r o s s e s down t h r o u g h t h e s l o w e r moving average. This version adds m u l t i p l e p o s i t i o n s for use with a p o r t f o l i o .



‫_ ׳‬

ba3ed on the moving averages. e r moving average h t h e slower moving

N u m P o s = 3; SetOption( "MaxOpenPositions", PositionSize = - 1 0 0 / NumPos;

NumPos

) ;

F a s t M A = M A ( C, 5 ) ; S l o w M A = MA( C , 20 ); Buy Sell

‫־‬ =

Cross( Cross(

FastMA, SlowMA,

SlowMA FastMA

Print t h e active d o c u m e n t

); );

Ln 1, Col 1

Now just change the value of NumPos, click Analysis, and look at the equity chart. Exit AmiBroker.

30 Minutes to Useful Results

91

EXAMPLE 8 - OPTIMIZE A TRADING SYSTEM

In this example, the moving average crossover system introduced in Example 6 is studied in more detail. The values for the two moving average lengths were guesses. In this example they will be chosen through an optimization process. An optimization is an organized search, done in such a way that a large number of alternative values of parameters are considered. For each set of values, the trading system is tested. The report produced at the conclusion of the optimization lists the profitability and other statistics for each of the sets of values tested. The hope is that the best set of values will continue to be profitable in the future. Start AmiBroker. Using Formula Editor: 1. Open Example6B.afl. 2. Change it to agree with the code shown below. 3. Save the new program as Example8A.afl. L [C:\Program Files\AmiBroker\Formulas\Custom\Examp... Eile

Edit

D 0? y // // // // // // // // // //

Ioote

Help

#

m

*‫י‬

‫׳‬

:

ExampleBA

‫׳‬

Example8A.afl A trading system based on t h e c r o s s o v e r of two moving averages. Buy when t h e f a s t e r moving a v e r a g e c r o s s e s up through the slower moving average. S e l l when t h e f a s t e r moving a v e r a g e c r o s s e s down t h r o u g h t h e s l o w e r moving average. Parameters are introduced.

FastMALength SlowMALength

= =

FastMA =

MA(

C,

FastMALength

MA(

C,

SlowftALength

jSlowMA Buy

=

Sell p l o t (

=

Cross( =

Cross(

C,

"C",

5; 20;

FastMA, SlowMA,

); );

FastMA

colorBlack,

e = Equity(); P l o t ( e, "equity",

Formula n a m e

SlowMA

);

);

styleCandle

colorGreen,

);

styleXine

|

styleOwnScale

);

Introduction to AmiBroker

92

Compare the statements that were changed. Example6B:

FastMA = MA ( C, 5 );

Example8A:

FastMALength = 5; FastMA = MA ( C, FastMALength);

A numeric value is assigned to a variable FastMALength, then that variable is used to calculate the moving average. Computationally, Example6B and Example8A are the same. But using the variable gives some flexibility. OPTIMIZE FUNCTION

AmiBroker has a built-in function, Optimize, that has this format: V = Optimize ("Name", Default, Initial, Final, Increment);

• •

V is a variable that will be assigned one value at a time, and a series of values as the search takes place. Name is the name of the variable as it will appear in the reports.



Default is the value that will be assigned to V if the run is only a backtest (or Explore or Scan), not an optimization.



Initial is the first value to be tested during the optimization.



Final is the last value to be tested.



Increment is the step taken from one iteration to the next.

For e x a m p l e , V = Optimize ("Length", 5, 1, 20, 1);



If only a backtest is being run, V will be assigned the value 5.



If an optimization is being run, V will be assigned 20 values, one for each optimization pass. The first will be 1, then 2, then 3, and so forth, with the final value assigned to V being 20. From 1 to 20 in steps of 1.

EXAMPLE8B.AFL

Using the Formula Editor, modify Example8A so that it agrees with the code shown below. Then save it as Example8B.afl.

30 Minutes to Useful Results

L

93

[C:\Program Files\AmiBrakertFormulas\Cu5tom\Examp... Q Eite

Edit

D G? U

loots m

Help

$

fe®

*‫״ז י‬

ExampleBB

Ky>®~

// // // // // //

Example8B.afl A t r a d i n g system based on the c r o s s o v e r of two moving a v e r a g e s . Buy when t h e f a s t e r m o v i n g a v e r a g e c r o s s e s up through t h e slower moving average.

// // // //

S e l l when t h e f a s t e r c r o s s e s down t h r o u g h moving average.

// // //

This v e r s i o n can be optimized to f i n d t h e b e s t v a l u e s f o r t h e two moving average l e n g t h s .

FastMALength = SlowMALength =

Optimize( Optimize(

"FMA", " 3MA",

=

MA(

C,

FastMALength

SlowMA

=

MA(

C,

SlowMALength

Sell

=

Cross( =

Cross(

P l o t ( C,

"C",

FastMA,

SlowMA

SlowMA,

e = Equity(); P l o t ( e, " e q u i t y " ,

5, 1, 2 0 , 2,

31, 30,

2 2

); );

.



styleOwnScale

);

); ); );

FastMA

colorBlack,

‫ ׳‬-

moving average the slower

FastMA

Buy

f

);

styleCandle

colorGreen,

);

styleLine

|

Redo the previously u n d o n e action

Note there are two Optimize statements. The first will assign values from 1 to 31 in steps of 2 to the variable n a m e d FastMALength. The second will assign values of 2 through 30 by steps of 2 to the variable named SlowMALength. There are 16 different values in the first statement, 15 different values in the second statement. To do the complete search, FastMALength will be set to 1, then all 15 values of SlowMALength tried; following that, FastMALength will be set to 3, then all 15 values of SlowMALength will be tried; and so forth until all 240 combinations have been tested. To perform the Optimization test, in Automatic Analysis: 1. In Formula File, load Example8B.afl. 2. Load CAT as the current ticker symbol. 3. In Apply to, click Current symbol. 4. In Range, set the From date to 7/1/2004. 5. In Range, set the To Date to 1/1/2007. 6. Click Optimize.

94

Introduction to AmiBroker ix Automatic Analysis - Example8B.afl

I

Scon

[ Back T e s t 1

|



Parameters

Pick

||

j

Explore

-‫־‬j I

Edit

Qptirmje

•1 |

File 1

• | |

Settings

|

Close

| 'j'1

₪ 20 1 36 1 37 38 21 19 70 5 33 2 17 23 10 <

Net % Protit

Exposure %

CAB

RAR

111.54 79.87 7646 7393 71.72 71.40 6885 64 73 5986 5576 5336 51 99 51 61 51 39 49.55

42 02 42.88 41 85 5 3 34 41.34 4014 40 48 4425 39.79 41 34 55.06 47.17 5540 39.79 37.56

3843 29 02 27 95 2715 26 45 2635 2553 24.19 2258 21 21 2039 19.93 19 79 19.72 19 08

9144 67 68 66.78 50 90 63 98 65.64 63 06 54 66 56 74 51 30 37.04 4224 35.73 49.56 50.80

11,15420 7.987.36 7.615 61 7.392.98 7.17218 7.139.61 6.88511 6.47293 5.985 59 5,57568 5.33569 5.199 32 5.160.86 5.139.33 4.95463

Max Trad -1.B20 09 -2.965.61 -1,199 83 -2.881.61 -2.054.86 -2,096.10 -2.31475 -1.10318 -1.781.53 -2.603.77 -61951 -2.178.75 -838.41 -2,09872 -1.987.13

Wax. Trad -9 5 0 -‫ ו‬4.52 - ‫ ו ו‬34 -14.52 -14 94 -13.20 -1138 -9.50 -13 20 -1176 -5 05 -1152 -5.39 -14 25 -143B

Max S y s -3.06452 -2.965.64 -2,551.97 -3.259.96 -2.391.20 -2,096.10 -2.11510 -2.62496 -1 781.53 -3.183 61 -1.628 39 -2.478 75 -1,736.33 -2.096 72 -1,987.13

liiill

:Number of rows: 240

The Results window will fill with 240 rows, one for each combination of FastMALength and SlowMALength. Sort the results according to some measure of the goodness that you like. In general, the measure of goodness is called a fitness function or an objective function. There are several fitness functions in the resuits that both reward equity growth and penalize drawdown. These include CAR/MDD, RAR/MDD, RRR, Ulcer Performance Index, and Kratio. The results, sorted by RAR/MDD are shown in the next image.

30 Minutes to Useful Results

95

Click the header of any column to sort by that column. IT

L Automatic Analysis - ExampleSB.afI 1

Formula tile

1 [ Pick]

C:\Program Files\AmiBroker\Formu!as\Custom\Example8B afl Apply to

Range

0 B.I! symbols

O all quotations Q n last quotations

(*)current symbol O u s e ti Iter

I

Define...

Q R u n every:

|

5minl

O n last d a y s

| 2

""

® f r o m : 1/2004 /7 ‫ן‬

V:

Q Edit

|

Explore

| gack Test

‫| ־״־‬

Optimize

1 ‫׳‬.

-

1 1

V

| V 1/2007

to:

Q Wait for backfill (RT only)

Scan

I

j ‫י‬

I

:..,...

‫ה־ר־‬ LU

Recovery

-15.44 -14.52 -14.61 -13.20 -15.01 -15.23 -12.43 -11 56 -17 43 -9.77 -13 20 -13 20 -13.23 -14.3B -14.25

|

File

LI Sync chart on select

< Sys.

mm

CAFVMDD

3 64 2.69 3 41 3.36 2 85 3.00 2 80 2.99 2 99 3.28 3.04 2.62 2.51 2 49 2.45

RAR/MDD

2 49 200 1.80 1.71 170 1.74 ‫ ו‬33 1.60 1.60 2.09 1.44 1.30 1.32 1.33 1 38

^ ‫ ' ־‬P r o f i t Factor 5 92 466 449 4 30 4 20 4 20 408 4 04 3 83 379 3.61 3.60 354 3.53 348

Payoff Ratio

3 44 233 3 42 2.24 2 76 2.71 6 85 2.25 2.23 1.72 2.20 3.40 3.13 2.88 2.94

1.35 0.73 0 98 1.19 0.99 090 2.16 1.35 0.98 2.05 1.30 1.13 0 87 075 1.08

Standard ..

RF

1.023 79 1 015 34 51873 558 75 584 17 600.27 34785 564 45 677 65 687 43 404 85 531.09 451 23 585.82 604 84

<

‫י‬

4 : 4 5. 3. 4 4 4 4 4 3. 5. 3. 4 ‫י‬ 3. v >

J

Number of rows: 240

Scrol I over to the far right and note the values of FMA and SMA that correspond to the best fitness value. They are FMA = 7, SMA = 4. L Automatic Analysis - ExampleSB.afI :C:\ProqramFiles\Arn1Broker\Formulas\Custom\Example8B.efl Apply to

Range

O ®1‫ י‬symbols

O a " quotations

,

current symbol (5)

O * O u s e filter [ j

Run every: [~| L • Wait for backfill (RT only)

n

j j Pick j [ Edit [ Explore Optimize

lost quotations

O ‫ ח‬last days ®from:

7/ 1/2004

I

Settings...

j

V 1/2007

• Sync chart on select

B

Results

I52 :66 !76 .91 40 :85 11 !24 !86 69 :06 :73 :94 91 :11 <

t of losers

% of Losers

L Tot. Loss

L. Avg. Loss

13 12 6 17 9 9 6 15 18 31 19 5 5 6 7

28 26 24 00 22 22 34 69 26 47 25.00 24 00 37 50 30 51 54 39 37 25 26,00 21 74 20.69 26.92

-4.575.35 -6.019.73 -2.948 70 -4.820.87 -3.909 51 -4,183.41 -760.38 -3.82514 -6.227 60 -7,385.95 -4,137.23 -1,031.02 -2.118.45 -2,635.39 -2,652.17

-351 95 -501.64 -491 45 -283.58 -434.39 -464.82 -126.73 -255.01 -345.98 -238.26 -217 75 -366.20 -423 69 -439.23 -37888

L Avg %... -2 20 -300 -3 31 -2.10 -3.02 -3.27 -1 00 -2 14 -2.52 -1 77 -1.82 -299 -3,32 -3.58 -2 90

L Avg. Ba. 8.38 10.25 16.33 7,29 12.22 13.22 5.33 9.33 5 72 4.06 6 42 16.80 19.60 18.67 17.57

FMA

SMA

7 7 11 11 9 9 27 13 7 1 9 21 19 19 13

2 6 10 4 6 26 12 6 6 8 4 4 2 4

>

A

v

, .

Number of rows: 240

Return to Example8B.afl and enter those values as the defaults in the two optimize statements.

Introduction to AmiBroker

96

, [C:\Program File5\AmiBroker\Formulas\Custam\Examp... ]_ File ‫ם‬

Edit

^

‫ט‬

Tools



Help «o c*

i

Example8B

/! 11 // /./ //

Example8B.afl A t r a d i n g system based on t h e c r o s s o v e r of two moving averages. Buy when t h e f a s t e r moving a v e r a g e c r o s s e s up t h r o u g h t h e slower moving

// // //

S e l l when t h e f a s t e r c r o s 3 e s down t h r o u g h moving average.

// Ii //

This version can be optimized to find the b e s t v a l u e s f o r t h e two moving average lengths.

FastMALength = SlowMALength =

moving average the slower

Optimize( Optimize(

"FMA", "3MA",

FastMA

=

MA(

C,

FastMALength

SlowMA

=

MA(

C,

SlowMALength

Buy =

Cross( =

Sell Plot(

FastMA,

Cross( "C",

C,

31, 30,

2 2

); );

); );

FastMA

colorBlack,

e = Equity(); P l o t ( e, "equity",

1, 2,

);

SlowMA

SlowMA,

7, 4,

);

styleCandle

colorGreen,

);

styleLlne

|

styleOvmScale

);

1. Save the program. 2. In Formula Editor, click Apply Indicator icon. Look at the chart showing the equity curve. It shows a final equity of $21,154. C A T - C = 75 77, e q u i t y = 2 1 , 1 5 4 . 2 0

‫ א‬v Vs1 " ‫י‬ A> r'1‫ '״‬W

7

Feb

‫׳‬Mar

85.0 BOO I E

<

15 0

"

V

70 0 65.0 1

Apr

' May

'Jun

‫ י‬Jul

'Aug

But the right side of the equity curve is flat. That is because the optimization was r u n up to 1/1/2007. The data from 1/1/2007 through the end of the file, 8/31/2007, was saved to do an out-of-sample test. 1. In Automatic Analysis, set the To Date to 8/31/2007. 2. Click Backtest. The final equity is $22,447. C A T - C = 75 77. equity = 2 2 , 4 4 7 . 3 3

-•F\tjf\ f ^ A,All

.w ‫ י‬J/‫׳׳‬

J

m l j N

‫ן‬

y!‫׳‬y

*5 0 70 0

' ..L

T T •

!1

\1‫•י־ד׳‬

‫ו‬

‫ו‬

1‫ו‬

/

‫״־־ד‬

‫־ז‬

select all of the letters in the old ticker, type in the new ticker erasing the old one, press The new symbol will be loaded.

For more details, see Chart Pane Context Menu, page 122.

Graphical User Interface 5 ‫ו ו‬ DEFAULT C H A R T

Figure 5.2 shows a typical default chart window. Every chart w i n d o w is a component of a Layout. You can have as many layouts as you wish. Figure 5.1 shows the chart window of a typical default layout. You have a great deal of control over what is included in your default charts and how they appear. Use the Tools > Preference menu to set your preferences. These two figures will be used as illustrations for this section. This layout consists of a single window with eight chart sheets. Each window can have as many sheets as you wish. Using the tabs along the bottom edge, you can select which sheet you want to be active. In Figure 5.2, Sheet 1 is the active sheet and contains three panes. A sheet can have as many panes as yoti wish. The upper pane contains the price in candlestick format, a simple moving average of the closing price with a short period, a simple moving average with a medium period, a simple moving average with a long period, a set of Bollinger bands, volume bars, an exponential moving average of the close with a short period, an exponential moving average with a long period, and interpretation code. The middle pane contains the MACD indicator, an exponential moving average of the MACD indicator, and interpretation code. The bottom pane contains the RSI indicator, an exponential moving average of the RSI indicator, and interpretation code. A C T I V E PANE

At any time, you wi 11 have one active layout, of which one window is active, of which one sheet is active, of which one pane is active. Saying that a chart or pane is active is the same as saying it is selected or has the focus. PRICE AND VALUE A X I S

At the right-hand side of each pane, there is a vertical axis. (See Figure 5.2.) It displays the price (if a price series is being plotted) or value (if an indicator or formula is being plotted). The colored boxes give the values of the last data point visible on the chart. They are color-coded to correspond with the color of the line that is used to plot them. Unless you turn it off in the Tools > Preferences menu, a box containing

Introduction to AmiBroker Tooltip (see Figure 5.2) will display information about that bar of that pane that is at the point of your cursor whenever the cursor is paused over any pane. D A T E AND T I M E A X I S

At the bottom of some panes is a date and time axis. (See Figure 5.2.) You have control over whether the dates are displayed, but they are always there and are used to synchronize the data displayed in each of the panes. To toggle the display of the dates on and off, see Chart Pane Context Menu, page 122. SCROLL T H R O U G H DATES

There are several ways to scroll (to change the date range of the data that appears in the pane): •

At the bottom, right-hand side you will see a scroll bar. (See Figure 5.2.) Clicking and holding the scroll bar, then moving your mouse, you will make different date ranges of data visible in the pane.



You can use the right and left arrows next to the scroll bar. Each click of an arrow scrolls by a single bar.



If your mouse has a wheel, rolling the wheel scrolls the window.

As the display scrolls, every pane of every sheet will be redrawn so that the date range displayed is the same in every one of them. Every pane will be rescaled so the data is displayed as efficiently as possible. (Just rescaled; all the calculation was done for all the dates before the panes were displayed the first time.) PANE SIZE

As you move your mouse slowly up and down, you will cross pane boundaries. When the cursor changes from an ordinary , ^ -Jui‫־‬ arrow to a set of two parallel lines with small arrows pointing up and down, you can click and drag the boundary to change the sizes of the panes separated by that boundary.

Graphical User Interface 5 ‫ו ו‬ ZOOM

There are several ways to Zoom (increase or decrease the number of bars of data being displayed). •

Use the icons in the View toolbar. (See Figure 5.1.)



Using the View menu, select Zoom, then In or Out.



View > Zoom > All will display all the quotes in your history file. View > Zoom > Range will zoom to the range you have set. (See Mark a Range, page 120.)

• •

Hold the Control key while rolling the wheel on your mouse. When you have the amount of zoom you want, click the mouse anywhere in the chart.

BAR INTERVAL (PERIODICITY)

There are several ways to change periodicity. •

Use the icons in the View toolbar. (See Figure 5.1.)



Using the View menu, select Daily, Weekly, or Monthly. If you have an intraday database, you can select any bar size that is the same as or longer than your base time interval. If the intraday bar size you want is not on the menu, you can define it using the Tools menu > Preferences > Intra-day.

When you change the periodicity for any pane, all panes on all sheets for the active chart window will be changed and synchronized. If you want to have different periodicities for the same symbol, open a second chart window, creating a multi-window layout. (Use the File menu > New > Chart.) The new chart will open with the same ticker. Change the periodicity as you wish. You can tile the windows so that you can see, for example, both the daily chart and weekly chart. You can save the tiled view as a new layout. Whenever you open that layout, the daily and weekly display will be loaded.

Introduction to AmiBroker SELECT A Q U O T E

Move your mouse to the date you are interested in and click anywhere in any pane. A vertical line will appear through all panes at the bar you selected. If that is close to, but not exactly the one you wanted, use the Keyboard Left Arrow and Right Arrow (the cursor keys) to move one bar at a time. The chart title will display the date (and time) of the selected bar. M A R K A RANGE

Set a bar range by either: •

Double-click one end of the range, then double-click the other end of the range.



Select the desired bar for the left (older) end. Press F12. Select the desired bar for the right end. Press S H I F T + F 1 2 .

The left end of the range will be marked with a vertical line and a small green bar at the bottom of that line. The right end will be marked by a vertical line and a small red bar at the bottom of that line. Once the range is established, double-clicking outside the range will extend the range in that direction. Double-clicking inside the range will move the closer end to the bar being double-clicked. Date ranges can be zoomed-to by using the View menu > Zoom. Date ranges can also be referenced from an AFL program using the functions BeginValue and EndValue. REMOVE THE RANGE MARKERS

Either: •

Press



Double-click either the left or right vertical line.

CTRL+F12.

Graphical

User

Interface

5

‫ו‬

‫ו‬

A D D A NEW PANE

Use one of these methods:

Layouts I Layers j Charts j Symbol‫;׳‬, j: m LJ Averages & C J Bands !» CJ Basic Charts /

Open Interest (futures)

/

s

s

/ Price (all in o n e ) / Price (foreign) /

Relative P e r f o r m a n c e

f

Volume

/

Volume (color)

/

Volume At Price

; 1 C j Custom LJ Equity CJ Include CJ Indicators ; £ £ j QTS Book Ss LJ QTS Book Code b: LJ Systems

To have that pane display a price series or a formula, use the Charts Tabbed menu, select the formula you want, right click it, click Insert. If you are planning to apply an indicator to the price series, select Price as the formula. Follow the first method, but double-click the formula you want (instead of right-click and insert). Alternatively, you can insert a new blank pane and then fill it later. Use the File menu > New > Pane. The new pane will appear as the bottom pane of the active window and will have no price or formula in it.

CLOSE A N Y PANE

Use one of these methods: •

|



Click on the pane you want to close to make it the active pane. Right-click, bringing up the context menu, choose Pane, then Close. Using the View menu, choose Pane, then Close.



Using the View Toolbar: 1. Click in the pane you want to close. 2 ;‫־‬. Click the Close Pane icon.

REORDER THE PANES

Right-click on the pane you want to move either up or down. From the context menu, choose Pane, then Move Up or Move Down. The pane will exchange places with the one next to it. To move a pane several locations, repeat the operation.

Introduction to AmiBroker

1 122

C H A R T PANE C O N T E X T M E N U j

Parameters Edit formula

x

Close Intraday

File selector window.



Close - Closes the current active document window.



Open Database - Allows you to open an existing AmiBroker database. Select the database folder and press OK.



Save Database - Saves the current database.



Save Database As - Saves the current database with a new name in a new folder.



Save - Saves the current document (account or HTML file).



Save As - Saves the current document with a new name.



Save All - Saves all documents currently open.



Database settings - Opens the database settings dialog that allows you to specify database parameters when setting up a database; or change your database parameters or intraday settings for an existing database.



Import Wizard ‫ ־‬Launches the ASCII Import Wizard window, that allows you to easily import ASCII (text) files into your database.



Import ASCII - Allows you to import ASCII files with use of

Graphical User Interface

‫ ו ו‬5

predefined import formats. •

Import MetaStock data - Launches the Metastock importer window. Note: The Metastock importer should be used only if you want to import MS data to a native, local AmiBroker database once. If you want AmiBroker to read the Metastock database directly on a regular basis, set up your database with the MetaStock Plugin.



Print - Print the currently displayed charts.



Print Preview - Displays how the information will look when printed.



Print Setup - Opens the Print Setup dialog box.



Send chart via e-mail - AmiBroker creates a .png image of the currently displayed chart and uses your default mailing program (e.g. Outlook Express) to send the file as an attachment.



List of AmiBroker databases. Click on any database name to open it. • QP End of Day • Data IntraDay DataAsDistributed



Exit - Closes the AmiBroker program.

Introduction to AmiBroker

1 34

EDIT MENU Edit \ View

Insert

Fgrmat

On Undo

Ctrl+Z

& %

Cut

Ctrl+X

Copy

Ctrl+C



Undo - Undo the last operation performed on chart studies such as trendlines. This option will be unavailable if no study has been drawn or moved.



Cut - Cut a study from the chart and hold it in the clipboard.



Copy - Copy a study from the chart to the clipboard.



Paste - Paste the contents of the clipboard to the current chart.



Delete - Delete a study from the chart without holding a copy in the clipboard.



Delete All - Delete all objects from the current chart pane.



Image Copy as Bitmap ‫ ־‬Copies the current chart window into the clipboard in .bmp format Copy as Metafile - Copies the current chart window into the clipboard in metafile format Export to file - Saves the current chart window in .png format to a disk location you choose Send by e-mail - Create a .png image of the current chart window and send it as an e-mail using your default e-mail utility



Delete quotation - Deletes the currently selected bar from the database for the current ticker symbol.



Delete session - Deletes the currently selected bar from all symbols in the database.



Properties - Opens a study properties dialog. (See Chart Pane Context Menu, page 122.)

•‫׳‬X X

Delete

Del

Delete All

Alt+Del

Image



Delete quotation Delete session

&

Properties

Image

Alt+Enter



Copy As Bitmap Copy As Metafile Export to file 0

Send by E-mail

Graphical User Interface

‫ ו‬35

VIEW M E N U View | pisert

+

F®‫־‬mat

Crosshair

Symbol

Analysis

!ools

‫ע‬

Crosshair — Turns crosshair on and off. Price chart style

Ctrl+H

j

Price chart style

0

Daily

>

Intraday

E



Weekly

Ctrl+W

«

Monthly

Ctrl+M

200 m

Line Line with dots

Ctrl+D

m

Auto

Candlesticks

Auto — Uses settings in Tools > Preference Line — Line chart Line with dots — Line chart with dots at closing price Candlesticks — Candlestick chart • Bars - OHLC Bar chart Intraday — Controls size of intraday bars and day - night sessions.

Bars •

History



Pane



Risk/yield map

E E

E E

Symbols Layouts Lasers Charts Interpretation Realtime Quote Alert Output Notepad Symbol Information l i m e a Sales Toolbars

Ml

Refresh

• F5

Refresh All

Day/Night h

Hourly

Ctrl+O



15-minute

Ctrl+6

Preference > Charting) Range — Displays the bars in the selected range Shorter bars — Reduces the vertical size of the bars Taller bars — Increases the vertical size of the bars

Introduction to AmiBroker (§

f-

History

Pane





O

Back

o

Forward

X

Ctrl+Alt+Left Arrow



History — Move back and forth between charts recently viewed in a browser-like way.



Pane Close — Closes the currently selected chart pane Arrange all — Arranges all the displayed charts Move down — Moves the currently selected chart down one pane Move up — Moves the currently selected chart up one pane Maximize — Maximizes the currently selected chart pane Restore — Restores the chart layout after using maximize Risk / yield map — Displays Risk / yield map of all the symbols in the database. Risk / yield map calculates average the weekly return (the yield) and standard deviation of the weekly returns (the risk) over at least 12 weeks. It requires at least 60 bars worth of data for every stock. To zoom in, mark the area with the mouse. To zoom out, simply click on the map.

Ctrl+Alt+Right Arrow

Close

no Arrange all Move Down Maximize





Symbols — Displays or hides the symbol tree (the Symbols tabbed menu) with categories.



Layouts — Displays or hides the Layouts tabbed menu.

Graphical User Interface

Toolbars

»

j Standard i j Ticker V j Tools ‫ • ד‬Format ; Draw

E View E Fibonacci & Gann IT • Status Bar

5‫וו‬



Layers — Displays or hides the Layers tabbed menu.



Charts — Displays or hides the list of charts, formulas, and indicators (the Charts tabbed menu).



Interpretation — Displays or hides the interpretation window



Realtime Quote —Displays or hides the real-time quote window



Alert output — Displays or hides the Alert O u t p u t window. The window displays messages generated by formula based alert.



Notepad — Displays or hides the Notepad window that allows you to store free-text notes about the active ticker symbol.



Symbol information — Displays or hides the Information window.



Time & sales — Displays or hides the time & sales window.



Toolbars Standard — Display or hide the standard toolbar Ticker — Display or hide the ticker toolbar Tools — Display or hide the tools toolbar Format — display or hide the format toolbar • Draw — display or hide the draw toolbar

Introduction to AmiBroker View — displar or hide the view toolbar Fibonacci & Gann — Display or hide the Fibonacci & Gann toolbar Status Bar —Display or hide the status bar •

Refresh — Refreshes the chart window.



Refresh all — Refreshes the chart window and re-reads the contents of all the categories in symbols tree.

Graphical User Interface 5 ‫ו ו‬ INSERT M E N U

The insert menu and the draw toolbar duplicate each other for many features. For more detailed description, see Draw Toolbar, page 154. Insert : Format S

!rend line

/ /

Raj

Symbol



Extended line

— I

»

Horizontal line



vertical Ibe Earallel lines Regression Channel Andrews' Pilrhfbrk Triangle

‫ם‬

Rectaogle

o

Ellipse



Horizontal line - Draws a horizontal line.



Vertical line - Draws a vertical line.



Parallel lines - Draws parallel trend lines.

Arc m

Cycle

d!>< Test tj

Zig-zag

1•

ArrQw Fibonacci Gann

» '

Trend line - Draws a trend line. Ray - Draws a ray - a right-extended trend line. Extended line - Draws a trend line that is extended on both right and left.

Regression Channel - Draws Raff, standard deviation, and standard error channels. Andrews' Pitchfork - Draws an Andrews' pitchfork. Triangle - Draws a triangle. Rectangle - Draws a rectangle. Ellipse - Draws an ellipse. Arc - Draws an arc. Cycle - Draws time cycles. Text - Places custom text. Zig-zag ‫ ־‬Draws a series of connected trend lines. Arrow - Draws a line that ends with an arrow.

Introduction to AmiBroker ::::::

Retracement

11!

l i m e zones

Ji-

Fan

‫׳‬si

Arc



Fibonacci studies Retracement Time zones Fan Arc Extension Time Extension Lines



Gann studies Fan Square

Extension HI

Sam

3

Time Extension Lines

Ean S3

Square

Graphical User Interface

‫ו ו‬5

FORMAT M E N U

This menu operates on the drawing tool that is active. The format menu and the draw toolbar duplicate each other for many features. For more detailed description, see Draw Toolbar, page 154.

Format | Symbol



Anal‫׳‬



Thick - Changes the formatting to thick.



Dotted - Changes the formatting to dotted.



Left extend - Extends the trendline to the left.



Right extend - Extends the trendline to the right.



Snap to price - Turns on the magnet that snaps the drawn studies to the prices. The snap to price % threshold can be set in the Preferences window. Snap to price % threshold defines how far price 'magnet' works - it will snap to price when the mouse is nearer than % threshold from H/L/C price.

Thick Dotted

V

Left extend

/

Right extend Snap to price

Introduction to AmiBroker SYMBOL M E N U Symbol

%

Analysis

!••is

Windc



New - Add new symbols to the database. After selecting this function you will be prompted for new ticker symbol. Symbols should be 26 characters or shorter and entered in all capital letters.



Delete - Removes the currently selected symbol from the database. Note that this operation can not be undone.



Split - Allows you to perform a stock split. The program will try to determine the split date and ratio by analyzing the quotations. If there is just a single quotation after the split this should work, if not you will be asked for a split date and ratio. You can specify a split using following expression: x->y which means that x shares before split become y shares after it. For example 2->3 means that 2 shares become 3 after the split. It is also possible to perform a reversesplit. For example 2->l, which means that 2 shares are joined together into 1 share.



Merge - This function allows you to merge two tickers. It is used when the ticker for the symbol is changed and in your database one symbol holds historical quotes and the second one holds newest quotes (after name change). Select the

New... Delete

¥

Split... Merge...

M

Find

e

Information...

F3

Quote Editor,.. Favourites



Watch list



Real Time Quote



Categories... Organize a s s i g n m e n t s . , , Qa leu late composites..,

Graphical User Interface

5‫וו‬

new ticker (after name change) and use Symbol > Merge. Then choose the original ticker ("merge with") and optionally check the following fields: overwrite duplicate quotes ‫ ־‬checking this option will overwrite the quotes already existing in "new" ticker with those present in "old" ticker (this should really not be the case, but may happen), delete "merge with" afterwards - checking this option will delete the "old" ticker after merging, assign alias name - checking this option will copy the "old" ticker to the alias field of the "new" ticker. •

Find - Opens the Symbol Finder window that allows you to quickly search the database for a symbol by typing the first letters of its full name or its ticker.



Information ‫ ־‬Opens the Information window for the symbol, which allows you to change the information related to the symbol.



Quote Editor - Opens the Quote Editor window that allows you to edit, delete and add quotations in your database. Note that you can edit the AmiBroker native database, but not the external database.

Introduction to AmiBroker • Favourites

• Remove selected symbol * Erase (make empty)

• If"

Wairh list



I Add selected symbol... Remove selected symbol.,. Iype‫־‬in symbols... Import... Export... Erase (make empty)... Sort alphabetically... Hide empty watchlists New watchlist... ‫ ־‬Delete watchlist...

Favorites Add selected symbol - Adds the current symbol to the Favorites category. Remove selected symbol - Removes the current symbol from the Favorites category. Erase (make empty) - Removes all entries from the Favorites category. Watch list Add selected symbol - Adds the current symbol to the watchlist you select. Remove selected symbol Removes the current symbol from the watchlist(s) you select. Type-in symbols - Add symbol(s) to a watchlist. Import - Import symbols to a watchlist from a .tls file. Export - Export the list of symbols in a watchlist to a .tls file. Erase (make empty) - Remove all symbols from a watchlist. Sort alphabetically - Sort the symbols in a watchlist into alphabetical order. Hide empty watch lists - In the symbol tree, show only those watchlists that are not empty. • New watchlist - Create a new watchlist. Delete watchlist - Removes

Graphical User Interface

5‫וו‬

the selected watchlists. Does not delete the symbols from the database. See Watchlists, page 179. Real Time Quote

Real Time Quote

Add selected symbol - Add the current symbol to the real-time quote list. Add watchlist - Add all the symbols in a watchlist to the real-time quote list. Type in symbol(s) - Type the symbols to be added. Insert empty line - Add an empty (separator) line. Remove all symbols - Remove all symbols from the real-time quote list. Categories - Opens the Categories w i n d o w that allows you to define the names of markets, groups, sectors, industries, and watchlists. (See Categories, page 177.) Organize assignments - Opens the Assignment organizer window that allows you to change the category assignments for symbols or to delete multiple symbols from the database. Calculate composites - Opens the Composite recalculation window that allows automatic calculation of number and volu m e of advancing/declining/ unchanged issues or volume numbers for indices.

Introduction to AmiBroker ANALYSIS M E N U

This is the workhorse menu of AmiBroker. After you have visually examined the chart and want to test the profitability of your ideas, you will use Analysis extensively. Each of these options has its own section in Chapter 9. analysis [1001s

yyridow

hi



Quick Review - Opens the Quick review window that provides overall market information like: daily symbol quotes, daily/weekly/monthly/ quarterly/yearly returns comparison table.



Automatic Analysis - Opens the Automatic Analysis window that enables you to perform explorations, backtests, optimizations, or scans.



Commentary - Displays the Commentary window which allows you to read comments generated by the technical indicators and describing the current conditions.



Formula Editor - Opens the Formula Editor window that enables you to write your own formulas.



AFL Code Wizard - Opens the AFL Code Wizard - Creates trading system AFL code from plain English sentences.

Quick Review.,, ‫י‬

Automatic Analysis...

&

Commentary...

A

Formula Editor.,.

S.

AFL Code Wizard

Graphical User Interface

‫ ו ו‬5

TOOLS M E N U



Database Purify - Checks the database to detect missing or extra quotes, possible splits or invalid OHLC relationships.



Indicator Maintenance - Opens the Indicator Maintenance wizard to clean up unused indicator space.



Bar Replay - Opens the Bar Replay tool which allows replay of historical data.



Preferences - Opens the Preferences w i n d o w which allows you to configure the AmiBroker program.



Save Preferences - Saves all the preferences changes (the information is stored in broker, prefs file).



Plug-ins - Opens the Plugins window. It contains the lists of all loaded plug-in DLLs. It can be used for inspecting which plug-ins are active and unloading unnecessary plug-ins.



Customize - Opens the Customize tools dialog which allows you to define custom tools that can be invoked from Tools menu.



Auto-update quotes - Invokes AmiQuote to update the historical quotes from the latest data in the file up to today.

Introduction to AmiBroker •

Sharenet Down loader - Launches the script which downloads the quotations from Sharenet (South Africa only).



Cleanup database - Launches the script that allows you to find non-traded stocks in the database. The script automatically scans the database and checks the latest quotation date. If it is old enough, the script will display warning message and let you decide whether the stock should be deleted or not. Additionally, the script can generate a list of "old" stocks and save it to the text file. The detailed information is available in the 05-2000 issue of the newsletter. (See Appendix C, Resources, for newsletter references.)

Graphical User Interface WINDOW

I Window | Help %

Cascade

Q

Tile Horizontally

Cascade - Cascades the open chart windows.



Tile Horizontally - Tiles the open chart windows horizontally.



Tile Vertically - Tiles the open chart windows vertically.



Arrange Icons - Aligns the windows nicely at the bottom of the AmiBroker window. Arrange icons works only if: You created more than two windows (via Window > New or Window > New Linked) • You have minimized them You moved the minimized boxes



Normal - Switches the chart window to "normal" (nonfloating) state.



Floating - Switches the chart window to floating state.



List of open windows. Click any entry to make it active.

_

Arrange Icons

113 Normal . Floating [ 7 | IQQQQ - POWERSHARES QQQ TRUST-UNIT SER 1 - Daily [

MENU



! [D Tile Vertically ‫ן‬

‫ ו ו‬5

: 2 SPY - SPDR TR-UNIT SER 1 - Daily



QQQQ



SPY

Introduction to AmiBroker

1 50

HELP M E N U



Help Contents - Displays the Contents page of the AmiBroker User's Guide.



Search - Allows you to search the User's Guide.



Tip of the Day - Shows Tip of the Day dialog where many useful usage tips are displayed.



Web Links - All open your default web browser AmiBroker Home Page - AmiBroker Home Page. Why Register - Purchasing and registering information. • Register On-line - Purchasing and registering information. Mailing list - Opens Yahoo AmiBroker Forum. On-line AFL Library - Library of AFL code, mostly contributed by users. AFL Function Reference - On-line reference for AFL functions.



Read Me - Using your browser, displays the contents of the Readme file describing features of the latest version of AmiBroker.



About AmiBroker - Shows the 'About‫ ׳‬window, which contains the information about program version and user details.

Help 1 ^ M

Help Contents Search Ti£ of the Day... Web links :: Read Me

f

About AmiBroker...

>

AmiBroker Home Page Why register? Register On-line Mailing list On-line AFL library AFL Function Reference

Graphical User Interface 5 ‫ו ו‬ TOOLBARS

A toolbar is a n a r r o w panel in a graphical user interface where buttons and icons can be placed. The icons are associated with m e n u s and programs, and the toolbar gives a convenient way of keeping c o m m o n l y used tools handy. All of the tools on all of the toolbars are available f r o m other menus. The toolbars are strictly for your convenience. The icons and p r o g r a m s shown in the screen capture images are the defaults. Add a n d remove icons to simplify your use of AmiBroker. Toolbars can be modified by the user: a d d i n g and removing icons as desired; undocked and re-docked in a more convenient location; in view or hidden. To set any of the toolbars to be in view or hidden, use the View menu, select Toolbars. TOOLS FOR GENERAL USE

Standard Toolbar • a* a m a - o © a, I I I I I I I I I I I I I jI

? c a 1 z * J i J > . ( u ( u « g j > < c u a . ‫״••־•־ כ ד‬

o

U

‫כד‬ ‫י‬-

o

w o c

Z

Ol/>‫״‬Q- u S. 4‫ ׳ כ‬rn 3 " - a •43 %

1/1

‫ם‬

o

gwa.

u_ - ‫ם‬

(!)U

>‫ §־‬s

Introduction to AmiBroker There are a lot of icons that can be added to the Standard Toolbar. Click the Toolbar Options icon to open the Add or Remove Buttons menu. [p] D ! p] ^ y 3rt

Format

© X

Symbol

Analysis

*‫•י‬

lools

Window

,SPY

h ‫ן‬

New

Ctrl+N

Open

Ctrl+O

Save

Ctrl+S

Save All

t

& ‫׳‬a

Help Topics About AmBroker Home page Save

Print

Ctrl+P

Cut

Ctrl+X

0

New database

Copy

Ctrl+C

a

Default Chart

Paste

Ctrl+V

Delete

a

Open Database

New Account

Del

e

New Web Research

Undo

Ctrl+Z

‫ם‬

New chart

Back

Ctrl+Alt+Left Arrow

a

New c h a r t Pane

Forward

Ctrl+Alt+Right Arrow

IS

Symbol information



Quote Editor

SI

Print Preview

‫ש‬

a m

Import Wizard

Click Toolbar Options to get to t h e choices a v a i l a b l e for icons

‫י‬ 1‫ > מ( > מ‬.

15 8 ‫ ״ • ״‬o 15 ‫״‬

E JS a, L. ‫ ע ו ו ן‬u E 3 5, ‫יי־‬ i f •5 o E -

*

‫ט < | ׳‬ o ‫׳‬

4

> ‫כ י ־‬

Graphical

User

View Toolbar •

» ₪ •

-

1 I I I I I I II

c

• nj — —

cOQ

1 .< .< < -< ‫״‬ -37: c c

2E ™I

S o t N

)

»

ra.o

> o ,a o

5 0 L

U S

Icons can be added to the View Toolbar. V‫׳‬ ‫ד‬ ‫׳י‬ v‫׳‬

Zoom in (+SHIFT zoom o u t +CTRL normal, +SHIFT+CTRL to ... Zoom out

e i

Ctrl+Num -

Intraday

Z

1

Hourly

Ctrl+O

d

Daily view

Ctrl+D

y

w

Weekly view

Ctrl+W

‫•י‬



Monthly view

Ctrl+M

E

e

New Web Research Close pane

‫״‬ Arrange charts ‫ש‬

+

©

i

Crosshair Refresh

Ctrl+H F5

Shorter bars

«

Taller bars

*

Day session

24 24-hours trading c

Night session

*

Day and night sessions

© ®

l‫־‬minute

Ctr 1+1

5-minute

Ctrl+5

15‫ ־‬minute Reset Toolbar

Ctr 1+6

Interface

5

‫ו‬

‫ו‬

Introduction to AmiBroker T O O L S FOR DRAWING

There are three toolbars that are used to place studies on price charts. They are the D r a w i n g Tools, Fibonacci and Gann Tools, and Formatting Tools. They m a k e placement and modification of studies very easy, and are much more efficient than using the Insert and Format pull-down m e n u s where they also reside. Toolbar Docking You can un-dock these f r o m their original positions and re-dock them a n y w h e r e you wish. To do that, move your cursor over the string of dots at the top of the toolbar; it will change to a four-direction arrow. Using normal drag and d r o p technique, place the toolbar wherever you w a n t it.

Draw Toolbar - Fibonacci Toolbar ‫ ־‬Format Toolbar The Drawing and Fibonacci Toolbars let you select and place a tool; the Formatting Toolbar lets you m o d i f y the properties of the study tool, such as color and line style.

s / / I

Select A r r o w is the first tool - at the top, or left if you have docked the toolbar horizontally, s h o w n as a Red Arrow. It is used to select objects that have already been d r a w n so that they can be moved or resized.

‫י ס‬

c m g ‫־‬o o ‫סו‬ t\ & i

To d r a w a study object on the chart:

H « A ) ‫׳‬

1. Select Select the the desired desired tool. tool c

= J

c

!111

(j

^

2. Move the mouse to the position you want to start drawing. V)

' o % o B t £I 4 ‫־‬ £ 11 ^ iZ — ro o ? E °

3. ‫־‬

Left-click the mouse.

. I f the d r a w i n g needs only one point, you will see the lines appear. If it needs a second point, move the m o u s e to the position you w a n t the second point. You can either hold the left button d o w n while m o v i n g the mouse, or not; either works. " 5. Left-click again (or release the mouse button).

Graphical User Interface

‫וו‬5

To modify a study object on the chart: 1. Select the study. Usually just hovering your mouse around the object is adequate. If there are multiple studies in close proximity using the Select Arrow to select the study. The control points will appear as small squares. These are used to resize the object. of the control meaning that middle of the meaning that

2. If your cursor is near one points, it will change to a two-direction arrow, the object can be resized. If your cursor is in the object, it will change to a four-direction arrow, the object can be moved.

The Format Toolbar has icons to: •

Change the color of the study.

^



Make the lines thick.

S



Make the lines dotted.

• •

Snap the study to the nearest price. Set the price using the Tools menu, select Preferences, on the Charting tab. Extend the study to the left.



Extend the study to the right.

‫ר‬

i

Preferences Charting

Colors

Editor

Date

Intraday

Miscellaneous

Alerts

AFL

::Currencies

General ‫ ןד־־ן‬Show vertical line between d a y s

0 Show v a l u e labels

(i ntrad ay)/ye a r s (E 0 D)

0 E n a b l e scroll bar zoom

F1 Showvertical line between months

0 'New Look1 charts

• Quote selection only by CTRL+LMB

159!

Default number of quotations in a chart: Blank b a r s in right margin: Candlesticks i U s e distinct color for b o d y outline and s h a d o w s Drawing 0 Return to select m o d e after drawing 0 Auto-select last drawn object

S n a p to price % threshold:

Miscellaneous 0 Ask for p a r a m e t e r s of newly inserted indicators 0 Ask for confirmation when deleting indicator sections • Ask for confirmation when closing indicator p a n e Number of chart s h e e t s (from next run):

OK

j |

Cancel

\ |

Apply

‫| ]־־־‬

Help

Introduction to AmiBroker Techniques used to manipulate the study and drawing tools follow Windows. •

To select the object, move the mouse over the object so the four-directional arrow cursor appears. Click once. The sizing handles will appear.



To de-select the object, click in any blank chart space.



To re-size the object, click on the sizing handle and drag it to the desired location.



To move the object, click on any part of the object other than the sizing handles and move it to the desired location.



To delete object, select it, then press the Delete key on the keyboard. Alternatively, use the Edit menu and select Delete.



To copy the object to the clipboard, select it, then press Ctrl+C. Alternatively, use the Edit menu and select Copy; or use the Copy toolbar button.



To cut the object, select it, then press Ctrl+X. Alternatively, use the Edit menu and select Cut; or use the Cut toolbar button.



To paste the object from the clipboard, press Ctrl+V. Alternatively, use the Edit menu and select Paste; or use the Paste toolbar button. The pasted object will be drawn in the same location as copied one and will be selected automatically so you can move it to a new location.



To apply color or style to the object select it and use Format menu or Format tool bar buttons to change color, thick, dotted and snap to price styles. You can select the color and style of the object before drawing a new object. Deselect previous object (if any), change color / style selections, and draw new object.



To modify the properties of an object, first select it, then open the Properties ciialog box.



To delete all objects in the pane, use the Edit menu and Delete All.

Graphical

User

Interface

5

‫ו‬

‫ו‬

STUDY TOOLS

Trend line, Ray, Extended, Vertical, Horizontal These tools give different flavors of the basic trend line, Trend line gives a line segment, Ray gives right-extended trend line, Extended gives trend line that is extended automatically f r o m both left- and right- sides. Vertical and Horizontal are self-explaining. Arrow Similar to Trend line but ends w i t h an a r r o w Zig-zag Draws a series of connected trend lines. To end d r a w i n g press the ESC key. Parallel This tool draws a series of parallel trend line segments. First you d r a w a trend line as usual. A second line parallel to the first is automatically created and you can move it a r o u n d with the mouse. Once you click on the chart it is placed in that position. A third parallel line appears that can be placed somewhere else. A n d so forth. W h e n you have all the parallel lines you need, either press ESC key or choose the Select tool. Regression channels Three kinds of regression channels are available: •

Raff regression channel.



Standard error channel.



Standard deviation channel.

All these channels are based on linear regression trend line. They differ in the method used for setting the distance f r o m the trend line to the upper and lower channel lines. "Study ID" column defines study identifier that can be used in your custom formulas to detect crossovers. If necessary, you can change these IDs by simply editing these fields. For more information on Study IDs check the Tutorial: Using studies in AFL formulas. More information on regression channels is available f r o m the AmiBroker User's Guide.

Introduction to AmiBroker Fibonacci and Gann studies There are m a n y options, parameters, and preferences. Please refer to the AmiBroker User's Guide for details. Triangle Triangle tool is self-explanatory. To d r a w a triangle: 1. Left-click at the first point. 2. Hold the left mouse button a n d drag to the second point. 3. Release the mouse button. 4. Move the cursor to the third point. 5.

Click once.

Andrews' Pitchfork A n d r e w s ' pitchfork is a study using parallel trendlines. To construct the study, choose three starting points. The first is a major peak or trough on the left side of the chart display. The second and third are chosen to be a major peak and a major trough to the right of the first point. Leftclick at the first point, hold d o w n and drag to the second point, then release m o u s e button and drag to the third point and click once. After all starting points have been decided, AmiBroker draws a trendline from the first point (the most left) so that it passes directly between the right most points. This line is called the h a n d l e of the pitchfork. The second and third trend lines are d r a w n by AmiBroker beginning at the starting points and parallel to the handle. Cycles Click at the starting point of the cycle and drag to the end of the cycle. Vertical lines will be d r a w n on the chart extending that cycle length to both the right and left.

Graphical User Interface

‫ ו‬59

A D D ICONS T O TOOLBAR

If you do not see an icon you want on a toolbar, you can turn it on. For example, assume you want the close pane icon on the view toolbar. 1. Click the Toolbar Options icon at the bottom of the View Toolbar. It will open the Add or Remove Buttons menu. 2. Select View. 3. Select Close Pane. 171 # Zoom in (+SHIFT zoom out, +CTRL normal, +SHIFT+CTRL to .,, Ctrl+Num H e Zoom out 0 1 Intraday Ctrl+0 E: * Hourly Ctrl+D B * Daily view Ctrl+W E ‫ ״‬Weekly view Ctrl+M Fl - Monthly view e New Web Research H x Close pane • m Arrange charts +

Crosshair

‫ש‬

Refresh

1

F5

Shorter bars



Taller bars

24

24-hours trading

*

Day session

c

Ctrl+H

Night session

*

Day and night sessions

0

1-minute

Ctrl+1

5-minute

Ctrl+5

®

Ctr 1+6

15-minute Reset Toolbar

Because the View Toolbar is at the right edge of the screen, these menus open right to left.

1 160

Introduction to AmiBroker

TABBED M E N U S

AmiBroker has several "tabbed" menus. These can be "torn off" from their present location and re-docked wherever you want them. And they can be set to slide to the side of the window (in an auto-hiding technique) giving more screen real estate to the charts. The next few pages describe the "tabbed" menus and windows. They include menus Layouts, Symbols, Layers, Charts, Notepad, and Interpretation, and windows Symbol Information, Real-time Quote, Alert Output, Time and Sales. RE-DOCKABLE MENUS

All of these tabbed menus are implemented as "tear-off tabs" and can be re-docked wherever you wish. To re-dock a menu into any side of the application or as a tab simply click on docking window's caption bar and drag it. Docking stickers will appear. Drag the pane until the cursor is over one of the docking stickers, then release. The pane will dock in that position. (See figure on next page.) When you re-dock the pane back into its original location, it may not be in the same order relative to the other tabs. A U T O - H I D I N G SLIDING MENUS 9 X

Symbols I Layouts j Layers Chart? j Symbols it! C l SB LJ Sft GJ (& Cl !1 LJ it; CJ

Markets Groups Sectors Watch lists Favourites Indexes

O

L AmiBroker - [QQ.QQ ‫ ע‬File

£drt

^

View #

Insert H i ®

‫ ״‬q q q q (Daily)

F >

*

7/30/20DB O

If there is a pin in the upper right h a n d corner of a tabbed menu, that menu may be set to auto-hide. Autohiding brings the menu out when you want it, and lets it slide out of the way and off the chart's real estate when you do not need it. To set Auto-hiding On, just click the pin. The pin icon will turn from upright to sideways and the menu will be auto-hiding, as in the illustration to the left. Click the tab and the menu will slide out.

Graphical User Interface L

A m i B r o k e r - [ Q Q Q Q - P O W E R S H A R E S Q Q Q T R U S T - U N I T SER 1

J QQQQ [Daily

‫ו ו‬5

- Daily]

IjlJUU (Daily) X

Q Q Q Q - Dally 4/18/2008 O p e n 46.51, Hi 46:

Cursor

Docking stickers

45.4371 45 1608

44.00M 0

For Help, ! y e s s F1

Nasdaq, ETF, Financial, Fin-ETF

* QP End of Day

1 62

Introduction to AmiBroker

LAYOUTS, LAYOUTS TABBED M E N U , LAYOUTS C O N T E X T M E N U

Layouts are the highest level of the AmiBroker chart structure. They are described in Chapter 4, AmiBroker Chart Structure. Layouts Tabbed Menu The Layouts tabbed m e n u shows which layouts are available for use with the database that is open (local layouts), and which are available with any database (global layouts). Show or hide the Layouts tabbed m e n u using View > Layouts.

1

Layouts

Layouts | Layers j Charts, j Symbols | Ss LJ Local layouts •

Default

0

Vanilla

The Yellow icon shows which layout is currently open and active.

& CJ Global layouts «

Daily_Weekly



Default



Local layouts



T w o Broad

Double-click any entry to open it and make it the active layout.

Layouts Context Menu The Layouts context menu opens w h e n you right-click in the Layouts tabbed menu. I2532331SI Open



Save S a v e As... Save as default Delete



O p e n - loads selected layout. Save - saves current w i n d o w layout u n d e r current name. Save As... - save current w i n d o w layout under n e w name. Save as default - save current w i n d o w layout as default (startup) layout for given database. Delete - delete selected layout.

Graphical

User

Interface

5

‫ו‬

‫ו‬

LAYERS, LAYERS TABBED M E N U , LAYERS C O N T E X T M E N U

Layers are like pieces of transparent plastic. You can put d r a w i n g s on them. Showing or hiding a layer allows you to display or hide the drawings placed on that layer without affecting the d r a w i n g s placed on other layers. Layers Tabbed Menu The Layers tab lists the pre-defined layers. j Layouts j Layers J Charts j Symbols j ₪ • 0 • P • • • • 0 •

Default layer Intraday layer Dally layer Weekly layer Monthly layer Custom layer 1 Custom layer 2 Custom layer 3 Custom layer 4 Custom layer 5 Weekly stuff

The checkboxes on the left side of each layer control layer visibility. If the box is checked, then that layer is visible; if it is unchecked, that layer is invisible. Show or hide the Layers tabbed m e n u using View > Layers.

The first five layers are built-in and special. They are: 1. Default layer - always visible. 2. Intraday layer - visible only w h e n viewing intraday charts. 3. Daily layer - visible only w h e n viewing daily charts. 4. Weekly layer - visible only w h e n viewing weekly charts. 5. Monthly layer - visible only w h e n viewing monthly charts. The visibility of these five is controlled by the charting interval selected, and cannot be changed using the checkboxes. The r e m a i n i n g layers can be shown or hidden by m a r k i n g the checkbox. To draw a study on a given layer: 1. Select the layer by clicking on its name. 2. Draw the study as usual. You can move a study f r o m one layer to another using the Properties menu of the study (not the Properties of the layer). That is, right-click the study, choose Properties, select the layer you w a n t this study to be on.

1 164

Introduction to AmiBroker

Layers Context Menu W h e n you right-click on a layer name, you will see the context menu containing the following options: Add layer R e m o v e layer S h o w All Hide All Toggle Lock built-in layers Unlock built-in layers

Add layer - A d d s a new layer. Remove layer - Removes the selected layer. Note that you cannot remove any of the first five, builtin layers. Show all layers - Shows all non-locked layers. Hide all layers - Hides all non-locked layers. Toggle - Toggles the visibility of all non-locked layers. Lock built-in layers - Lock the first five, built-in layers. W h e n these layers are locked, their visibility changes w h e n the charting interval changes. Unlock built-in layers - Unlocks the first five layers. The visibility now d e p e n d s on the checkbox. •

Layer properties

!*/]Lock visibility to selected interval Visibility Interval •

Monthly



Weekly

M

Daily



Daylight



Hourly

F " | 15-minute 5‫ ח‬- m i n u t e r~1

*

Properties - Launches the properties box that allows you to r e n a m e layers, and decide if the layer should be locked to the charting interval displayed. There is a separate visibility setting for each interval. Check the boxes where you w a n t the layer to be visible and uncheck those where you do not.

Graphical User Interface

‫ וו‬5

SYMBOLS, SYMBOLS TABBED M E N U , SYMBOLS C O N T E X T M E N U K B Layouts I l a y e r s j Charts | Symbols j ‫ נ‬AII ‫ נ‬Markets ‫ כ‬Groups J Sectors £ U Undefined ti LJ Capital Goods a Svc !1

Consumer Goods

Symbols.

6 LJ Telecommunications H D Utilities J Watch lists fe CJ Passed Test N LJ Best Results is U DJ30 y; D Russell 1000 t LJ Russell 2000 i LJ SP100 B D NASDAQ 100 t: LJ SPSectorETFs J Favourites • ^

S2SSI SPY

J Indexes

Symbols Context Menu The Symbols context menu opens w h e n you right-click in the Symbols tabbed menu. •

Add to favorites - Add the active symbol to the Favorites category.



Remove f r o m favorites - Remove the acfive symbol f r o m the Favorites category



Erase favorites - Remove all m e m b e r s of the Favorites category f r o m that category (not f r o m the database).



Web research - O p e n a new w i n d o w in the AmiBroker C h a r t window, and use the built-in browser to display a page of information about the active symbol. (See figure next page.)

Symbols I Layouts li h ti is -

LJ _l CJ • CJ * g

| Chat is j Symbols j

All Markets Groups Sectors Watch lists D Passed Test Q Best Results • Bf ‫־ ־‬ » A f Mc

IT: U ‫ נ ם‬3 ‫ס‬ t. ‫ ט‬Russe

.‫ ט‬SPIOO

Remove from favourites Erase favourities Web Research

WA‫ ״‬, !TET

ii LJ NASD* * ‫ ט‬SPSec ‫ ט‬Favour iter • QQQQ V SPY I Indexes

Delete

Introduction to AmiBroker

1 166

4 AMIBROKER - [Q.Q.QQ - HEADLINES (Y! FINANCE)] a Ells

edit

yiew

Insert

Symbol

Fgrmat

‫״‬D Alert Output.

Alert Output Context Menu The Alert O u t p u t Context m e n u gives only two choices: •

Delete - Delete the selected row



Delete All - Delete all rows in the window.

‫וו‬5

Graphical User Interface REAL-TIME Q U O T E , REAL-TIME Q U O T E C O N T E X T M E N U

Real-Time Quote Window 4 AmiBroker - [XLY - CONSUMER DIS SS SPDR - 1 - m i n u t e ] ‫ צ‬EHe

Edit

View

‫&ם‬y&

Insert

Format

m

o

Symbol

oa=

Analysis

!ools

Window

‫& « •י‬

XLY

Help a

&

1

*!

^ j y

:m

‫׳‬

j

b

d

w

2 XLY ( 1 - m i n u t e ) : XLY - 1 - m i n u t e 8 / 1 4 / 2 0 0 8 2 : 2 2 : 0 0 PM O p e n 3 1 . 0 5 . Hi 3 1 . 0 5 . Lo 31, C l o s e 31 ( - 0 . 1 % ) Vol 13.247 M A ( C I 0 s e , 1 5 ) = 3 1 . 0 2 , Mid

J

1

'8/13/2008 y

13:00 113:30 114 00' 14 30 115 00115:30 '8/14/2008

(• \ S h e e t 1

Realtime Quote T... Sf Open XLB XLE XLF XLI XLK XLP XLU XLV XLY i

39.64 72.90 20.46 35.07 23.41 28.54 37.17 32.91 30.04 i



•1 V - i s t

For Help, press Fl

/ Sheet 2 ‫ ץ‬Sheet 3

1

1 0 : 3 0 1 1 1 : 0 0 ' 1 1 : 3 0 ' 12:01' 12:30 1 1 3 0 0

Sheet 4 \ Sheet 5 ^ Sheet 6 ^ Sheet 7 \ Sh - 5 - 1

High

Low

Last

Change

% Ch...

Volume

Trad... !

39.80 74.38 21.26 35.73 23.75 28.89 37.17 33.57 31.28

39.06 71.36 20.38 34.89 23.28 28.35 36.65 32.89 30.01

39.49 72.36 21.06 35.50 23,67 28,76 36,94 33,43 31,00

" -0.19 ‫־‬1.14 0.49 0.18 0.21 0.19 -0.20 0.13 0.60

‫־‬0.48% ‫־‬1.55% +2.33% +0.51% •>•0.90% +0.67% -0,54% +0.39% + 1.97%

8,013,... 27,44... 89,40... 5,579,... 3,320,.., 3,385,.,, 2,479,,,. 2,394,... 3,955,...

100 100 1,800 100 100 100 100 100 300

A « 2 Y U S . 3 ^ List 4 . u s t s X List 6 \ u s t 7 \ List X; 8/13/2008 3:02:00 PM, Bar: 2465 Y: 31.0864

8 L

\ <

Bid 39.49 72.36 21.06 35.50 23.66 28.76 36.93 33.41 31.00

1

13:45114

<

Bid size I 30 70 850 130 524 195 195 274 115

Ask 39,50 72.37 21.07 35.51 23,67 28.77 36.94 33,42 31.01

Asks...

52w ... i 52\a

"""""I'D"'' 5 1,855 116 237 205 39 261 164 ‫׳‬A--j

i

: Undefined, Undefined, Services, Advertisinc > QP RealTi me

The Real-Time Quote w i n d o w shows the tick-by-tick information about the symbols that have been added to the window. Fields depend somewhat on the data provider, but include: •

Prices for the session - Open, High, Low, Last.



Change from previous close.



Percent change from previous close.



Volume for the session.



Last trade volume.



Bid price and size.



Asked price and size.

Show or hide the Real-Time Quote w i n d o w using View > Real-Time Quote.

Introduction to AmiBroker Real-Time Quote Context Menu The Real-Time Quote context m e n u opens when you right-click in the Real-Time Quote window. •

Time a n d Sales - O p e n s the Time a n d Sales w i n d o w that provides information about every bid, ask, and trade.



Easy Alerts - O p e n s the Easy Alerts w i n d o w that provides a way to define real-time alerts executed w h e n bid, ask, or last hit user-defined levels.



Add Symbol - A d d s the current symbol to the RealTime Quotes list.



Add Watchlist - A d d s all the symbols in a watchlist to the Real-Time Quotes list.



Type in Symbol - O p e n s a dialog so you can type in a symbol to add.



Insert Empty Line - Inserts a blank row in the RealTime Quote w i n d o w to help visual organization of the window.



Remove Symbol - Removes the symbol in the highlighted line f r o m the Real-Time Quote window.



Remove All - Removes all symbols from the RealTime Quote list.



Hide - Hides the Real-Time Quote list and window.

Time a Sales... Easy alerts Add symbol Add watch list.,. Type-in symbol(s) Insert empty line Remove symbol Remove All Hide

Graphical User Interface 5 ‫ו ו‬ T I M E AND SALES L Time & Sales SPY Time 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:1X1 10:36:00 10:36:00 10:36:00 10:36:00 10:36:00 10:36:CC

Type

Price

Bid Bid Bid Ask Ask Trade Bid Ask Trade Trade Bid Ask Ask Bid Bid Trade Trade Bid

129.B6 129.86 129.86 129.87 129.87 129.87 129.86 129.87 129.87 129.87 129.86 129.87 129.87 129.86 129.86 129.87 129.B7 129.86

•o Size

15700 15100 14300 1300 1100 100 14400 700 200 100 14300 1100 1300 14200 13600 100 100 13600

<

m A

V

The Time a n d Sales w i n d o w displays information about every bid, ask and trade streaming f r o m the market. Each row displayed represents either a new trade, a n e w bid, or a n e w ask that is sent by the streaming data source. Each line in the time and sales w i n d o w is marked with color to m a k e it easier to distinguish b e t w e e n various conditions.

>

Coloring rules are: •

Light green background m e a n s a new ask.



Light red background m e a n s a new bid.



Normal (white) background m e a n s a n e w trade.



Red text for the bid price, ask price, or size m e a n s that the value is less than the previous value of the same category. For example, if the bid price is written in red letters, that m e a n s that the n e w bid is lower t h a n the previous bid.



Green volume field m e a n s that the volume of last trade, or ask or bid size, is greater t h a n the last.



Black text for the bid/ask price/size/volume m e a n s that the value is the same.



Red last trade price m e a n s the trade occurred at or below the current bid.



Green last trade price m e a n s the trade occurred at or above the current ask.



Black last trade price m e a n s the trade occurred inside the current bid-ask range.

Introduction to AmiBroker Time and Sales Context Menu The Time and Sales Context Menu appears w h e n you right-click in the Time and Sales Window.

HfflBBBBB Time

Type

10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16

Bid Bid Ask Ask Bid Bid

10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16 10:37:16

Bid Ask Ask Bid Bid Bid Bid Bid Bid Bid Bid

Price

Size

129.89 129.89 129.90 129,90 129.89 129.89

10000 10200 *000 3900 10400 10600

A

* Show Trades * Show Bid / Ask Quotes Clear display 129,89 129.89 129.89 129.89 129.89 129.89

18100 18800 19800 20300 205C0 20700

Show Trades - W h e n checked, displays trades. Show bid / ask Quotes - When checked, displays bid and ask prices. Clear display - Clears the window.

Graphical User Interface 5 ‫ו ו‬ CATEGORIES

AmiBroker has the ability to assign ticker symbols to different categories, and then use categories as filters, selecting symbols based on membership in a particular category. There are two types of categories: 1. Those with mutually exclusive membership: groups, markets, sectors, and industries. This m e a n s that a symbol m u s t belong to exactly one group, one market, one sector, and one industry at a time. 2. Those with free membership: watchlists, favorites, and indexes. This m e a n s that a symbol may belong to any n u m b e r (including zero) of watchlists, and, optionally, belong or not belong to the favorite and index categories. GROUP - M A R K E T - SECTOR - INDUSTRY

For stocks, each stock belongs to one industry. It belongs to one sector based on its industry and on an assignment table - each industry belonging to exactly one sector. For example: GM (General Motors) belongs to the "Auto & Truck M a n u f a c t u r e r s " industry, and this implies that GM belongs to "Consumer/Cyclical" sector. AmiBroker can h a n d l e up to 32 sectors and up to 256 industries. The predefined list of industries and sectors is in A p p e n d i x B. You can define your o w n sectors and industries to use in place of those. For more details, see the AmiBroker User's Guide. CATEGORY MEMBERSHIP

Categories are displayed u n d e r the Symbols Tabbed menu. Although the icons look like normal folders used by W i n d o w s Explorer, categories do Not work like folders. The difference is f u n d a m e n t a l . In the W i n d o w s file structure, a file appears only once in a given tree as a leaf. In the AmiBroker symbol trees, any symbol may show up multiple times - once as a leaf in every category to which it belongs.

1 178

Introduction to AmiBroker

A single symbol belongs to m a n y categories at the same time. For example AAPL (Apple Inc.) will belong to these categories: •

All



Stocks g r o u p



Nasdaq market



Information sector



Comp-Computer Mfg industry

A n d it m a y belong to these categories: •

Any n u m b e r of watchlists



Perhaps the favorite category



Perhaps the index category

The special category called All lists all symbols present in the database. CATEGORY ASSIGNMENT

You can assign a symbol to an industry using either: • •

Symbol Pull-down m e n u > Information, then edit the Categories you wish to change. Symbol Pull-down m e n u > O r g a n i z e assignments, then use the Assignments Organizer.

The first m e t h o d is fine if you w a n t to change single symbol settings. The latter is better if you w a n t to move multiple symbols from one category to another.

Graphical User Interface

‫וו‬5

W A T C H LISTS

Watchlists are lists of symbols that have s o m e t h i n g in common. Watchlists are used to define the universe of symbols that should be used w h e n procedures are run. You will use t h e m a lot, and there are m a n y techniques for m a n a g i n g them. Examples of watchlists you might use are: •

Components of the S&P 100.



Components of the NASDAQ 100.



Sector ETFs.



C o m m o d i t y ETFs.



Stocks that passed your favorite filter.

Watchlists differ from other kinds of categories (groups, markets, industries, sectors) in that you can assign a single symbol to more than one watchlist - in fact, to as m a n y watchlists as you w a n t to. Symbol* Layouts j Layers [ Charts j Symbols * CJ All & LJ Markets '*j LJ Groups ii (_J Sectors & LJ Watch lists i D List 2 ©•D30‫נם‬ $ • • • • • » • • • • • • • • • • • •

MMM AA AXP AIG T BAC BA CAT CVX C KO DD XOM GE GM HPQ HD INTC IBM

The m e m b e r s of each watchlist are s h o w n in the symbol tree. O p e n the Symbol Tabbed m e n u a n d expand Watch lists. Watchlists are associated with a single database. They are one symbol per line, and have the file extension .tls. The .tls files can also be opened by AmiQuote. They are stored as text files in the Watchlists folder in the subdirectory of the database they are used with. The folder contains any n u m b e r of .tls files defining watchlists themselves; and it also contains the file n a m e d index.txt that defines the order of watchlists. You can create as m a n y watchlists as you want, and n a m e them whatever you want. You add your o w n .tls files to that subdirectory, and AmiBroker will automatically u p d a t e index.txt, and add any new watchlists it finds.

All watchlists are local, there are no global watchlists. If you w a n t to use the same watchlist with several databases, copy the .tls files to those database subdirectories. When you open the default symbol tree and e x p a n d the watchlist category, you will see 64 watchlists, n u m b e r e d 0 t h r o u g h 63, all initially empty. You can populate these and r e n a m e them, or you can add n e w watchlists.

Introduction to AmiBroker

1 180 A D D I N G WATCHLISTS

You can add watchlists in several ways: •

Use the Symbol m e n u > Watch List > N e w Watchlist.



From the watchlist context menu.

Symbol ! Analysis

!00Is

Windc j layouts ' Layers j Chart?- i Symbols

New...

J NASDAQIOO • ATVID • ADBE • AKAM • ALTR

Delete Split...

ft

Merge,.. Find

e

Information.,,

m

Quote Editor...

F3

Favourites

>

Wairh list



Add selected symbol...

Real Time Quote



Remove selected symbol...

Categories..,

lype-in symbols.,,

Organize assignments...

Import...

Calculate composites...

Export... Erage (make empty)... Sort alphabetically...

• • • • • • • • • • •

I AN A('• AF AA AN AC. Bill BB Bli BR

Add to favourites Erase favour ities Web Research Add selected symbol Remove selected symbol Type-in symbols,,. Import,.. Export.., Erase (make empty)

Hide empty watchlists New watchlist... Delete watchlist...

Sort alphabetically Hide Empty watchlists New watchlist... Delete watchlist

REMOVING WATCHLISTS

Similarly, you can remove watchlists in those same ways using the Delete watchlist option. If these m e n u items do not appear, use the Tools > Customize > Options, then press the Reset button for new m e n u items to appear.

Graphical User Interface

5‫וו‬

A D D I N G SYMBOLS TO WATCHLISTS

You can add a single symbol to a watchlist by right-clicking the symbol in the symbol tree (in any of the categories except watchlist) and choos‫־‬ ing Watch List > Add selected symbol. Symbols

• GMKT (Daily) X

| Layouts j Layers ‫"׳‬harts ‫ ן‬Symbols ;

| GMKT - Daily 7/30/2008 Open 21 65. Hi 2

i‫ •־‬Technology :.!if 03 '3 O Internet-Retailing v AAC • ABTL • AMTD • AMZN • BFLY • BIDZ 0 DGC • DSCM • EBAY • ETFC • EXPE * Add to favourites

• HC

Web Research

IN • ‫ן‬ • • Kl • LC • LC

Add selected symbol

‫—־‬

Remove selected symbol Type-in symbols,,. Import,,,

Delete

Export... Erase (make empty) Sort alphabetically Watch list > Type-in. You will be asked to select a watchlist, then to type in the list of symbols, each symbol separated from the next by a comma. Use uppercase letters. Symbol I Analysis %

lools

Wind )w

Help

New...

&

! ^ /ft ^ ^

Enter one or more tickers to a d d ( c o m m a separated)

;; Delete £

Split...

AA. AXP. GM. F. IBM

,'•I Merge... (Mil Find

F3

O

Information...

03

Quote Editor,.. Favourites



Wafch li*t :

>

1 Real Time Quote

Add selected symbol.,.



Remove selected symbol...

‫ י‬Categories,,,

Type- in sy mbo Is... •

Organize assignments.., | Calculate composites..,

;; Import... I

Export... ‫ ן‬Erase (make empty),.. Sort alphabetically...

j"*"! Hide empty watchlists New watchlist... I Delete watchlist..,

You can also right click the watchlist n a m e in the workspace tree to t y p e in symbols directly into the watchlist. S LJ Watch lists a OS®* Add selected symbol Remove selected symbol Type-in symbols... Import,,, Export... Erase (make empty) Sort alphabetically * Hide Empty watchlists New watchlist... Delete watchlist

SORTING SYMBOLS IN A WATCHLIST

1 €3 I I P *

Add selected symbol Remove selected symbol Type-in symbols... Import.,. Export.,, Erase (make empty) Sort alphabetically

‫ ׳׳‬Hide Empty watchlists New watchlist.., Delete watchlist

Watchlists remember the order in which symbols were added. If you sort a result list in some order and then you ,, add symbols to watchlist‫ ״‬the order will be kept in the watchlist. You can ask AmiBroker to sort the watchlist into alphabetic order. Select the watchlist, right-click, and select Sort alphabetically.

Graphical

User

Interface

5

‫ו‬

‫ו‬

REMOVING SYMBOLS FROM WATCHLISTS

Removing symbols from the watchlist is as easy as a d d i n g them. Rightclick the Watchlist n a m e and select Remove Selected Symbol. & U 1 List 2 •

QQQQ

• 0. » U D330 « Mr • A^ • A} • AI •

• » • •

Add to favourites Erase favour ities

|

' H B‫™־׳‬ Ci C\

Add selected symbol Remove selected symbol Type-in symbols...

[

Import...

• c —

Export,,,

• • • • • • • •

Erase (make empty)

KO DD XOM GE GM HPQ HD INTC

Sort alphabetically *‫ ׳‬Hide Empty watchlists New watchlist,,, Delete watchlist

ERASING WATCHLISTS

Sometimes you may w a n t to clear (or erase) the whole watchlist. Using the Symbol menu, Watch list, Erase (make empty) option. In the watchlist selector w i n d o w mark the list(s) you w a n t to clear and click OK. You will be asked to confirm. Symbol [analysis

%

Iools

yVindow

New... Qelete

?'

, **r I asip

£

Split... Merge...

M

Fnd

O

Information.,.

F3

Quote EditDr... Favour ites



&ateh list



Add selected symbol.,.

Real Time Quote

Remove selected symbol.,.

Categories,,,

lype-in symbols.,.

Organize assignments.

import,,.

Calculate composit8s..

Export,.. Sort alphabetically... E

Hide empty watchlists New watchlist... Qelete watchlist.,,

‫י‬

1 184

Introduction to AmiBroker

H I D I N G AND U N H I D I N G EMPTY WATCHLISTS

By default all watchlists, including those that have no symbols in them, are s h o w n in the symbol tree. You can hide e m p t y lists. Right-click on any symbol or watchlist n a m e in the symbol tree, and select ‫״‬Hide Empty watchlists". To un‫־‬hide, use the same m e n u and remove the check mark. 1• Ci List 4 , :

Q List 5 •DI List 6 ‫׳‬call® LJ List:

S C3 DJ31

Add selected symbol R e m o v e selected symbol

p r

Type-in symbols...



‫׳‬

Import...



‫׳‬

Export...



1

• '

Erase (make e m p t y )

4> [ • >

S o r t alphabetically

& c

Hide Empty watehlists

^

New watchlist,..

^ y

Delete watchlist

Kjg>g*|f

USING WATCHLISTS IN A U T O M A T I C ANALYSIS W I N D O W

The results of scanning, backtesting, and exploration can be added to a watchlist. After r u n n i n g your analysis, you will have a list of results. Sort those results as you wish. Select the lines of the symbols you want in a watchlist. (The lines do not need to be contiguous. Hold the CONTROL key while clicking the m o u s e on any lines in any order.) Rightix Automatic Analysis - Example.afl Formula tile !C:\Program Files\AmiBroker\Formulas\Systems\Example.afl : A p p l y to

Range

;

O ®‫ יי‬s y m b o l s

O oil quotations

!

Q current s y m b o l

‫ן‬

®usefilter

[

‫ן‬

o ‫ ח‬last quotations De<



Run every



Wait tor backfill ( R T only)

( • ) ‫ ח‬lost d a y s

O 'rom:

| Back Test n -

[ 9/ 1/2004 f 1/

‫־־‬

5



‫״‬

»

‫־ ן‬ Equity

1/2006

[ I ] S y n c chart o n s e l e c t Results

CGRB ICO <

13.574.38 30.897.31

13.57 30.98

Add selected results to watch list.. Replace watch list with the results. Replace watch list with selected results...

:(1978 rows) Prolit •-17810.38 (-1 7 8 1 ' / . ) , C A R - - 1 3 ;

Clear results list Copy

‫ן ן‬

S c a n

Ex

•*,j j ‫ן ך‬

Pl0fe

Optimize ‫־ — ־‬ Settings...

Graphical User Interface

5‫וו‬

clicking brings up a dialog box that gives several choices. The four we are interested in at this time are: •

Add all the results to watch list. There are 1978 rows. Selecting this option will add the symbols for all 1978 rows to the watchlist. Duplicates will be eliminated.



Add selected results to watch list. This option will add eight symbols to the watchlist. Duplicates will be eliminated.



Replace watch list with the results. Make the watchlist empty, then save the 1978 symbols in it. Keep the symbols in the order they are in the results window.



Replace watch list with selected results. Make the watchlist empty, then save the eight symbols in it.

After you have m a d e your choice from a m o n g these four options, you will have an o p p o r t u n i t y to select the watchlist(s) to receive the symbols.

m ListO List 1 List 2 List 3 List 4 List 5 List 6 List 7 List 8 DJ30 Russell 1000 Russell 2000

Cancel Hint: You can select multiple lists here by holding SHIFT/CTRL key.

Introduction to AmiBroker

1 186

IMPORT A W A T C H L I S T FROM A FILE

Using the Symbol menu, choose Watchlist, then Import. Select the watchlist you w a n t to use. Ignore the file button ‫ ־‬you cannot change it. S y m b o l ! analysis

V

3:

lools

B!ndow

New...

Uelp

‫י ׳‬

Delete

» ar ! i i f i l ‫ ־‬£

List 1 List 2 List 3 List 4 List 5 List 6 List? Lists DJ30

Split... Merge...

H O

Find

F3

Information... Quote Editor... Favourites

>

'Watchlist Real Time Quote •‫•ן‬

»j

Add selected symbol,..



Remove selected symbol...

Categories...

lype-in symbols...

Organize assignments.,,

‫ ־‬F Export..,

Calculate composites,..



Select watch list(s)

‫•״‬--‫יי ״י*׳יו'״״״ ' י‬

[

Russell 1000 Russell 2000 Import/Export from/to:

®Fife. e t e r n a l 43ts s a r c t j

Erase (make empty)... Sort alphabetically... Hide empty watchlists New watchlist... Delete watchlist...

1. Navigate to the file you w a n t to import. 2. Select that file. 3. Click Open.

Look in:

m

My R e c e n t Documents

CB

Desktop

My Documents

a st
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF