31.07.2021 Views

Ultimate Algorithmic Trading System

Using automated systems for trading in stock markets

Using automated systems for trading in stock markets

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

before a single line of code is typed. We have just skimmed the surface of the

capabilities of AmiBroker. It is a very powerful and easy-to-use tool. I learned AFL

while writing this book, and used it for most of the testing in Chapters 2 and 3.

Once you get your futures data into a database and create different portfolios,

testing across the entire portfolio is as simple as clicking on a single button. The

optimization capabilities of AmiBroker are simply mindblowing. You can use a

genetic optimizer to optimize not only a single market but an entire portfolio—just

like I did in Chapter 3. The best way to learn AFL is through examples. Also the

online community is absolutely terrific! I found answers to all my questions online

and I didn’t have to search very far.

Here are some of the codes for the various systems I tested in Chapters 2 and 3:

Code Samples

// Chapter 2 Double Moving Average Cross Over

// with Dollar Stop

Filter = 1;

PositionSize = MarginDeposit = 1;

sl = Param("ShortLen",9,9,100);

il = Param("InterLen",19,19,200);

mmStop = Param("StopDollars",3000,3000,6000);

OptimizerSetEngine("cmae");

Buy = MA(C,sl) > MA(C,il) ;

Short = MA(C,sl)< MA(C,il);

Sell = short;

Cover = buy;

ApplyStop(stopTypeLoss,stopModePoint,mmStop/PointValue,1);

141

INTRODUCTION TO AMIBROKER’S AFL

// Chapter 2 Bollinger Band Algorithm

PositionSize = MarginDeposit = 1;

len = Optimize("Len",60,10,80,2);

width = Optimize("Width",2,0.25,3,.25);

www.rasabourse.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!