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.

FIGURE 4.21

Sample loop programming code.

140

INTRODUCTION TO AMIBROKER’S AFL

programmer that certain lines are controlled by a loop or if construct. All the code

involved with the for loop is surrounded by curly brackets. The code controlled

by the if statement is surrounded by nested curly brackets. By matching an opening

left curly bracket with a closing curly right bracket, the programmer can easily see

what code goes with the for loop or the if statement. The left curly bracket right

after the loop definition opens up the block of code consisting of six lines. The lastright

curly bracket closes the loop and the block of code.

In addition to having to use the curly brackets to tell the computer which lines of

code go inside the loop or the if construct, it’s good practice to also indent the lines

of code enclosed within brackets. This is not a necessity, but it makes the readability

of the code so much easier. Now that we are using loops and ifs, we can highlight

the collapsible or folding text feature of the editor. Look at the code in Figure 4.21.

Notice where the arrows for the opening curly brackets are pointing. Now look at

the small boxes with a dash inside that correspond to the curly brackets. If you click

on the first box, the code controlled by the corresponding line of code will collapse

or hide. Go ahead and do it—see for yourself. If you click on the very first box, all

the code disappears except the for loop definition. The second box collapses the

code that goes with the first if. This is a neat feature if you want to streamline the

look of your code, or if you want to hide it and send a screenshot to someone else.

The combination of array and loop programming capabilities in AmiBroker should

facilitate any programming needs you come across.

■ Summary

All programming languages are built on expressions and operators and the precedence

of those operators. A solid understanding of these concepts is absolutely necessary

www.rasabourse.com

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

Saved successfully!

Ooh no, something went wrong!