|
Using the Security Data function with the Expert Advisor
For those with MetaStock Professional, the Security Data function provides an unusual potential that many people
overlook. The ability to analyze a group of securities at the same time.
While the explorer gives you this option, you are required to use the same system or signal generator for each
security. But what if you want to see the signals of ten different securities, each with its own trading system?
This can now be done very easily with the Expert Commentary.
The format for such a commentary would look like this:
Writeif( Filter condition here ," Message Here ")
A WriteIf statement is used to display a message if a condition is true. The filter condition is whatever you
would normally put in the filter. The message is whatever you want to display.
For example, if you had a moving average crossover that you liked, the filter for it may look like this:
Cross(Mov(C,50,S),Mov(C,200,S))
This exploration would show you all of the securities in which the 50-period moving average crossed above the 200-
period moving average. But remember, you don’t want the information for all securities, only one security with this
signal. Assume that it is for IBM. First (to make writing easier) the closing price of IBM is assigned to a
variable, and then the signal is expanded upon:
A:=Security("IBM",Close);
Cross(Mov(A,50,S),Mov(A,200,S))
Since "A" is assigned as a variable to the closing prices of IBM it must be used wherever that information is
desired (replacing the "C" for closing prices in the moving averages).
Once this is done, an expert commentary can be made like this:
Writeif(A:=Security("IBM",Close);Cross(Mov(A,50,S),Mov(A,200
,S)),"Buy Signal on IBM")
First, the Writeif statement is placed. Note that immediately into the function, a variable is assigned (the
"A" for the closing prices of IBM). The semicolon separates the variable from the function. The cross function
is then put in. After this, a message statement is put in for when the condition becomes true.
Regardless as to what security this is applied to, the values for IBM will be used for that part of the
commentary. "Buy Signal in IBM" will be displayed only if the buy signal occurred on that day. Otherwise, nothing
would be displayed.
We could make a complete expert using this technique like this:
Writeif(A:=Security("IBM",Close);Cross(Mov(A,50,S),Mov(A,200
,S)),"Buy Signal on IBM
")\
\
Writeif(A:=Security("IBM",Close);Cross(Mov(A,200,S),Mov(A,50
,S)),"Sell Signal on IBM
")\
\
Writeif(A:=Security("MSFT",Stoch(14,3));Cross(A,20),"Buy
Signal on Microsoft
")\
\
Writeif(A:=Security("MSFT",Stoch(14,3));Cross(80,A),"Sell
Signal on Microsoft
")\
\
Writeif(A:=Security("DAL",RSI(14));Cross(A,30),"Buy Signal
on Delta Airlines
")\
\
Writeif(A:=Security("DAL",RSI(14));Cross(70,A),"Buy Signal
on Delta Airlines
")\
Here, the expert displays a buy signal and a sell signal for IBM using a moving average crossover, a buy signal
and a sell signal for Microsoft using a Stochastic oscillator, and a buy signal and a sell signal for Delta
Airlines using an RSI.
(The backslash is used to put the display together removing any carriage returns that you don’t want, and
carriage returns are put in after the message but before the last quote on each line so that it IS displayed
when you do want it.)
When this is applied to any security, the signals for each security in the expert are displayed giving you a
quick look at what should be done the next day.
(This expert commentary assumes that the symbols you use are in the same folder as the security that you applied
the expert to. See the MetaStock manual for information on using securities in multiple folders or using securities
online with Data on Demand).
|