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.

COND3 = C > MA(C,100);

COND1 = centerBar < 0 AND centerBar < Min(leftBar2, leftBar1)

AND centerBar < Min(rightBar1,rightBar2);

COND2 = centerBar > 0 AND centerBar > Max(leftBar2, leftBar1)

AND centerBar > Max(rightBar1,rightBar2);

Buy = COND1 AND COND3;

Short = COND2 AND NOT(COND3);

BuyPrice = C;

ShortPrice = C;

longEntryPrice=ValueWhen(Buy,BuyPrice,1);

shortEntryPrice = ValueWhen(Short,ShortPrice,1);

Sell = Cross(C, longEntryPrice - 3 * ATR(10));

Cover = Cross(ShortEntryPrice + 3 *ATR(10),C); ;

AddColumn(longEntryPrice,"BuyPrice");

AddColumn(longEntryPrice - 3 * ATR(10),"longStop");

AddColumn(Sell,"Sell ?");

143

This last algorithm introduces the AddColumn and ValueWhen functionality.

The AddColumn is useful for many purposes, but is probably used more as a

debugging tool. Basically, this prints information out to the spreadsheet in Exploration

mode. The ValueWhen function, in this example, returns the element of

the BuyPrice array when the first value of 1 occurs in the BUY array. In other

words, it is the long entry price. This code is somewhat sophisticated, as it introduces

methods of debugging and gathering the last entry price. This code is fully explained

along with utilizing AmiBroker’s Exploration feature in the AmiBroker appendix.

INTRODUCTION TO AMIBROKER’S AFL

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!