O'Reilly logo

Building Winning Trading Systems with TradeStation™ by John R. Hill, George Pruitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3

Program Control Structures

The least complicated programs start at the top of the program block and execute each statement in order and stop after the last statement. A very simple and straightforward strategy is illustrated by our very first strategy from Chapter 1:

Inputs: longLength(40), shortLength(40);
Buy tomorrow at Highest(High,longLength) stop;
Sell Short tomorrow at Lowest(Low,shortLength) stop;

Most trading ideas can rarely be expressed in such simplistic terms. This strategy does not take into account a protective or trailing stop, profit objective, or any other exit mechanisms. It's not that a simple approach can’t work (most of the time they work best), but trading ideas can be complex and involved.

CONDITIONAL BRANCHING WITH IF-THEN

You can make your programs as complex as you need to by using control structures. These structures give programs the ability to react differently under different situations; based on information provided to it, a program can choose between different avenues of logic to follow. In other words, your program must make a decision. Decision processing requires three bits of information: (1) what information is used, (2) how to evaluate the information, and (3) what to do after the decision. This type of programming is called conditional branching, because the flow of your program will branch in different directions after a logical condition is evaluated. Conditional branching is a form of a control structure. By adding conditional branching ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required