Let's looks at the following scan.....
(HI + LO + CL) / 3 > MA
In this scan, we will emphasize the importance of bracketing or parenthesizing when using arithmetic in scans. We will run the above scan on Daily data. As you can see from the expression above, this scan is taking the average of today's High, Low, and Closing prices and comparing that average with a moving average. The quotepage that results will consist of instruments whose current days average is greater than it's moving average.
Investor/RT provides a number of arithmetic operations, including the following.
Addition + 3 + 4 = 7 Subtraction - 5.3 - 3.1 = 2.2 Multiplication * 2.2 * 2.0 = 4.4 Division / (2 + 1) / 2 = 1.5 Remainder % 10 % 3 = 1 Power ^ 4 ^ 2 = 16
When using arithmetic in a scan, it is important to properly parenthesize your expression so that it will be evaluated appropriately. For instance, in the expression above, "(HI + CL + L) / 3", the parentheses are critical. Without the parentheses, the expression: HI+LO+CL/3 would be evaluated by first dividing the CL by 3, and then adding the LO and the HI to the result. This would give you a value much larger than you would expect. By placing the parenthesis around (HI + LO + CL), you are telling Investor/RT to first do the addition of those three tokens before dividing them by three. A good rule of thumb: Whenever in question, parenthesize. Too many can never hurt you! If you are ever getting unexpected results, go back and check to see if you may need to do more parenthesizing. Remember, a good way to check to see if your expression is being evaluated appropriately is to Ctrl-click on the Check button in the Scan window. This will give you the details of the evaluation.
Now let's look at using scans to set data columns....