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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Here is the source code from Chapter 4 that included some interesting topics that

is discussed here.

//Chapter 2 MACD utilizing AMIBROKERS

//Exploration Feature

Filter = 1;

PositionSize = MarginDeposit = 1;

Setting Filter = 1 turns on the Exploration tool. PositionSize = Margin-

Deposit = 1 facilitates futures trading mode.

myMACD = MACD(fast=12,slow =26);

myMACDAvg = MA(myMACD,9);

myMACDDiff = myMACD - MYMACDAvg;

leftBar2 = Ref(myMACDDiff,-4);

leftBar1 = Ref(myMACDDiff,-3);

centerBar = Ref(myMACDDiff,-2);

rightBar1 = Ref(myMACDDiff,-1);

rightBar2 = Ref(myMACDDiff,0);

Call the MACD function and calculate the difference between it and its nine-period

smoothing average. Utilize Ref to get historic values in the myMACDDiff array.

Visualize the MACD difference plotted as a histogram. This bit of code is gathering

information to determine if pivot point of the histogram has occurred. CenterBar is

two bars back and leftBar1, leftBar2, rightBar1, and rightBar2 are self-explanatory.

297

AMIBROKER

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);

COND3 is set to true when the close is above the 100-day moving average.

COND1 is set to true when the center bar forms a pivot low and is below 0.

COND2 is set to true when the center bar forms a pivot high and is above 0.

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!