ADDING
NEW FDC FUNCTIONS: MACROS
Many traders use so-called toolboxes of technical indicators to study data. The missing ingredient is the ability to form your own indicators and add them to the toolbox without the need for programming, and the ability to modify the provided indicators at will. In FDC you can formulate virtually any indicator by using the powerful basic functions that you have learned. Instead of retyping a formula each time you want to use it, you can make a macro abbreviation that essentially extends the intrinsic commands of the FDC calculator to include this new indicator. Simply press the Macro Wizard tool on the toolbar of a command window. This button is highlighted below.
When pressed, the Macro Wizard
window opens, as shown below.

Macro example 1.
The
Macro Wizard window shown above provides you with a chance to modify any existing
macro, or write a new one yourself. The
names of the existing macros are shown in the “Macro Name” window. When you select one, the definition appears
in the “Macro Definition” window and can then be modified in the usual way
(it is ordinary ASCII text). When
you press the “Create New Macro” button, you will have a chance to enter your
chosen name in the “Macro Name” window, and the corresponding definition in
the “Macro Definition” window.
Suppose
you want an abbreviation to compute the daily range of the data set STOCK1. Press the “Create New Macro” button, and type: RANGESTOCK1 in the “Macro Name” window. After the name is entered, you will type
(HI STOCK1) MINUS (LO STOCK1)
Now
press the “Process New Macro” to add this new Macro to the list of stored
Macros. Return to the input window. If while you are in the input window you should
type RANGESTOCK1, then FDC will go find the STOCK1 Dataset, take its HI and LO, subtract them, and give the result back to you.
This
is great; however, you may also want to compute the range for GOLD, BONDS, S&P, and maybe 10 other markets. In effect, you want to add a new “range” function to FDC. Therefore, let us modify the above example.
Select
the Macro Wizard again, and click on the RANGESTOCK1 macro
in the “Macro Name” window. Choose “Delete Macro” to erase it (we could edit the definition instead, but we want
to change the name). Create a new
macro named “RANGE”, whose definition in the Macro Definition window
is
(HI #R) MINUS (LO #R)
In FDC macro language, "#R" means "right input". Now the RANGE macro will act like a built-in range function and can be applied to any appropriate Dataset. That is, you can request RANGE GOLD, and you will receive the range of GOLD. Whatever Dataset the function is applied to will replace the symbol #R in the definition, however many times that symbol appears. Note that the Dataset to which the function is applied is put on the right of the function. This explains the use of the #R variable in the definition.
Macro example 2:
As above, create a macro named AVE310, whose definition is as follows:
(3 MOVAVE #R) - (10 MOVAVE #R)
When
applied to any Dataset, this function computes the difference between the
3 and 10 day moving average of each column of that Dataset. While this is easy to follow, you could easily imagine needing to
construct macros which are much more complicated, and perhaps quite lengthy. So lets define another function similar to AVE3l0, but which performs the same operation on
the midrange price of the day. Let
us name this Macro function MID310. When asked for construction, type the following
on successive lines:
A: ((HI #R) + (LO #R)) /2
B:
3 MOVAVE A
C: 10 MOVAVE A
B - C
The
intermediate names A,
B, and C do not actually
exist outside of this macro and are called “local variables”. Make certain to use the colons (“:”) after
each local variable. When the macro
is used, each line is substituted into all successive lines to make one final
abbreviation. That is, all of the
above gets put together as one long line, which forms the definition of
MID310. Incidentally, since macros are ordinary ASCII data sets, you could,
if you wanted to, create them with any available text editor , and paste the
definitions into The Macro Definition window.
Macro
example 3:
You
have some Bond prices that were displayed in the format: 19980201 9427 9428
9325 9327, that is an OP HI LO CL format.
The only problem was that the price 9427 means 94 and 27/32, not 94.27,
and you want the data in decimal form so you can do certain smoothing operations
more easily. The following Macro will do the trick:
Macro Name:
RECONFIG
Macro Definition:
A: #R INTDIV 100
B: #R MOD 100
A + (B DIV 32)
Here's
what would happen when RECONFIG is applied
to the given data:
A turned 9427 into
94
B turned 9427 into 27
RECONFIG added 94 to 27/32 and got 94.845
You
could then request RECONFIG BONDS, or RECONFIG
TNOTES, etc. The reverse translation is also easy.
Macro example 4:
Macros
can have a left input Dataset as well as a right one. Thus they can work with two Datasets at once. Consider the following lines that could constitute
the definition of a macro.
Macro
Name:
RANGESCALE
Macro
Definition:
A:
(HI #R) - (LO #R)
A / #L
This
new function RANGESCALE computes the range of any right input divided
by the specified left input. Thus
the command
10 RANGESCALE CRUDEOIL
will
return one tenth the daily range of the Dataset CRUDEOIL. The symbol #L has been replaced by 10, and #R has been replaced by CRUDEOIL.
In this way you can create a macro that uses two inputs. Remember though, if a macro is to have only one input, then this must be a right input
Any information line in the macro definition after the character @ will be ignored for computation purposes. Thus, to make comments in your macros, simply add them after the @ character.