ools I T

MetaStock Tips & Tools
IN THIS SAMPLE ISSUE
Multi-Frame Templates for Custom Formulas
ZigZag-Based Volume Histogram
New Multi-Frame Features
Trade Equity Enhancements
Pairs Trading Tests
Sudoku Puzzle
Active Trader Market Breadth System
Market Breadth Portfolios
Miscellaneous New & Revised MetaStock Code
Self-Installing Formula Contents
1
6
6
8
11
12
17
21
23-34
35
MULTI-FRAME TEMPLATES
FOR CUSTOM FORMULAS
By Roy Larsen
Tools For
MetaStock
MetaStock Tips & Tools
Published by
R A Larsen & Associates
Palmerston North 4412
NEW ZEALAND
Tel: +64 6 358 3723
[email protected]
www.metastocktips.co.nz
© 2004-2013 Roy Larsen
Volume 8, Issue 4
September 2012 (Sample)
I
’ve recently taken the Multi-Frame Compression/Expansion process
one step beyond what was previously possible for the average user.
If you’ve looked closely at existing formulas in the "CE" format you
might have noticed that only one price per indicator is ever
compressed. Although this is usually sufficient when adapting one
MetaStock function it can be very limiting if the aim is to adapt a
custom formula with two or more standard functions and requiring two
or more data arrays.
It occurred to me that, since only a small number of MSTT readers are
likely to have the confidence and skill to adapt a Multi-Frame formula
to their own needs, wouldn’t the task of inserting custom MetaStock
code into the Multi-Frame format be much simpler if there was a
template to work from? So that’s what I’ve created .
Naturally there are a few restrictions on what you can and can't do
using this approach. For example, you can only use functions that
allow a Data Array and/or Expression parameter to be nominated.
Functions that cannot be used are those that default to the underlying
O, H, L, C or V data arrays and don’t give you any choice in the
matter. Functions that don’t allow the use of compressed data arrays
(as provided within a template) can only produce a usable result for the
current timeframe of a chart (or exploration data etc.).
Another restriction is that your efforts are limited to just 350 or so
characters of code. Unfortunately the structure of each supporting
template takes up most of the available space. Additional space can be
recovered by deleting unnecessary comments. Although this is not my
preferred option it may be a necessary one in some instances.
All charts in this publication are courtesy of MetaStock
September
unless
2012
stated otherwise.
Page 1
A third obstacle that might be rather more difficult to negotiate is that there
are only 4 available variable names over and above those already used by
each template. The good news is that several of the existing single-character
names are available for recycling if and when they are needed. Names
available for recycling include virtually all those not used in the "Expanded
result" section of each template.
The result of your code must be renamed "K", and only one result from the
custom code can be expanded to the required timeframe. However, the two
template variables that accept input values ("N" and "R") can be used for a
custom formula in addition to the names already available. If "N" is used by
your code as something other than an Input() parameter then you must
remove both instances of "-N" from the "Expanded result" section.
Once the O, H, L, C and V data arrays have been compressed they are
represented by the Q, B, Y, K and U variable names. These are the only data
arrays that your custom formulas can use. All references to O, H, L, C or V
must be changed to Q, B, Y, K or U. Existing variable names can be retained
as long as they don’t cause the limit of 20 variable-names to be exceeded.
These templates are only available for the D+ and ID Multi-Frame series, and
Compression Only (C) versions are listed in addition to the Compression/
Expansion (CE) versions. With Compression Only formulas all variable
names otherwise used by the "Expand result" section would also be available
for your custom code.
To help you get a feel for working with these templates I’ve created one
example using custom code for the SellP() MetaStock function. Then there’s
a second example using a "Gann-Trend" formula. Multi-Frame versions of
the first example already exist, but the point of this exercise is to show you
how to insert custom formulas into one of the templates.
The custom formula I pulled from my Indicator Builder is shown in Figure 1,
and the code after adaptation for template use is shown in Figure 2.
{Selling Pressure}
N:=10;
K:=WC();
Figure 1.
TR:=Wilders(HHV(H,2)-LLV(L,2),N);
Custom code for the
VR:=V/Ref(Wilders(V,N),-1);
MetaStock SellP() function.
WR:=(K-Ref(K,-1))/Min(K,Ref(K,-1));
CN:=Abs(WR)*K*3/TR;
If(WR<=0,VR,VR/Exp(CN));
{Selling Pressure}
N:=10;
K:=(B+Y+2*K)/4;
TR:=Wilders(HHV(B,2)-LLV(Y,2),N);
VR:=U/Ref(Wilders(U,N),-1);
WR:=(K-Ref(K,-1))/Min(K,Ref(K,-1));
CN:=Abs(WR)*K*3/TR;
K:=If(WR<=0,VR,VR/Exp(CN));
Necessary changes have been made to the code in Figure 2 to apply the
compressed BYKU data arrays rather than the conventional HLCV data
arrays. Dropping this formula into the template and checking that it worked
as intended took only me a few minutes. Notice that I didn’t even need to
change any of the custom formula’s variable names. Apart from the
restrictions I mentioned earlier there’s no reason why you couldn’t adapt
some of your own custom indicators to the Multi-Frame format using this
method The completed template is shown over the page as Figure 3, and the
six basic templates can be found on pages 23 - 28.
September 2012
Figure 2.
The same custom code after
being changed to the MultiFrame template format.
Changed data array names
are shown as bold and
underlined text.
Page 2
The second conversion example is shown
in Figures 4, 5 and 6 where a "GANNTrend" indicator has been modified for
the "D" and "D+" Multi-Frame series.
It’s only a few days since a user asked if
this was possible, so the indicators shown
in Figures 6 & 7 represent a real-life
application of templates to the conversion
process.
{Multi-Frame D+CE SellP}
{Constructed using Multi-Frame CE template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 17/8/12}
{Proprietary code removed}
Indications are that this and related
GANN formulas have been around for a
long time, even including weekly
versions for EOD charts. What my
templates demonstrate is a rather painless
way to adapt many MS indicators to
longer timeframes. Well, "painless" may
not be quite the right word because I’m
sure that some quite innocuous looking
formulas will simply refuse to cooperate.
Nevertheless, the conversion of many
Metastock indicators to the Multi-Frame
format has just gotten a whole lot easier.
Figure 3.
Here the custom code for the MetaStock SellP()
function has been inserted into the Multi-Frame
template. Only a few simple changes to data array
names were needed to complete the project.
Changed data array names are shown as bold and
underlined text.
September 2012
Page 3
{Gann-Trend 4/27/99}
{Swing Direction}
{Gann-Swing 4/27/99}
{Market swing is defined as:}
{Up = 2 higher highs, Down = 2 lower lows.}
Us:=BarsSince(Sum(H>Ref(H,-1),2)=2);
Ds:=BarsSince(Sum(L<Ref(L,-1),2)=2);
Hc:=HighestSince(1,Us=0,H);
Lc:=LowestSince(1,Ds=0,L);
Sd1:=If(Us=0,
{then}If((L<>Lc) AND (Ref(L,-1)<>Lc),
{then}1,
{else}0),
{else}If(Ds=0,
{then}If((H<>HC) AND (Ref(H,-1)<>Hc),
{then}-1,
{else}0),
{else}0));
Sd2:=If(Sd1=1,
{then} If(Ref(BarsSince(Sd1=1),-1) >
Ref(BarsSince(Sd1=-1),-1),
{then}1,
{else}0),
{else} If(Sd1=-1,
{then}If(Ref(BarsSince(Sd1=1),-1) <
Ref(BarsSince(Sd1=-1),-1),
{then}-1,
{else}0),
{else}0));
TD1:=ValueWhen(1,Sd2<>0,Sd2); Td1;
{Multi-Frame D CE Gann-Trend}
{Constructed using Multi-Frame D-CE template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 7/9/12}
{Proprietary code removed}
Figure 4.
The Gann-Trend formula as given to me.
{Gann-Trend}
{Swing Direction}
{Created by Adam Hefner?}
Us:=BarsSince(Sum(H>Ref(H,-1),2)=2);
Ds:=BarsSince(Sum(L<Ref(L,-1),2)=2);
Hc:=HighestSince(1,Us=0,H);
Lc:=LowestSince(1,Ds=0,L);
Sd1:=If(Us=0,
If((L<>Lc) AND (Ref(L,-1)<>Lc),1,0),
If(Ds=0,If((H<>HC) AND (Ref(H,-1)<>Hc),-1,0),0));
Sd2:=If(Sd1=1,If(Ref(BarsSince(Sd1=1),-1)>
Ref(BarsSince(Sd1=-1),-1),1,0),
If(Sd1=-1,If(Ref(BarsSince(Sd1=1),-1)<
Ref(BarsSince(Sd1=-1),-1),-1,0),0));
ValueWhen(1,Sd2<>0,Sd2);
Figure 5.
The same formula as in Figure 4 but with {else} and
{then} comments removed, and the variable / data
array names to be changed marked in bold type.
Figure 6.
Inserting code for the GANN-Trend indicator into the MultiFrame D-CE template. Only a few simple changes to variable /
data array names were necessary - see bold type.
September 2012
Page 4
{Multi-Frame D+CE Gann-Trend}
{Constructed using Multi-Frame D+CE template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 7/9/12}
{Proprietary code removed}
Figure 7.
Code for the Gann-Trend indicator into
the Multi-Frame D+CE template.
September 2012
Page 5
ZIG-BASED VOLUME HISTOGRAM
By Roy Larsen
T
he indicator code shown in Figure 4 was put together in
response to a request posted on the Equis Forum. The
enquirer asked for a cumulative volume plot based on timeframes
formed by Zig() function reversals. Also requested was that results
should be capable of being plotted as green and red histograms,
green for positive price moves and red for negative moves.
The most difficult part of creating this formula was figuring out
how to identify each Zig() turning point (see the "A" and "B"
variables). Once that was determined the rest was simply a matter
of adapting the Multi-Frame volume calculation and, of course,
separating positive volume from negative volume.
{Zig-Based Volume Histogram}
{Roy Larsen, 30/7/12}
N:=Input("ZigZag % Parameter",0,99,10);
A:=Zig(C,N,%);
B:=Ref(A,-1)>A AND Ref(A,1)>A OR
A>Ref(A,-1) AND A>Ref(A,1);
X:=A>ValueWhen(2,1,A); Z:=Cum(1);
{Calculate/plot frame Volume}
D:=BarsSince(Ref(B,-1)+(Z=1))+1;
ExtFml("Forum.Sum",V,D)*X;
ExtFml("Forum.Sum",V,D)*(X=0);
While Zig() has been used in this instance, I’m quite sure that volume for many
other frame definitions could be captured just as easily. In this case I didn’t even
need to worry about the N/A bar introduced by the "B" variable at the hard right
edge. "B" has to be delayed by one bar before the "D" variable can function
properly anyway, and that delay eliminates the previously-created N/A bar by
shifting it one bar to the right and off the right side of the chart.
Figure 8.
A volume accumulator with
timeframes determined by
Zigzag-based price
reversals.
NEW MULTI-FRAME FEATURES
By Roy Larsen
W
ith this issue I’ve released a completely new "D~" series of Multi-Frame
indicators. In conjunction with this series I’ve also released new features
for the "D" range. Most readers would have received a note from me asking for
feedback on the potential usefulness of timeframes based on the number of bars
rather than a calendar period. Undoubtedly some of you must have thought that I
was nuts for even raising the idea. Perhaps I am. Nevertheless I must have
received responses from about a third of the MSTT readership, and of those
twice as many were in favor of the suggestion as those against it.
Over the years I’ve strongly resisted any pressure to create any rolling timeframe
indicators, and I still have serious doubts about their usefulness. The poll result,
however, suggested that it was time for me to re-evaluate my position on "rolling
frame" indicators. As a concession to my own thoughts on the matter I’ve
included a mechanism that forces a rolling frame to periodically synchronize
with calendar events. This option can be disabled or, at the user’s discretion,
applied at 1, 2, 3, 4, 6 or 12 monthly intervals.
As you’ve already seen I’ve named this series "D~" – the tilde character
evocative of a rolling or wave-like motion. To me a rolling timeframe is
one that depends purely on where data starts for some, and where it ends.
For others. Such timeframes only give the appearance of consistency when
they have a reference point that remains constant. That illusion is quickly
shattered when the reference point changes for any reason.
September 2012
rolling timeframe
indicators …
... doubts about
their usefulness
Page 6
v
Figure 9.
A view of the "D~" series
Parameter window.
At the end of the day,
though, these indicators
are not about what I think.
They’ve been created for
those among us who see
value in the use of
arbitrary timeframes. The
maximum frame size is
65 days but I’d expect
shorter timeframes to be
the norm. The default has
been set to 3 days.
While testing I’ve found
that "D~" indicators can
accurately reproduce
certain calendar-based
timeframes by virtue of
the resync mechanism.
Daily, monthly and quarterly timeframes are typical examples of that. Monthly
timeframes can be set by combining a 1-month resync option with the number
of days set to 23 or higher. For instruments that are traded on more than 5 days
a week the number of days per frame would obviously need to be higher.
Some time ago I seriously considered discontinuing the "D" series of indicators.
In the event, however, I’ve decided to add the split-week feature to this series in
preference to adding even more features to the "D+" series. The split-week
feature caters for two end-of-frame variations. One option splits each week
between Tuesday and Wednesday, and the other makes the split between
Wednesday and Thursday. In essence the split provides either 2 plus 3 days or 3
plus 2 days. I’m have stocks in mind here, but of course the splitting points are
the same for Forex or any other intraday or EOD data.
Figure 10.
A view of the revised "D"
series Parameter window.
No other structural changes have been made to the "D" series of indicators, but
considerable effort has gone into identifying problems with individual
indicators across all series
and making the necessary
corrections.
The
Wilson
CSC
indicators have been
removed from each series
for now. Although I was
able to correct one error
appearing in a couple of
these formulas, there is
still another problem that
I’ve not had time to track
down. As it appears that
few people use these
formulas I don’t see any
urgent need to find and
correct the problem.
September 2012
Page 7
TRADE EQUITY ENHANCEMENTS
By Roy Larsen
I
’m pleased to announce some small but significant improvements to the
Trade Equity family of tools for MetaStock. Some of the changes are
purely cosmetic and make very little difference in the wider scheme of things.
One change in particular, though, stands out as a game-breaker. So as not to
keep you guessing I’ll start telling the story about that change right away.
A few months ago a fellow trader asked me if Trade Equity could be used for
testing pairs. My reply was that I thought it could but that I’d need to sit
down and work through the possibilities before offering a definitive answer.
Subsequently, though, my investigations suggested that it was more difficult
to do than I had at first imagined. I’m not a pair’s trader but it seems to me
that there are two possible objectives with pairs trading. One is to use the
practice as a risk-management technique, and the other is to magnify
potential gains (I’m not talking about Forex trading here). Putting my
assumptions to one side, what I needed to figure out was how to test the
effectiveness of trading signals generated by one security when they are
applied to one or more different securities (not necessarily on the same side
of the market).
To begin with I considered adapting the Trade Equity DE (dual) formulas for
the task, but as I thought about it there seemed to be two main obstacles to
this approach. First of all I knew that the DE indicator would run more
slowly than its LE and SE stable mates. My other concerns were that any DE
conversion would be difficult to implement, and the result of that conversion
probably somewhat clumsy even on a good day. What I needed was a
primary TE indicator that could operate on either side of the market, and to
complement it a secondary equity indicator that was equally ambidextrous.
The concept I decided to go with was that one TE indicator should
generate signals for one side of the market, for example, such as trading an
index. Those same signals would then be applied to a security or portfolio
of choice, also on just one side of the market, but not necessarily the same
side as that used for creating the original signals.
Then it hit me. I already had two very similar indicators in Trade Equity
GV LE and Trade Equity GV SE, so why not add a short capability to the
LE indicator and a long capability to the SE indicator? Brilliant (thinks I),
but would it work? Right about now I imagine you’re thinking that if the
idea was a lemon then you wouldn’t be reading about it, and you’d be right
of course. Thankfully the concept does work, though not without the odd
problem raising its head, or the occasional need for compromise.
... why not add a
short capability to
the LE indicator
and a long
capability to the
SE indicator?
I wonder why I didn’t think of this possibility years ago! They say that
necessity is the mother of invention, and up until this point there had never
seemed to be a need (not to me at least) for an equity curve indicator that
could flip from long to short or vice versa. Luckily there are only a few lines
of code related specifically to the side of the market that Trade Equity
operates on. To cut a long story short my solution was to insert both long and
short side code into each TE indicator, then add an option for selecting the
required side of the market. Although I’m not totally comfortable with the
September 2012
Page 8
control mechanism that I settled on, it works precisely as I had hoped it
might. The User Options setting has been expanded from 0-27 out to 0-127.
By selecting display options in the range of 100-127 the LE indicator
switches from long to short and the SE indicator similarly switches from
short to long. Mission accomplished. Well, almost.
Of course these changes mean that, for the most part, both linkable display
modules must ignore the extra 100 in the Option Display value passed to
them by the parent indicator. What I haven’t documented yet is whether the
long-side display modules will return correct values for the opposite side of
the market. I’ve been down that path with two of the portfolio experts and the
only calculations that wouldn’t play ball were the "Trade Efficiency"
statistics. The quickest solution was simply to take them out of the expert
altogether. Who understands what the Trade Efficiency stats tell us anyway?
Who
understands
what the
Trade
Efficiency
stats tell us
anyway?
The stand-alone display modules don’t use the parent indicators display
options because they have their own parameter selection for options.
However, they do have access to the display option global variable created by
the parent indicator, so they’re also able to make decisions based on the
sourcing indicator’s market polarity.
I’ve checked the linkable display modules for both Trade Equity indicators
and found that only two options, 15 and 16, appeared to need changing. To
make the maximum excursions displays for both sides of the market operate
correctly it would be necessary to switch 15 for 16 (and vice versa) if
operating on the alternate side of the market.
At the time I was still considering whether to use the "Mn" and "Mx" global
variables to feed into each display module’s "Nd" and "Ns" variables as
extreme excursions instead of the "Xs" global variable used up until now.
The "Mn" and "Mx" global variables were added to the Trade Equity
indicators some time back to allow portfolio-based experts to calculate
maximum excursions based on HIGH and LOW prices rather than on trade
entry, exit or CLOSE prices.
I decided to switch to the "Mn" and "Mx" global variables for determining
extreme price movements. Looking at the changes made earlier to the display
modules it’s apparent that the "Mn" and "Mx" variables do away with the
need to switch options 15 and 16 if the parent indicator has had its market
polarity changed. Nevertheless it is still necessary to strip 100 from the TE
Display Options parameter so that it returns to the 0-27 range. See the text
box below for how this is achieved.
{Trade Equity GV LE Display}
{Roy Larsen, 2004-2012, 25/7/12}
{use with Trade Equity GV LE, v8.5}
Z:=ExtFml("GV.GetVar","Le");
D:=DayOfMonth();A:=LastValue(D);
M:=Month();B:=LastValue(M);Y:=Year();
G:=M*31+D-(M>B OR (M=B AND D>A))*372;
G:=G<ValueWhen(2,1,G);Z:=If(Z>99,Z-100,Z);
As an unfortunate byproduct of adding calculations for the other side of the
market into Trade Equity indicators they now have very little available free
September 2012
Page 9
space (situation normal I suppose). One way to deliver trading signals to TE
via external formulas is to arrange those formulas (and Trade Equity) so that
they take up minimal room.
Traditionally the "Signals" section of Trade Equity would have looked much
like that shown below, and it still can as long as the formula names for your
inputs are kept short.
{Signals}
N:=Fml("MSTT IH Buy AU SP300 W");
Ns:=0;
X:=Fml("MSTT AT Trail AU W");
Xs:=Fml("MSTT Intrabar Stop W");
The overheads required by Fml() and FmlVar() calls are not humungous, but
they can and do slow things down a little. To marginally reduce the impact of
such overheads while conserving space at the same time, I’ve devised a
recommended new layout for TE signal formulas. My suggested layout has
the ability to deliver either binary or price signals. Rather than requiring two
or three separate Fml() calls for each system, most signals can now be
delivered by one input formula. One exception would be if your system
needed to deliver concurrent entry and exit signals. Intrabar trades must still
be delivered by two formulas. Why? Because entry signals are represented by
positive spikes and exit signals are represented by negative spikes. Clearly a
single signal cannot simultaneously deliver both positive and negative values.
Another possible exception might be when both binary and price exit signals
are required. However, I can’t imagine any combination of setup conditions
that couldn’t be managed by inserting any relevant delays (such as "exit on
the next open") into the system formula and delivering all exit signals as
prices to the "Xs" input variable. Price signals can also be used to function as
binary signals if you so desire. Sadly, binary signals can’t deliver prices.
... a single
signal cannot
simultaneously
deliver both
positive and
negative
values.
{PS MOO (Meisels Overbought/Oversold)}
M1:=Sum(If(C>Ref(C,-1),+1,If(C<Ref(C,-1),-1,0)),10);
EntryLong:=Cross(-6,M1) OR M1=-6;
ExitLong:=Cross(M1,0) OR M1=0;
EntryShort:=Cross(M1,6) OR M1=6;
ExitShort:=Cross(0,M1) OR M1=0;
Long:=EntryLong-ExitLong;
Short:=EntryShort-ExitShort;
Long;
Using the modified layout of the "PS Meisels Overbought/Oversold" system
as an example (see above), the Trade Equity Signals setup area seen below
demonstrates how to feed both entry and exit signals to TE and extract the
appropriate entry and exit signals from the one input. For testing the short
side you’d need to use FmlVar() at the cost of around 12 extra characters.
{Signals}
I:=Fml("PS MOO");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=0;
September 2012
Page 10
{Signals}
I:=Fml("PS MOO");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=I*(I<0); {if an Exit Stop is enabled}
{Code}
Notice that the "I" variable name is now used to receive system signals.
Externally generated inputs are not needed beyond this point so the "I"
variable then becomes available immediately after the {Code} comment. The
"MS MOO" system doesn’t use price stops, so the "Ns" and "Xs" variables
are normally be set to zero for that system anyway.
In the example above it should be pointed out that that "X" and "Xs" can only
be used together if they are, in fact, the same signal (–price). Applying a price
signal to X is quite OK; the "<" operator converts it into a binary signal even
though that is not strictly necessary. A problem arises, though, when the
timing of "X" and "Xs" is different. That won’t happen with properly
constructed system signals, and it’s up to the user to make sure that the signal
source is 100% valid.
If a delay is normally applied to "X" then it’s important to know that "Xs"
ignores any TE exit delay setting. When that variable is active an "exit stop"
will take effect immediately, and of course the same signal applied as a
conventional binary exit signal will have been beaten to the draw because of
the delay setting.
Finally, note that revised Trade Equity indicators can be found at the end of
this newsletter. Page 35 has a listing of all formulas that have been discussed
in this issue. Appropriate download links should have already been provided
in my distribution letter. Failing that the necessary information will be
available for the asking.
PAIRS TRADING TESTS
By Roy Larsen
T
he "Trade Equity Pairs" indicators have been created to allow testing of
pairs in any mix of long and/or short combination. For this to work the
TE primary indicator must be set up for the underlying security and system
signals, and the secondary TE indicator fed the same signals via an
intermediate Trade Equity Pairs indicator. The function of the Pairs indicator
is to extract signals applied to the primary security (e.g. by monitoring Trade
Equity GV LE), and then feeding those signals to the secondary TE indicator
to test one or more secondary securities. The aim is to find those securities
that demonstrate a strong colinearity to the primary security.
The two indicators in Figures 12 and 13 extract long or short signals
(whichever is appropriate) from the primary security and act as a conduit for
transferring trading signals from one Trade Equity indicator to the other.
September 2012
Page 11
Although both Trade Equity indicators are capable of executing same-bar
trades, it is not currently possible to transfer such trade signals from one TE
indicator to the other. That’s because same-bar signals cannot be extracted
simply by monitoring the "R" trade-latch variable. Nevertheless, since this
feature is seldom if ever used it really doesn’t affect the usefulness of the
Pairs process. It would not be difficult to create an alternative transfer method
(signal conduit) if the need should arise.
What appears to be an anomaly with the method I’ve devised is that delays
applied to the master security and TE indicator do not get applied to the
secondary TE indicator. Signals applied to the primary TE indicator already
have any delays included before they reach the "R" variable (trade latch).
Therefore the secondary TE indicator, be it LE or SE, should not apply any
(unintentional) additional delays to the Pairs signals. Signals applied to the
secondary TE indicator cannot legitimately precede those applied to the
master TE indicator. However, there might well be situations where a delay
could legitimately be applied to secondary signals.
As with normal Trade Equity usage, test results can be displayed by Expert
Commentaries. Those results can be used to assess the degree of correlation
between the primary security and a secondary portfolio or one of its
constituents. For individual securities it’s simply necessary to attach the
appropriate "Chart" commentary to the targeted chart. For portfolio results
you must run the appropriate "Portfolio" or "Super" exploration and use the
associated expert commentary to display a summary of test results.
If necessary the "Portfolio" and "Super" scans can be modified to report
a specific statistic from each or any column. To do this you will need to
locate the relevant calculation and create an output at the point where a
result for each security is added into the portfolio accumulator for that
statistic. The result that you want to display in the exploration report
must be the last output for that column. Although a column can
generate several outputs, only the last output in sequence will appear in
the report. All other outputs are masked (i.e. overridden) by the output
that appears in the report.
SUDOKU BREAK
7
3
3
6
1
6
1
5 8
5
In order to make the task of finding those calculations a little easier I’ve
placed list of each column’s calculations at the beginning of the
column. In column A, for example, you’ll find a "Max favorable
excursion" heading and an {MFE} calculation section – see the text box
below and on Page 13.
6
5
2
9
5 4
7 3
7
6
6 3
9
3
6
9
4
1
2
Figure 11.
Sudoku puzzle - (medium)
see solutions on page 22.
{MFE}
SV:=LastValue(ExtFml("GP.GetVar","MXFV"));
RS:=LastValue(Highest(ExtFml("GV.GetVar","Mx")));
SV:=ExtFml("GP.SetVar","MXFV",Max(SV,RS));
To report the MFE for each security you will need to add "RS;" (without
quotes) to the end of the "RS" or second "SV" line as shown above. The "RS"
variable usually returns the final value of a particular calculation for the
current security. The first "SV" variable is the cumulative value of all results
up to the previous security. The second "SV" variable adds the current "RS"
value to the "SV" accumulator, thus updating it to include the total value for
all securities so far.
September 2012
Page 12
As already mentioned there must not be any active outputs appearing further
down the exploration column. Existing outputs that might follow the "RS"
output (for MFE in this case) should be deleted or commented. When
changing the output expression or variable reported by column B, be aware
that there are a couple of existing outputs in the portfolio scans that are easily
overlooked because they are presented (coded) as unnamed variables.
{MFE}
SV:=LastValue(ExtFml("GP.GetVar","MXFV"));
RS:=LastValue(Highest(ExtFml("GV.GetVar","Mx"))); RS;
SV:=ExtFml("GP.SetVar","MXFV",Max(SV,RS));
Just when I thought I’d finished the discussion on Trade Equity Pairs
someone asked about testing pairs with the EST. I responded by saying that
this article would appear in the next issue of MSTT and left it that. There was
no question in my mind that a composite TE/EST test could be put together,
but my concern was that actually doing so would be a rather difficult task for
many readers. And to be honest even I struggle to follow my own procedures
at times, so how difficult would that be for less experienced users?
Accordingly I’ve created a TE/EST composite Pairs system test. Although
the system that’s been devised has some advantages over a pure TE-based
arrangement, I have to say that it doesn’t offer as many advantages as I
thought it would. As I see it there is one major limitation with a pure Trade
Equity approach in that it only allows a portfolio to be tested against one
security at a time.
As an exercise I ran each of 73 ETFs against the same 73-ETF portfolio using
the "PS MOO" system. For this I had to enter a specific target ETF in the
"Trade Equity Pairs GV SE" indicator 73 times. This exercise took me a
about 2 hours. I had hoped that by using the EST I’d be able to minimize my
setup time and, in doing so, significantly reduce total test times. Sadly the
EST wasn’t as cooperative as I’d expected, so the hoped-for time savings
didn’t eventuate. For you, however, the EST-based method might save some
time, though whether or not the EST provides as much information as a TE
portfolio report is a moot point.
The portfolio I ran these tests on is made up of ETFs with at least 2500 bars
of data, and that data all having common dates. By that I mean that the date
of each bar across all ETFs is the same. Put another way, there are no missing
bars and no extra bars. This is an important consideration when wanting to
display portfolio results using one of the Trade Equity Portfolio Display
indicators.
The difficulty with Pairs testing is that, while it’s easy to step through a
portfolio of securities, it’s much more difficult to switch automatically to a
different system for a second or subsequent pass across the same portfolio.
For that reason Trade Equity Pairs testing is pretty much limited to one
primary set of signals at a time. Changing either the system, or the primary
security that generates that system’s signals, can only be done manually. In
theory the EST can change the system being applied on the fly by virtue of
the OPT function. The reality, however, is that running four different master
securities in the one test (effectively giving four system variations) is about
as much as the EST can handle without triggering a catastrophic meltdown.
September 2012
Page 13
Figures 16 and 18 respectively attempt to show the organization and data
flow of a Trade-Equity-only Pairs process and a Trade-Equity/EST pairs
process. Of necessity the TE/EST composite method is organized a little
differently from the TE-only method. Hopefully those diagrams add a
measure of clarity. When testing pairs signals are applied to one security, and
those signals are then replicated for one or more different securities.
So, if ABC and XYZ are the pair to be tested, primary signals would
normally be created by ABC, and those signals, not the system itself, would
be applied to XYZ. Strictly speaking the system under test is only applied to
ABC. In all likelihood the system would generate a quite different set of
signals if it was applied directly to XYZ. What’s essential, though, is that the
signals applied to XYZ (and any other security being pairs-tested against
ABC) must align with the signals generated by ABC.
Figure 12.
This indicator extracts
trading signals specific
to the YHOO symbol
from Trade Equity GV LE
and formats them for Pairs
use by Trade Equity GV SE.
{Trade Equity Pairs GV LE}
{Roy Larsen, 2012 20/8/12}
{Proprietary code removed from sample newsletter}
{Trade Equity Pairs GV SE}
{Roy Larsen, 2012, 30/7/12}
{Proprietary code removed from sample newsletter}
Figure 13.
This indicator extracts
trading signals specific
to the YHOO symbol
from Trade Equity GV SE
and formats them for Pairs
use by Trade Equity GV LE.
{Trade Equity GV LE}
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
{Inputs}
A:=Input("Trade Equity GV LE, Opt 0-27, SE=100+",0,127,0);
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,0);
J:=Input("Exit Cost",0,999,0);
D:=Input("Entry/Exit Delays 00-55",0,55,11);
Figure 14.
K:=1000; F:=1; {Equity/Factor}
Shows Trade Equity GV LE set up to trade
{Signals}
the PS MOO system long on YHOO, using it
I:=Fml("PS MOO");
as the primary security to generate identical
N:=I>0;
signals for another portfolio by way of
Ns:=0;
Trade Equity Pairs GV LE.
X:=I<0;
Signals would be applied to secondary
Xs:=0;
securities by Trade Equity GV SE or the EST.
September 2012
Page 14
Color Code
PS long or short systems
System Indicators
TE Pairs Setup Indicators
Explorations
Custom binary or price-stop entry/exit signals
Expert Commentaries
Optional Printed Reports
Trade Equity GV LE
(long or short
as appropriate)
Trade Equity GV SE
(long or short
as appropriate)
Trade Equity Pairs GV LE
(to replicate primary
security’s signals)
Trade Equity Pairs GV SE
(to replicate primary
security’s signals)
Trade Equity GV SE
(applies Pairs signals to
security or portfolio)
Trade Equity GV LE
(applies Pairs signals to
security or portfolio)
Trade Equity Reset
(prepares global
variable storage)
Figure 15.
This shows user settings required for Trade
Equity GV SE to be paired long with Trade
Equity GV LE. Figure 14 shows Trade Equity
GV LE set up to trade the PS MOO system
long on YHOO, and Figure 12 shows how
Trade Equity Pairs GV LE prepares the
signals generated by YHOO for use with
Trade Equity GV SE on a separate security
or portfolio, also on the long side.
Trade Equity
Super/Portfolio
SE Scans
Trade Equity
Super/Portfolio
LE Scans
Trade Equity SE
Portfolio
Expert Commentary
Trade Equity LE
Portfolio
Expert Commentary
Super/Portfolio Scan
Commentary
Printed Reports
{Trade Equity GV SE}
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
{Inputs}
A:=Input("Trade Equity GV LE, Opt 0-27, SE=100+",0,127,100);
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,0);
J:=Input("Exit Cost",0,999,0);
D:=Input("Entry/Exit Delays 00-55",0,55,00);
K:=1000; F:=1; {Equity/Factor}
{Signals}
I:=Fml("Trade Equity Pairs GV LE");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=0;
September 2012
Figure 16.
This flow chart shows the steps necessary
to create primary trading signals for one
security, pass them to the secondary
Trade Equity indicator, then sum
portfolio results using the Explorer and
Expert Commentaries.
Page 15
Color Code
PS long or short systems
System Indicators
TE Pairs Setup Indicators
Custom binary or price-stop entry/exit signals
EST Signal Processing
EST Reports
Trade Equity GV LE
(long or short
as appropriate)
Figure 17.
These steps are needed to create primary trading
signals for one security, pass them to the
Enhanced System Tester, and then examine
individual results for each security.
The EST generates very little portfolio information.
Trade Equity GV SE
(long or short
as appropriate)
Enhanced System Tester
Buy Order or Sell Short Order Windows
replicate primary signals generated by
Trade Equity GV LE or
Trade Equity GV SE
Enhanced System Tester Reports
Figure 18.
{Trade Equity GV SE}
Trade Equity GV SE setup parameters
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
required to generate long trading
{Inputs}
signals from one of four primary
A:=Input("Trade Equity GV SE, Opt 0-27, LE=100+",0,127,100);
securities (see Figure 19) under test.
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,0);
J:=Input("Exit Cost",0,999,0);
Figure 19.
D:=Input("Entry/Exit Delays 00-55",0,55,11);
This
EST
system
accepts signals from the
K:=1000; F:=1; {Equity/Factor}
primary
Trade
Equity
indicator (SE in this
{Signals}
example)
and
applies
one
of up to 4 sets of
I:=Fml("PS MOO");
signals
to
a
secondary
security
or portfolio.
N:=I>0;
This
EST
system
replaces
both
Ns:=0;
the
TE
Pairs
setup
indicators
and
the TEX:=I<0;
based
secondary
portfolio
scan
function.
Xs:=0;
It can test a portfolio relative to up to 4
primary securities.
{Trade Equity Pairs for EST}
{Roy Larsen, 2012, 27/8/12}
{Proprietary code removed from sample newsletter}
September 2012
Page 16
AT MARKET BREADTH SYSTEM
By Roy Larsen
T
he trading system being discussed this time around is the AT Market
Breadth system as described by Volker Knapp in the September 2012 issue
of Active Trader. In essence it’s based on the ratio of news highs to new lows
for any given portfolio. I suggest that you purchase a copy of Active Trader if
you’re at all interested in checking out this dip-buying system. It’s not a system
that will make you rich in the short term, and that’s mainly because it’s only in
the market around 1% of the time. It aims to enter on market dips, hopefully just
as confidence reverses the market direction. All trades are held for 5 days and
then sold at the next OPEN.
The breadth indicator underpinning this system is a New-Highs/New-Lows ratio
calculated as: NHNL = New Highs / (New Highs + New Lows). New Highs and
New Lows represent the number of securities in any portfolio making new 20day highs and new 20-day lows respectively. The oscillator so formed by the
NHNL formula is smoothed by a 10-day Simple Moving Average
{Trade Equity GV LE}
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
{Inputs}
A:=Input("Trade Equity GV LE, Opt 0-27, SE=100+",0,127,0);
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,0);
J:=Input("Exit Cost",0,999,0);
D:=Input("Entry/Exit Delays 00-55",0,55,11);
K:=2000; F:=-0.5;{Equity/Factor}
{Signals}
I:=Fml("AT Market Breadth AT") * Fml("Date Filter");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=0;
Figure 20.
Trade Equity settings for
testing the "Market
Breadth" systems.
The entry rule is to buy on the next OPEN when
the SMA of the NHNL oscillator (which swings
between 0 and 1) falls below 0.2, and the stocks
price has been falling for three or more days in a
row. The exit rule is to sell on the OPEN once the
trade has been held for 5 full days.
Active Trader suggests that no more than 5% of
account equity per position and that the maximum
number of trades at any one time be kept to 20 or
less. They also suggest specific starting equity as
well as costs and slippage allowances. The AT
rules allow multiple positions to be held up to the
20-trade limit. My tests were run with Trade
Equity and didn’t include costs or any limit on the
number of open trades.
A list of the 17 stocks in the standard AT portfolio is provided on page 22. I’ve
used this portfolio for some of my tests, but I’ve also run tests on larger
portfolios drawn from the S&P 100 and EFTs that have been traded for more
than 10 years.
When providing breadth data for other projects I’ve generally built historical
data files for loading as MetaStock data. This time I’m only providing the tools
needed to create temporary global variables. There are reasons for doing it this
way, and the biggie is that they don’t need daily updating – that is, they can be
created on the fly as and when needed. Allied to this each portfolio must have
its own its own market breadth files. I’ve created several versions of the two
files as I’ve needed them by running the "Breadth D" scan with appropriate data
loaded. This creates two global variable breadth files. The two global variables
(ScanHighC and ScanHighC) can only be used for one portfolio at a time, so the
"Reset" and "Breadth D" must be rerun for each new portfolio.
For some time now a feature of Trade Equity has been the Portfolio Display
module. As with the last issue of MSTT I’ll be using it to plot equity curves for
September 2012
Page 17
each portfolio tested. I know I’ve discussed the need for
"validated" data to be used with this tool but I’m happy to
explain the situation again. Creating data files "on-the-fly" is a
process that demands validated data to work with. Basically
what validation does is weed out securities that have missing or
extra bars of data.
For Trade Equity global variables to accurately accumulate
values for each date or bar of data (e.g. by summing all bars of a
series of equity curves) it’s essential that those securities have
identical dates. Global variables don’t store date or time values
and so have no way of aligning themselves to those labels. One
missing bar of data renders the global variable it’s being written
to as corrupt and non-repairable for the current process. In some
circumstances it’s OK to continue using the corrupted data,
though knowing that it’s not as accurate as it could be. In other
situations that’s totally unacceptable.
The validation process is a way of identifying the securities in a
portfolio that have identical dates, and saving those securities as
a portfolio under the Favorites folder. This is best done by
creating a new folder for each portfolio and giving it a name
that identifies its contents. I have folders called "AT Standard
Portfolio", "ETF Valid 2600 4-9-12" and "SP100 Valid". Each
of these has 2600 EOD bars and common dates across all bars.
I’m using 2600 bars rather than 2500 or some lesser number so
that I can start my tests at the beginning of June 2002, this being
where the Active Trader tests start.
{Data Validity}
{Roy Larsen, 2005}
{This exploration scans a list of securities to
find those with complete data sets. Column
results are then included in the filter for use in
a second scan to filter out securities with
missing or extra data records.}
{Col A: Day}
ValueWhen(1,Cum(1)=1,DayOfMonth());
{Col B: Month}
ValueWhen(1,Cum(1)=1,Month());
{Col C: Year}
YearValueWhen(1,Cum(1)=1,Year());
{Col D: SumMonth}
Cum(DayOfMonth());
{Col E: Sum Days}
Cum(DayOfWeek());
{Col F: Sum Bars}
Cum(1);
{Filter}
{Disable filter for first run. Use results to set
filter values. Enable filter & rerun to select
valid securities.}
{colA=9 AND colB=5 AND colC=2002
AND colD=41016 AND colE=7858}
Filter enabled
Periodicity
Records required
Yes
Daily
2600
Figure 21.
The Data Validity Scan for
The validating exploration reports the start day, month and year in columns
finding
matching data dates
A, B and C, cumulative day-of-month in column D, and cumulative day-ofacross
an entire portfolio.
week in column E. One only needs to look at the exploration report to find a
large block of common numbers and then rerun the exploration after entering
the appropriate numbers into the Filter section. The results of the filtered run
should be saved for later use. The AT Standard Portfolio
{AT Breadth}
doesn’t need validation because it already has common dates
{Short variable delivers secondary signals}
as far back as my 2600-bar tests go.
The validation exploration is shown in Figure 21. Note that
braces are used to comment out the filter section on the first
pass, then removed to activate it for the second pass.
{Code removed from sample newsletter}
Another "secret" to getting consistent, reliable and
repeatable portfolio results from Trade Equity is to make
sure that the chart used for displaying a portfolio equity
curve has the same number of bars loaded as used for the TE
explorations. For this system that’s 2600 EOD bars.
Hopefully I’ll finish my testing before any more data is
added (no data updates is key to getting repeatable results
over several days). I’ve already experienced inconsistent
results this morning because I forgot to change the standard 2500 bars loaded
to 2600. I couldn’t work out why the TE expert was reporting one profit
figure and the portfolio equity curve another. The figures agreed 100% once
extra bars were loaded for the active chart.
September 2012
Figure 22.
Creates secondary signals via
"Short" variable. See Figures
25-26. Run TE "Reset" and
"Depth D" scans to prepare
breadth data.
Page 18
The next problem I faced was that the EST results for the
standard AT portfolio didn’t match TE results for any of the 17
{Col F}
securities. I resolved this problem by switching TE from $1000
{Reset New Highs and New Lows counters}
to $2000 of initial equity and changing the "F" variable to "-0.5".
{New Highs and Lows}
This tells TE to use 50% of initial equity and only purchase
A:=ExtFml("GP.SetVar","ScanHighC",0);
whole shares – something that’s normal for the EST. With those
A:=ExtFml("GP.SetVar","ScanLowC",0);
adjustments TE and the EST finally produced identical results.
Figure 23.
Thank goodness for that. Unfortunately the 93 validated stocks
Add this code to the Trade
from the S&P 100 didn’t deliver anything like yesterdays values even though
Equity Portfolio Reset scan
I changed the appropriate system settings. Oh, I see the problem; I wrongly
so that all GV resets are
marked the results report as being generated by the 93 S&P 100 stock
confined to a one exploration.
portfolio rather than the 72 ETF portfolio. Silly me!
{Trade Equity Portfolio Reset}
The "Trade Equity Portfolio Reset" and "Trade Equity Scan
Breadth D" explorations must be run before either a Trade
Equity scan or an EST test. That’s necessary so that the
breadth GV counters are reset and repopulated with the
appropriate breadth data before Trade Equity or the EST do
their thing. It’s important that the breadth data arrays
provide information that’s relevant to the portfolio being
tested – loading breadth information for one portfolio and
then using it to create signals for a different portfolio is
probably not going to work too well. I suppose you could do
that, but it seems to me that it would be somewhat akin to
eating an apple in order to find out what a banana tastes like.
{Trade Equity Portfolio Scan Breadth}
{Col A:}
{Create breadth data for validated portfolio}
{Code removed from sample newsletter}
Figure 24.
This exploration follows the
TE Portfolio Reset scan - it
generates breadth data for the
selected portfolio.
It’s named so that it can be
batched with other TE scans
to be run in the proper order.
The equity curves shown in Figures 30, 31 and 32 show
significant drawdowns in October 2008 that you need to be
aware of. Don’t forget that this system buys as the price is falling and it has
no mechanism to extricate you from a trading heading way south. Notice,
though, that the biggest gains come very shortly after the biggest drawdowns.
You can see portfolio excursions by using options 5 and 6 of the portfolio
display module, but make sure that the chart you use it on has the same
number of bars loaded as the TE exploration or explorations that created the
New Highs and New Lows data files.
{AT Market Breadth AT}
{AT 17 Portfolio signals}
{AT Market Breadth EF}
{EFT 72 & SP 93 Portfolio signals}
{Code removed from sample newsletter}
{Code removed from sample newsletter}
Figure 25.
This indicator generates Trade Equity signals for
the AT 17 Standard Portfolio. Run TE "Reset" and
"Depth D" scans un to prepare breadth data.
Figure 26.
This indicator generate Trade Equity signals for the
EF 72 and SP 93 Portfolios. Trade Equity "Reset" and
"Depth D" scans must be run to prepare breadth data.
September 2012
Page 19
{ AT Market Breadth 17}
{ AT Market Breadth 72}
Buy Order
Order Type
Order Expiration
Initial Equity
Default Size
Buy Order
Order Type
Order Expiration
Initial Equity
Default Size
Market
Day
$2000
$1000
Market
Day
$2000
$1000
Signal Formula
{AT Market Breadth}
Signal Formula
{AT Market Breadth}
{Code removed from sample newsletter}
{Code removed from sample newsletter}
Figure 27.
The EST setup for testing the AT 17 Standard
portfolio. Run the Reset and Breadth explorations
before running this system with the EST.
Figure 28.
The EST setup for testing the ETF-72 portfolio. Run
the Reset and Breadth explorations before running
this system with the EST.
{ AT Market Breadth 93}
Buy Order
Order Type
Order Expiration
Initial Equity
Default Size
Market
Day
$2000
$1000
Signal Formula
{AT Market Breadth}
{Code removed from sample newsletter}
Figure 29.
The EST setup for testing the SP-93 portfolio,
taken from the S&P 100 . Run the Reset and Breadth
explorations before running this system with the EST.
September 2012
Page 20
Figure 30.
This equity curve
represents trading results
for the AT Standard
Portfolio of 17 stocks..
Figure 31.
This equity curve
represents trading
results for the Portfolio
of 72 validated EFTs.
Figure 32.
This equity curve
represents trading results
for a Portfolio of 93 S&P
100 validated stocks.
MARKET BREADTH PORTFOLIOS
By Roy Larsen
The three portfolios used for my tests are shown over the page. Keep in mind
that the integrity of the breadth data files you create (20-day new highs and
new lows) is critically dependant on validated data (common data dates
across each portfolio), so be sure to check these and any other portfolios that
you choose to run tests with. The alternative is to create your own MetaStock
breadth data files, files that will need daily updating if they’re to be kept
current.
(See next page)
September 2012
Page 21
Active Trader Standard Portfolio
AAPL, C, BA, CAT, CSCO, KO, DIS, FITB, HPQ, INTC, IBM, IP,
JPM, MSFT, SBUX, T, WMT.
4
2
1
9
3
8
5
7
6
9
6
5
2
4
7
1
3
8
1
9
7
5
8
2
3
6
4
8
5
3
4
7
6
2
9
1
6
4
2
1
9
3
8
5
7
2
7
6
8
5
1
9
4
3
3
1
9
7
2
4
6
8
5
5
8
4
3
6
9
7
1
2
SP 93 Portfolio
AAPL, ABT, ACN, AEP, ALL, AMGN, AMZN, APA, APC, AXP,
BA, BAC, BAX, BHI, BK, BMY, BRK.B, C, CAT, CL, CMCSA,
COF, COP, CSCO, CVS, CVX, DD, DELL, DIS, DOW, DVN,
EBAY, EMC, EMR, EXC, F, FCX, FDX, GD, GE, GILD, GS, HAL,
HD, HNZ, HON, HPQ, IBM, INTC, JNJ, JPM, KFT, KO, LLY, LMT,
LOW, MCD, MDT, MET, MMM, MO, MON, MRK, MS, MSFT,
NKE, NOV, NWSA, ORCL, OXY, PEP, PFE, PG, QCOM, RTN,
SLB, SO, SPG, T, TGT, TWX, TXN, UNH, UNP, UPS, USB, UTX,
VZ, WAG, WFC, WMB, WMT, XOM.
7
3
8
6
1
5
4
2
9
ETF 72 Portfolio
ICF, IYK, IYC, IYE, IYF, IYG, IYH, IYY, IYJ, IYR, IYW, IYZ, IDU,
EWZ, EWC, EFA, EZU, EWQ, EWG, EWH, EWJ, EWM, EWW,
EPP, EWS, EWY, EWT, EWU, IBB, SOXX, IWF, IWB, IWD, IWO,
IWM, IWN, IWV, IWW, IWP, IWR, IWS, OEF, IVW, IVV, IVE,
IEV, IOO, IJK, IJH, IJJ, IGM, IGV, IJT, IJR, IJS, OIH, PPH, RTH,
SMH, QQQ, XLY, XLP, XLE, XLF, XLV, XLI, XLB, XLK, XLU,
SPY, MDY, VTI.
Figure 33.
Sudoku solution.
PREMIUM DATA SERVICES
I
f you are serious about getting the most from MetaStock, you will
need top quality data. Having bad data is worse than no data at all. I
use Premium Data, available from Norgate Investor Services.
They provide premium quality end-of-day data suitable for MetaStock,
covering stock markets (ASX, SGX, Amex, NYSE, NASDAQ, OTC),
futures markets (80 contracts) and Forex (78 currency pairs). The data
is fully adjusted for all corporate actions such as consolidations, splits,
mergers, renames, code changes, and allows sophisticated groupings
such as industry, index participation and dividend-paying securities. A
free trial is available.
Are you getting
the most from
MetaStock?
If you currently use another provider, let Norgate Investor Services
know and they'll give you a special offer. They really are worth your
consideration. www.premiumdata.net
Disclaimer: There are significant risks associated with securities trading. Nothing in this newsletter should be considered investment
advice, trading advice or recommendations as to investment management. I am not an investment advisor, and the information
provided in this newsletter is for educational purposes only. Each subscriber uses the information published in MetaStock Tips &
Tools at their own discretion and bears all risk associated with the application of that information to their trading or investment
decisions. Nothing in this newsletter implies that any formula, method or strategy is in fact correct, or reliable in all circumstances.
September 2012
Page 22
{Multi-Frame D C Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 7/9/12}
{Proprietary code removed from sample newsletter}
Figure 34.
The Multi-Frame D Compression template.
September 2012
Page 23
{Multi-Frame D CE Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 7/9/12}
{Proprietary code removed from sample newsletter}
Figure 35.
The Multi-Frame D Compression/Expansion template.
September 2012
Page 24
{Multi-Frame D+C Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 17/8/12}
{Proprietary code removed from sample newsletter}
Figure 36.
The Multi-Frame D+ Compression template.
September 2012
Page 25
{Multi-Frame D+CE Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 17/8/12}
{Proprietary code removed from sample newsletter}
Figure 37.
The Multi-Frame D+ Compression/Expansion template.
September 2012
Page 26
{Multi-Frame ID C Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 17/8/12}
{Proprietary code removed from sample newsletter}
Figure 38.
The Multi-Frame ID Compression template.
September 2012
Page 27
{Multi-Frame ID CE Template}
{Requires Forum & MSTT DLLs}
{Roy Larsen, 2012, 17/8/12}
{Proprietary code removed from sample newsletter}
Figure 39.
The Multi-Frame ID Compression/Expansion template.
September 2012
Page 28
{Trade Equity GV LE}
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
{Inputs}
A:=Input("Trade Equity GV LE, Opt 0-27, SE=100+",0,127,100);
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,1);
J:=Input("Exit Cost",0,999,1);
D:=Input("Entry/Exit Delays 00-55",0,55,11);
K:=1000; F:=1;{Equity/Factor}
{Signals}
I:=Fml("PS MOO");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=0;
{Code}
I:=ExtFml("GV.SetVar","Cf",F);I:=ExtFml("GV.SetVar","Le",A);
Xd:=LastValue(Int(Frac(D/9.9)*10));
D:=LastValue(Int(D/10));Ns:=(B=5)*Ns;
F:=ValueWhen(1+D,1,If(F=0,-1,If(Abs(F)>1,Abs(F),-F)));
M:=If(Ns>0,Min(H,Max(L,Ns)),If(B=1,O,If(B=3,H,If(B=4,L,C))));
N:=N*(Alert(N=0,2)+(Cum(N>-1)=1));
X:=X*(Z<5)*(Alert(X=0,2)+(Cum(N>-1)=1));
N:=ValueWhen(1+D,1,N);N:=If(B<5,N,Ns>0);
N:=If((F<=1)*(F>0)*(F*K<M),(K=0)*N,N);
Xs:=(Xs>0)*Min(H,Max(L,Xs));
Y:=If(Xs>0,Xs,If(Z=1,O,If(Z=3,H,If(Z=4,L,C))));
X:=ValueWhen(1+Xd,1,X);X:=X+Xs>0;
Y:=If((Z<5)*(X=0),C{Y},Y);Y:=If((Xs>0)*N*X,Xs,Y);
Figure 40.
I:=Cum(Abs(F)+N+X>-2)=1;N:=(I>-1)*N;
Version 8.5 of the
Y:=If((N+X=0)*Alert(N*X,2),ValueWhen(2,1,Y),Y);
Trade Equity GV LE indicator. R:=BarsSince(I+N)<(BarsSince(I+X)+(Cum(N)=1 AND Cum(I+X)=1));
R:=If((N+X>1)*(Alert(R,2)+((D+Xd<1)
*(B<>2)*(Z>1)*(Max(B,Z)>4 OR B<>Z))),1,R);
U:=R*Alert(R=0,2)+I;M:=If(I*(N=0),C,M);
Rx:=Alert(R,2);Q:=Rx*(LastValue(Cum(1))=Cum(1));
Z:={Q+}(R=0)*Rx;D:=A<99;A:=ValueWhen(1,U,If(M,M,1));
F:=ValueWhen(1,U,If(F<0,K*Abs(F),
If(F<=1,Int((F*K-G)/A)*A+G,F*A+G)))*(K>0);
B:=Rx*(1+BarsSince(U));
I:=(F-G)*Y/A-F;U:=(F-G)*(A-Y)/A-G;
N:=(Z+Q>0)*If(D,If(K,I-J*Z,Y-A),If(K,U-J*Z,A-Y));
Xs:=Rx*If(D,If(K,I-Z*J,Y-A),If(K,U-Z*J,A-Y));
X:=Cum((Z+Q>0)*(N>0)*(B-1));Xd:=Cum((Z+Q>0)*(N<=0)*(B-1));
M:=Cum(N)+K+R*(Q=0)*If(D,If(K,I,Y-A),If(K,U,A-Y));
I:=ExtFml("GV.SetVar","Mx",Rx*If(D,If(K,(F-G)*
((H/A)-1)-G-J*Z,H-A),If(K,(F-G)*((A-L)/A)-G-J*Z,A-L)));
I:=ExtFml("GV.SetVar","Mn",RX*If(D,If(K,(F-G)*
((L/A)-1)-G-J*Z,L-A),If(K,(F-G)*((A-H)/A)-G-J*Z,A-H)));
I:=ExtFml("GV.SetVar","A",A);I:=ExtFml("GV.SetVar","Cn",G);
I:=ExtFml("GV.SetVar","Cp",K);I:=ExtFml("GV.SetVar","Cx",J);
I:=ExtFml("GV.SetVar","Eq",M);I:=ExtFml("GV.SetVar","F",F);
I:=ExtFml("GV.SetVar","N",N);I:=ExtFml("GV.SetVar","Tr",R);
I:=ExtFml("GV.SetVar","X",X);I:=ExtFml("GV.SetVar","Xd",Xd);
I:=ExtFml("GV.SetVar","Xs",Xs);I:=ExtFml("GV.SetVar","Y",Y);
{Fml("Trade Equity GV LE Display");}M;
September 2012
Page 29
{Trade Equity GV LE Display}
{Roy Larsen, 2004-2013, 10/1/13}
{use with Trade Equity GV LE, v8.5}
Z:=ExtFml("GV.GetVar","Le");
D:=DayOfMonth();A:=LastValue(D);
M:=Month();B:=LastValue(M);Y:=Year();
G:=M*31+D-(M>B OR (M=B AND D>A))*372;
G:=G<ValueWhen(2,1,G);Z:=If(Z>99,Z-100,Z);
K:=ExtFml("GV.GetVar","Cp");M:=LastValue(K);
N:=ExtFml("GV.GetVar","N");M:=ExtFml("GV.GetVar","Eq");
R:=ExtFml("GV.GetVar","Tr");Nd:=ExtFml("GV.GetVar","Xs");
F:=ExtFml("GV.GetVar","F");I:=Cum(IsDefined(R))=1;
Q:=R*(Cum(1)=LastValue(Cum(1)));
F:=ExtFml("Forum.Sum",F,1); F:=If(F=0,1,F);
Ns:=HighestSince(1,I,ExtFml("GV.GetVar","Mx"));
Nd:=LowestSince(1,I,ExtFml("GV.GetVar","Mn"));
A:=HighestSince(1,I+R*Alert(R=0,2)*(Z<19),M)=M;
B:=ValueWhen(1,I+A,Max(M,ValueWhen(1,I+(R=0),M)));
D:=LowestSince(1,I+A,M);Rd:=HighestSince(1,I,B-D);
Rp:=100*HighestSince(1,I,(B-D)/(B+(B=0)));
I:=Alert(Cum(IsDefined(Ref(I,2)))=1,3);
Y:=If(Z>24,G,Y<>ValueWhen(2,1,Y)) OR Cum(I)=0 OR Cum(I)=2;
Y:=TroughBars(1,Y,1)=0 OR Alert(Cum(I)=1,3) OR Cum(1)=LastValue(Cum(1));
Y:=ExtFml("Forum.Sum",Y,1);
A:=ValueWhen(1,Y,M); B:=ValueWhen(2,Y,M);
G:=PREC(100*(A-B)*(B<>0)/(Abs(B)+(B=0)),2);
U:=(M-ValueWhen(1,I+(M=Highest(M)),M))/(K+(K=0));
U:=U+(U=0)*0.0000001;
D:=If(Z=0,M,
If(Z=1,M-K, If(Z=2,100*(M-K)/F,
If(Z=3,N+M-K-Cum(N),
If(Z=4,100*(N+M-K-Cum(N))/F,
If(Z=5,N, If(Z=6,100*N/F,
If(Z=7,Cum((N>0)*N), If(Z=8,Cum((N<0)*N),
If(Z=9,Cum(N>0), Cum((R=0)*Alert(R,2)+Q>0 AND N<=0)))))))))));
D:=If(Z<11,D,
If(Z=11,R,
If(Z=12,R*Alert(R=0,2)-(R=0)*Alert(R,2),
If(Z=13,BarsSince(I+(R=0)),
If(Z=14,Cum(R),
If(Z=15,Ns, If(Z=16,Nd,
If(Z=17,-Rd, If(Z=18,-Rp,
If(Z=19,-Rd, -Rp))))))))));
D:=If(Z<21,D,
If(Z=21,M-ValueWhen(1,I OR M=Highest(M),M),
If(Z=22,100*U,
If(Z=23,(A-B)*(B<>0), If(Z=24,G,
If(Z=25,(A-B)*(B<>0), If(Z=26,G,F)))))));
I:=Cum(IsDefined(D));
D:=ExtFml("Forum.SUM",D,1); If(Z=10 AND I=0,0,
If(I=0,LastValue(ValueWhen(1,I=1,D)),D));
Figure 41.
Version 8.5 of the Trade Equity GV LE Display indicator
September 2012
Page 30
{Trade Equity GV LE Display H}
{Roy Larsen, 2004-2013, 10/1/13}
{use with Trade Equity GV LE, v8.5}
J:=Fml("Trade Equity GV LE");
Z:=Input("Trade Equity GV LE Display H, Option?",0,27,0);
J:=Input("Output, 1=One Plot, 2=Two Plots (histogram)",1,2,1);
D:=DayOfMonth();A:=LastValue(D);
M:=Month();B:=LastValue(M);Y:=Year();
G:=M*31+D-(M>B OR (M=B AND D>A))*372;
G:=G<ValueWhen(2,1,G);
K:=ExtFml("GV.GetVar","Cp");M:=LastValue(K);
N:=ExtFml("GV.GetVar","N");M:=ExtFml("GV.GetVar","Eq");
R:=ExtFml("GV.GetVar","Tr");Nd:=ExtFml("GV.GetVar","Xs");
F:=ExtFml("GV.GetVar","F");I:=Cum(IsDefined(R))=1;
Q:=R*(Cum(1)=LastValue(Cum(1)));
F:=ExtFml("Forum.Sum",F,1); F:=If(F=0,1,F);
Ns:=HighestSince(1,I,ExtFml("GV.GetVar","Mx"));
Nd:=LowestSince(1,I,ExtFml("GV.GetVar","Mn"));
A:=HighestSince(1,I+R*Alert(R=0,2)*(Z<19),M)=M;
B:=ValueWhen(1,I+A,Max(M,ValueWhen(1,I+(R=0),M)));
D:=LowestSince(1,I+A,M);Rd:=HighestSince(1,I,B-D);
Rp:=100*HighestSince(1,I,(B-D)/(B+(B=0)));
I:=Alert(Cum(IsDefined(Ref(I,2)))=1,3);
Y:=If(Z>24,G,Y<>ValueWhen(2,1,Y)) OR Cum(I)=0 OR Cum(I)=2;
Y:=TroughBars(1,Y,1)=0 OR Alert(Cum(I)=1,3) OR Cum(1)=LastValue(Cum(1));
Y:=ExtFml("Forum.Sum",Y,1);
A:=ValueWhen(1,Y,M); B:=ValueWhen(2,Y,M);
G:=PREC(100*(A-B)*(B<>0)/(Abs(B)+(B=0)),2);
U:=(M-ValueWhen(1,I+(M=Highest(M)),M))/(K+(K=0));
D:=If(Z=0,M,
If(Z=1,M-K, If(Z=2,100*(M-K)/F,
If(Z=3,N+M-K-Cum(N),
If(Z=4,100*(N+M-K-Cum(N))/F,
If(Z=5,N, If(Z=6,100*N/F,
If(Z=7,Cum((N>0)*N), If(Z=8,Cum((N<0)*N),
If(Z=9,Cum(N>0), Cum((R=0)*Alert(R,2)+Q>0 AND N<=0)))))))))));
D:=If(Z<11,D,
If(Z=11,R,
If(Z=12,R*Alert(R=0,2)-(R=0)*Alert(R,2),
If(Z=13,BarsSince(I+(R=0)),
If(Z=14,Cum(R),
If(Z=15,Ns, If(Z=16,Nd,
If(Z=17,-Rd, If(Z=18,-Rp,
If(Z=19,-Rd, -Rp))))))))));
D:=If(Z<21,D,
If(Z=21,M-ValueWhen(1,I OR M=Highest(M),M),
If(Z=22,100*U,
If(Z=23,(A-B)*(B<>0), If(Z=24,G,
If(Z=25,(A-B)*(B<>0), If(Z=26,G,F)))))));
I:=Cum(IsDefined(D));D:=ExtFml("Forum.SUM",D,1);
D:=If(Z=12 AND I=0,0,
If(I=0,LastValue(ValueWhen(1,I=1,D)),D));
ValueWhen(1,J=2,If(D>=0,D,0));
If(J=2,If(D<0,D,0),D);
Figure 42.
Version 8.5 of the Trade Equity GV LE Display H indicator
September 2012
Page 31
{Trade Equity GV SE}
{Roy Larsen, 2003-2012, 11/8/12, v8.5}
{Inputs}
A:=Input("Trade Equity GV SE, Opt 0-27, LE=100+",0,127,0);
B:=Input("Entry, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
Z:=Input("Exit, 1=O 2=C 3=H 4=L 5=Stop",1,5,1);
G:=Input("Entry Cost",0,999,1);
J:=Input("Exit Cost",0,999,1);
D:=Input("Entry/Exit Delays 00-55",0,55,11);
K:=1000; F:=1;{Equity/Factor}
{Signals}
I:=FmlVar("PS MOO","Long");
N:=I>0;
Ns:=0;
X:=I<0;
Xs:=0;
{Code}
I:=ExtFml("GS.SetVar","Cf",F);I:=ExtFml("GS.SetVar","Se",A);
Xd:=LastValue(Int(Frac(D/9.9)*10));
D:=LastValue(Int(D/10));Ns:=(B=5)*Ns;
F:=ValueWhen(1+D,1,If(F=0,-1,If(Abs(F)>1,Abs(F),-F)));
M:=If(Ns>0,Min(H,Max(L,Ns)),If(B=1,O,If(B=3,H,If(B=4,L,C))));
N:=N*(Alert(N=0,2)+(Cum(N>-1)=1));
X:=X*(Z<5)*(Alert(X=0,2)+(Cum(N>-1)=1));
N:=ValueWhen(1+D,1,N);N:=If(B<5,N,Ns>0);
N:=If((F<=1)*(F>0)*(F*K<M),(K=0)*N,N);
Xs:=(Xs>0)*Min(H,Max(L,Xs));
Y:=If(Xs>0,Xs,If(Z=1,O,If(Z=3,H,If(Z=4,L,C))));
X:=ValueWhen(1+Xd,1,X);X:=X+Xs>0;
Y:=If((Z<5)*(X=0),C{Y},Y);Y:=If((Xs>0)*N*X,Xs,Y);
I:=Cum(Abs(F)+N+X>-2)=1;N:=(I>-1)*N;
Y:=If((N+X=0)*Alert(N*X,2),ValueWhen(2,1,Y),Y);
R:=BarsSince(I+N)<(BarsSince(I+X)+(Cum(N)=1 AND Cum(I+X)=1));
R:=If((N+X>1)*(Alert(R,2)+((D+Xd<1)
*(B<>2)*(Z>1)*(Max(B,Z)>4 OR B<>Z))),1,R);
U:=(R+Alert(R=0,2)=2)+I;M:=If(I*(N=0),C,M);
Rx:=Alert(R,2);Q:=Rx*(LastValue(Cum(1))=Cum(1));
Z:={Q+}(R=0)*Rx;D:=A>99;A:=ValueWhen(1,U,If(M,M,1));
F:=ValueWhen(1,U,If(F<0,K*Abs(F),
If(F<=1,Int((F*K-G)/A)*A+G,F*A+G)))*(K>0);
B:=Rx*(1+BarsSince(U));
I:=(F-G)*Y/A-F;U:=(F-G)*(A-Y)/A-G;
N:=(Z+Q>0)*If(D,If(K,I-Z*J,Y-A),If(K,U-Z*J,A-Y));
Xs:=Rx*If(D,If(K,I-Z*J,Y-A),If(K,U-Z*J,A-Y));
X:=Cum((Z+Q>0)*(N>0)*(B-1));Xd:=Cum((Z+Q>0)*(N<=0)*(B-1));
M:=Cum(N)+K+R*(Q=0)*If(D,If(K,I,Y-A),If(K,U,A-Y));
I:=ExtFml("GS.SetVar","Mx",Rx*If(D,If(K,(F-G)*
((H/A)-1)-G-J*Z,H-A),If(K,(F-G)*((A-L)/A)-G-J*Z,A-L)));
I:=ExtFml("GS.SetVar","Mn",Rx*If(D,If(K,(F-G)*
((L/A)-1)-G-J*Z,L-A),If(K,(F-G)*((A-H)/A)-G-J*Z,A-H)));
I:=ExtFml("GS.SetVar","A",A);I:=ExtFml("GS.SetVar","Cn",G);
I:=ExtFml("GS.SetVar","Cp",K);I:=ExtFml("GS.SetVar","Cx",J);
I:=ExtFml("GS.SetVar","Eq",M);I:=ExtFml("GS.SetVar","F",F);
I:=ExtFml("GS.SetVar","N",N);I:=ExtFml("GS.SetVar","Tr",R);
I:=ExtFml("GS.SetVar","X",X);I:=ExtFml("GS.SetVar","Xd",Xd);
I:=ExtFml("GS.SetVar","Xs",Xs);I:=ExtFml("GS.SetVar","Y",Y);
{Fml("Trade Equity GV SE Display");}M;
September 2012
Figure 43.
Version 8.5 of the
Trade Equity GV SE indicator
Page 32
{Trade Equity GV SE Display}
{Roy Larsen, 2004-2013, 10/1/13}
{use with Trade Equity GV SE, v8.5}
Z:=ExtFml("GS.GetVar","Se");
D:=DayOfMonth();A:=LastValue(D);
M:=Month();B:=LastValue(M);Y:=Year();
G:=M*31+D-(M>B OR (M=B AND D>A))*372;
G:=G<ValueWhen(2,1,G);Z:=If(Z>99,Z-100,Z);
K:=ExtFml("GS.GetVar","Cp");M:=LastValue(K);
N:=ExtFml("GS.GetVar","N");M:=ExtFml("GS.GetVar","Eq");
R:=ExtFml("GS.GetVar","Tr");Nd:=ExtFml("GS.GetVar","Xs");
F:=ExtFml("GS.GetVar","F");I:=Cum(IsDefined(R))=1;
Q:=R*(Cum(1)=LastValue(Cum(1)));
F:=ExtFml("Forum.Sum",F,1); F:=If(F=0,1,F);
Ns:=HighestSince(1,I,ExtFml("GS.GetVar","Mx"));
Nd:=LowestSince(1,I,ExtFml("GS.GetVar","Mn"));
A:=HighestSince(1,I+R*Alert(R=0,2)*(Z<19),M)=M;
B:=ValueWhen(1,I+A,Max(M,ValueWhen(1,I+(R=0),M)));
D:=LowestSince(1,I+A,M);Rd:=HighestSince(1,I,B-D);
Rp:=100*HighestSince(1,I,(B-D)/(B+(B=0)));
I:=Alert(Cum(IsDefined(Ref(I,2)))=1,3);
Y:=If(Z>24,G,Y<>ValueWhen(2,1,Y)) OR Cum(I)=0 OR Cum(I)=2;
Y:=TroughBars(1,Y,1)=0 OR Alert(Cum(I)=1,3) OR Cum(1)=LastValue(Cum(1));
Y:=ExtFml("Forum.Sum",Y,1);
A:=ValueWhen(1,Y,M); B:=ValueWhen(2,Y,M);
G:=PREC(100*(A-B)*(B<>0)/(Abs(B)+(B=0)),2);
D:=If(Z=0,M,
If(Z=1,M-K, If(Z=2,100*(M-K)/F,
If(Z=3,N+M-K-Cum(N),
If(Z=4,100*(N+M-K-Cum(N))/F,
If(Z=5,N, If(Z=6,100*N/F,
If(Z=7,Cum((N>0)*N), If(Z=8,Cum((N<0)*N),
If(Z=9,Cum(N>0), Cum((R=0)*Alert(R,2)+Q>0 AND N<=0)))))))))));
D:=If(Z<11,D,
If(Z=11,R,
If(Z=12,R*Alert(R=0,2)-(R=0)*Alert(R,2),
If(Z=13,BarsSince(I+(R=0)),
If(Z=14,Cum(R),
If(Z=15,Ns, If(Z=16,Nd,
If(Z=17,-Rd, If(Z=18,-Rp,
If(Z=19,-Rd, -Rp))))))))));
D:=If(Z<21,D,
If(Z=21,M-ValueWhen(1,I OR M=Highest(M),M),
If(Z=22,100*(M-ValueWhen(1,I OR M=Highest(M),M))/(K+(K=0)),
If(Z=23,(A-B)*(B<>0), If(Z=24,G,
If(Z=25,(A-B)*(B<>0), If(Z=26,G,F)))))));
I:=Cum(IsDefined(D));D:=ExtFml("Forum.SUM",D,1);
If(Z=10 AND I=0,0,
If(I=0,LastValue(ValueWhen(1,I=1,D)),D));
Figure 44.
Version 8.5 of the Trade Equity GV SE Display indicator
September 2012
Page 33
{Trade Equity GV SE Display H}
{Roy Larsen, 2004-2013, 10/1/13}
{use with Trade Equity GV SE, v8.5}
J:=Fml("Trade Equity GV SE");
Z:=Input("Trade Equity GV SE Display H, Option?",0,27,0);
J:=Input("Output, 1=One Line, 2=Two Lines (histogram)",1,2,1);
D:=DayOfMonth();A:=LastValue(D);
M:=Month();B:=LastValue(M);Y:=Year();
G:=M*31+D-(M>B OR (M=B AND D>A))*372;
G:=G<ValueWhen(2,1,G);
K:=ExtFml("GS.GetVar","Cp");M:=LastValue(K);
N:=ExtFml("GS.GetVar","N");M:=ExtFml("GS.GetVar","Eq");
R:=ExtFml("GS.GetVar","Tr");Nd:=ExtFml("GS.GetVar","Xs");
F:=ExtFml("GS.GetVar","F");I:=Cum(IsDefined(R))=1;
Q:=R*(Cum(1)=LastValue(Cum(1)));
F:=ExtFml("Forum.Sum",F,1); F:=If(F=0,1,F);
Ns:=HighestSince(1,I,ExtFml("GS.GetVar","Mx"));
Nd:=LowestSince(1,I,ExtFml("GS.GetVar","Mn"));
A:=HighestSince(1,I+R*Alert(R=0,2)*(Z<19),M)=M;
B:=ValueWhen(1,I+A,Max(M,ValueWhen(1,I+(R=0),M)));
D:=LowestSince(1,I+A,M);Rd:=HighestSince(1,I,B-D);
Rp:=100*HighestSince(1,I,(B-D)/(B+(B=0)));
I:=Alert(Cum(IsDefined(Ref(I,2)))=1,3);
Y:=If(Z>24,G,Y<>ValueWhen(2,1,Y)) OR Cum(I)=0 OR Cum(I)=2;
Y:=TroughBars(1,Y,1)=0 OR Alert(Cum(I)=1,3) OR Cum(1)=LastValue(Cum(1));
Y:=ExtFml("Forum.Sum",Y,1);
A:=ValueWhen(1,Y,M); B:=ValueWhen(2,Y,M);
G:=PREC(100*(A-B)*(B<>0)/(Abs(B)+(B=0)),2);
D:=If(Z=0,M,
If(Z=1,M-K, If(Z=2,100*(M-K)/F,
If(Z=3,N+M-K-Cum(N),
If(Z=4,100*(N+M-K-Cum(N))/F,
If(Z=5,N, If(Z=6,100*N/F,
If(Z=7,Cum((N>0)*N), If(Z=8,Cum((N<0)*N),
If(Z=9,Cum(N>0), Cum((R=0)*Alert(R,2)+Q>0 AND N<=0)))))))))));
D:=If(Z<11,D,
If(Z=11,R,
If(Z=12,R*Alert(R=0,2)-(R=0)*Alert(R,2),
If(Z=13,BarsSince(I+(R=0)),
If(Z=14,Cum(R),
If(Z=15,Ns, If(Z=16,Nd,
If(Z=17,-Rd, If(Z=18,-Rp,
If(Z=19,-Rd, -Rp))))))))));
D:=If(Z<21,D,
If(Z=21,M-ValueWhen(1,I OR M=Highest(M),M),
If(Z=22,100*(M-ValueWhen(1,I OR M=Highest(M),M))/(K+(K=0)),
If(Z=23,(A-B)*(B<>0), If(Z=24,G,
If(Z=25,(A-B)*(B<>0), If(Z=26,G,F)))))));
I:=Cum(IsDefined(D));D:=ExtFml("Forum.SUM",D,1);
D:=If(Z=12 AND I=0,0,
If(I=0,LastValue(ValueWhen(1,I=1,D)),D));
ValueWhen(1,J=2,If(D>=0,D,0));
If(J=2,If(D<0,D,0),D);
Figure 45.
Version 8.5 of the Trade Equity GV SE Display H indicator
September 2012
Page 34
SELF-INSTALLING FORMULA CONTENTS
Self-installing EXE file
MS 8+ Sep 2012 Trade Equity Formulas.exe
Explorations
Trade Equity Data Validity
Trade Equity Portfolio Reset
Trade Equity Portfolio Scan DE1
Trade Equity Portfolio Scan DE2
Trade Equity Portfolio Scan LE
Trade Equity Portfolio Scan SE
Trade Equity Super Scan DE1
Trade Equity Super Scan DE2
Trade Equity Super Scan LE
Trade Equity Super Scan SE
Experts
Trade Equity Chart Report DE
Trade Equity Chart Report LE
Trade Equity Chart Report LSE
Trade Equity Chart Report SE
Trade Equity Portfolio Report DE
Trade Equity Portfolio Report LE
Trade Equity Portfolio Report LSE
Trade Equity Portfolio Report SE
Trade Equity Super Scan Report DE
Trade Equity Super Scan Report LE
Trade Equity Super Scan Report LSE
Trade Equity Super Scan Report SE
Indicators
Bar Count
Date Filter
PS MOO (Meisels Overbought/Oversold}
Trade Equity GV DE
Trade Equity GV DE Long
Trade Equity GV DE Short
Trade Equity GV Display Options
Trade Equity GV LE
Trade Equity GV LE Display
Trade Equity GV LE Display H
Trade Equity GV LE Portfolio Display
Trade Equity GV SE
Trade Equity GV SE Display
Trade Equity GV SE Display H
Trade Equity GV SE Portfolio Display
Trade Equity Pairs GV LE
Trade Equity Pairs GV SE
DLLs
Forum, MSTT, GD, GP, GS, GV
Templates
Trade Equity LE
Trade Equity LSE
Trade Equity SE
Default Display settings
2/2 22/1
11/1
2/2 22/1 - 2/2
22/1
2/2 22/1
11/1
Figure 46.
Contents of the MS 8+ Sep 2012 Trade Equity Formulas.exe file.
Self-installing EXE file
MS 8+ Sep 2012 System Formulas.exe
Explorations
Trade Equity Portfolio Scan Breadth D
Trade Equity Portfolio Scan Breadth P
Indicators
AT Breadth
AT Market Breadth AT
AT Market Breadth EFT
PS AMA (Adaptive Moving Average)
PS BP1 (Bull Power Bear Power 1)
PS BP2 (Bull Power Bear Power 2)
PS BP3 (Bull Power Bear Power 3)
PS CBO (Consolidation Breakout)
PS CCI (Commodity Channel Index)
PS CFO (Chande Forecast Oscillator)
PS CMO (CMO Reversal)
PS CPP (Cooper 1234 Pattern)
PS CPR (Cycle Progression)
PS DM1 (Dynamic Momentum Index 1)
PS EMA (Exponential Moving Average)
PS FT1 (Fractal Trading System 1)
PS FT2 (Fractal Trading System 2)
PS LSS (Long Sell Short Sale-5 Day)
PS MH1 (MACD Histogram 1)
PS MH2 (MACD Histogram 2)
PS MOO (Meisels Overbought/Oversold)
PS MSW (MESA Sine Wave)
PS PC3 (Percentage Crossover 3%)
PS PO1 (Projection Oscillator 1)
PS PT1 (Pattern Trading System 1)
PS SRS (StochRSI)
PS SWI (Swing Index)
PS VBC (Volatility Breakout (Chaikin))
PS VHF (Vertical Horizontal Filter)
Figure 47.
Contents of the MS 8+ Sep 2012 System Formulas.exe file.
September 2012
Page 35