Metastock
Formulas
- G
Click
here to go back to Metastock Formula
Index
IMPORTANT:
These formulas aren't my complete collection. For my complete
collection of instantly usable, profitable
and powerful MetaStock formulas Click
Here
|
Would
You Like To Use MetaStock To Its Full Potential? Discover the Amazingly
Simple Secret to Master Metastock Step-By-Step
- click
here
A | A 1 | B | B 1 | C | C 1 | D | D 1 | E | F | G | H | I | J | K | L | M | M 1 | N | O | P | R | S | S 1 | T | U | V | W | Z |
Col
A: CLOSE
Col B: ROC(C,5,%)
Filter: (ROC(C,5,%)>10 OR ROC(C,5,%)<-10) AND C>5
Filter enabled: Yes
(Go
Top) |
{name:
GANN-HiLo}
HLd:=If(CLOSE>Ref(Mov(H,3,S),-1),
{then}1,
{else}If(CLOSE<Ref(Mov(L,3,S),-1),
{then}-1,
{else}0));
HLv:=ValueWhen(1,HLd<>0,HLd);
HiLo:=If(HLv=-1,
{then}Mov(H,3,S),
{else}Mov(L,3,S));
HiLo;
(Go
Top) |
colA
BUY
BarsSince(C< Fml("GANN-HiLo"))
colB
SELL
BarsSince(C> Fml("GANN-HiLo"))
filter
colA=1 OR colB=1
(Go
Top) |
{Market
swing is defined as:
Up = 2 higher highs,
Down = 2 lower highs.}
Us:=BarsSince((H > Ref(H,-1)) AND (Ref(H,-1) >
Ref(H,-2)));
Ds:=BarsSince((L < Ref(L,-1)) AND (Ref(L,-1) <
Ref(L,-2)));
Sd1:=If(Us=0,
{then}If(Ref(L,-1)<>LowestSince(1,Ds=0,L),
{then}1,
{else}0),
{else}If(Ds=0,
{then}If(Ref(H,-1)<>
HighestSince(1,Us=0,H),
{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;
(Go
Top) |
This
is an update to Gann-Swing indicators I had posted several
months
back. Most of the code has been improved and I have modified
the swing
definition slightly.
Gann Weekly Expert Instructions
1. First create a new expert and name it whatever you want.
2a. under "trends" tab put this code for bullish:
ut:=FmlVar("GANN-Trend","TDV");
uplot:=If(BarsSince(Ut=1)<
BarsSince(Ut=-1),1,0);
uplot=1;
2b. and this for bearish:
dt:=FmlVar("GANN-Trend","TDV");
dplot:=If(BarsSince(dt=1)>
BarsSince(dt=-1),1,0);
dplot=1;
Then click on the "ribbon" option and turn off "Display
Vertical Lines", I
also turn off
the corner option.
3a. Under highlights tab create a new and call it "HiLo
Change", choose
color, and enter this code:
HLd:=If(CLOSE>Ref(Mov(H,3,S),-1),
{then}1,
{else}If(CLOSE<Ref(Mov(L,3,S),-1),
{then}-1,
{else}0));
HLv:=ValueWhen(1,HLd<>0,HLd);
HLv<>Ref(HLv,-1);
3b. Create new and call it "Up-Trend", choose color, and
enter this code:
ut:=FmlVar("GANN-Trend","TD");
uplot:=If(BarsSince(Ut=1)<
BarsSince(Ut=-1),1,0);
uplot=1;
3c. Create new and call it "Down-Trend", choose color, and
enter this code:
dt:=FmlVar("GANN-Trend","TD");
dplot:=If(BarsSince(dt=1)>
BarsSince(dt=-1),1,0);
dplot=1;
4a. Under "Symbols" tab create new and call it " UpSwing",
enter this code:
FmlVar("GANN-Swing","SD2")=1;
then under graphic choose "Buy Arrow", choose color (Dark
Green), and small
size, then pick "Above Price Plot".
4b. Create new and call it "DownSwing", enter this code:
FmlVar("GANN-Swing","SD2")=-1;
then under graphic choose "sell arrow", choose color (Dark
Red), and small
size, then pick "Below Price Plot".
As for the HiLo ....just plot it as a regular indicator
and choose the last
"style" option under "color/style" tab.
Note: For daily bar charts ribbon use these formulas:
2a. ut:= FmlVar("GaW-Trend","TDV") ;
uplot:=If(BarsSince(Ut=1)<
BarsSince(Ut=-1),1,0);
uplot=1;
2b. dt:= FmlVar("GaW-Trend","TDV") ;
dplot:=If(BarsSince(dt=1)>
BarsSince(dt=-1),1,0);
dplot=1;
(Go
Top) |
{Swing
Direction}
Sd:= FmlVar("GANN-Swing","TD1") ;
{Swing Change High}
Sch:=If(Sd=1 AND Ref(sd,-1)=-1,
{then}1,
{else}0);
{Swing Change Low}
Scl:=If(Sd=-1 AND Ref(Sd,-1)=1,
{then}1,
{else}0);
{Peak Value}
Pv:=If(Scl=1,
{then}HighestSince(1,Sch=1,H),
{else}0);
{Trough Value}
Tv:=If(Sch=1,
{then}LowestSince(1,Scl=1,L),
{else}0);
{Trend Direction}
Td:=If(H>ValueWhen(1,Pv>0,Pv),
{then}1,
{else}If(L<ValueWhen(1,Tv>0,Tv),
{then}-1,
{else}0));
{UpTrend=1 DownTrend =-1}
Tdv:=ValueWhen(1,Td<>0,Td);
Tdv;
(Go
Top) |
{BUY}
L>Ref(H,-1) OR
Cum(1)=LastValue(Cum(1))
{SELL}
H<Ref(L,-1) OR
Cum(1)=LastValue(Cum(1))
(Go
Top) |
{BUY}
N1:=5;
L>Ref(HHV(H,N1),-1) OR
Cum(1)=LastValue(Cum(1))
{SELL}
N1:=5;
H<Ref(LLV(L,N1),-1) OR
Cum(1)=LastValue(Cum(1))
(Go
Top) |
{Enter
Long}
N1:=5;
L>Ref(HHV(H,N1),-1) OR
Cum(1)=LastValue(Cum(1))
{Exit Long}
N2:=3;
C<Ref(LLV(L,N2),-1) OR
Cum(1)=LastValue(Cum(1))
{Enter Short}
N1:=5;
H<Ref(LLV(L,N1),-1) OR
Cum(1)=LastValue(Cum(1))
{Exit Short}
N2:=3;
C>Ref(HHV(H,N2),-1) OR
Cum(1)=LastValue(Cum(1))
(Go
Top) |
Shows
stocks which have gapped up or down on the open compared
to yesterdays price. The search returns 1 for Ok and 0 for
not ok.
(Go
Top) |
Here
is the gap-trading system code for use in Equis International's
MetaStock software. For practical reasons, the system has
been defined as an indicator rather than a system, showing
the cumulated profit.
dn:= 1.0;
up:= 1.0;
gap:= 100*(OPEN - Ref(CLOSE, -1))/Ref(CLOSE, -1);
prf:= If(gap>=up, OPEN-CLOSE, If(gap<=-dn, CLOSE-OPEN,0));
Cum(prf);
(Go
Top) |
The
MetaStock formulas to calculate these percentages are shown
below. The
first input is the minimum gap (e.g., 1%), and the second
input is the gap
increment (e.g., 1%, which would give you a range of 1-2%).
To calculate
gaps down, change the percentage to a negative.
Formula to determine whether the closing price is equal
to or exceeds the
opening price on a gap day:
MinGap := Input("Minimum gap to consider (%)",-10000,10000,1);
GapIncrement := Input("Gap Increment (%)",0,100,1);
LookingForGapUp := MinGap >= 0; LookingForGapDown :=
MinGap < 0;
{ Gap percentage }
Gap := (OPEN - Ref(CLOSE,-1))/Ref(CLOSE,-1)*100;
NumGaps := If(LookingForGapUp, Cum(Gap >= MinGap AND
Gap < MinGap +
GapIncrement), If(LookingForGapDown, Cum(Gap <= MinGap
AND Gap > MinGap -
GapIncrement),0));
If(LookingForGapUp, Cum(If(Gap >= MinGap AND Gap <
MinGap + GapIncrement,
If(CLOSE >= OPEN, +1,0),0)),
If(LookingForGapDown, Cum(If(Gap <= MinGap AND Gap >
MinGap - GapIncrement,
If(CLOSE <= OPEN, +1, 0),0)), 0))/NumGaps*100;
Formula to determine whether the daily range crosses the
previous day’s
close on a gap day:
MinGap := Input("Minimum gap to consider (%)",-10000,10000,1);
GapIncrement := Input("Gap Increment (%)",0,100,1);
LookingForGapUp := MinGap >= 0; LookingForGapDown :=
MinGap < 0;
{ Gap percentage }
Gap := (OPEN - Ref(CLOSE,-1))/Ref(CLOSE,-1)*100;
NumGaps := If(LookingForGapUp, Cum(Gap >= MinGap AND
Gap < MinGap +
GapIncrement), If(LookingForGapDown, Cum(Gap <= MinGap
AND Gap > MinGap -
GapIncrement),0));
If(LookingForGapUp, Cum(If(Gap >= MinGap AND Gap <
MinGap + GapIncrement,
If(LOW <= Ref(CLOSE,-1), +1,0),0)),
If(LookingForGapDown, Cum(If(Gap <= MinGap AND Gap >
MinGap - GapIncrement,
If(HIGH >= Ref(CLOSE,-1), +1, 0),0)), 0))/NumGaps*100;
Formula to determine whether the following day’s open
continues the gap
trend:
MinGap := Input("Minimum gap to consider (%)",-10000,10000,1);
GapIncrement := Input("Gap Increment (%)",0,100,1);
LookingForGapUp := MinGap >= 0; LookingForGapDown :=
MinGap < 0;
GapYesterday := (Ref(OPEN,-1) - Ref(CLOSE,-2))/Ref(CLOSE,-2)*100;
NumGapsthruYesterday := If(LookingForGapUp, Cum(GapYesterday
>= MinGap AND
GapYesterday < MinGap + GapIncrement), If(LookingForGapDown,
Cum(GapYesterday <= MinGap AND GapYesterday > MinGap
- GapIncrement),0));
If(LookingForGapUp, Cum(If(GapYesterday >= MinGap AND
GapYesterday < MinGap
+ GapIncrement, If(OPEN > Ref(CLOSE,-1), +1,0),0)),
If(LookingForGapDown, Cum(If(GapYesterday <= MinGap AND
GapYesterday >
MinGap - GapIncrement, If(OPEN < Ref(CLOSE,-1), +1, 0),0)),
0))/NumGapsthruYesterday*100;
(Go
Top) |
Enter
long
GapUp()
Close long
Ref(GapUp(),-5)
Initial equity 10000
Positions Long and short
Trade price Open
Trade delay 1
Entry commission 0%
Exit commission 0%
Interest rate 0%
Margin req. 100%
(Go
Top) |
A:Close
B:GapDown()<=Ref(LLV(L,40),-1) and C>=O and
C>=((H-L)*.50)+L
C:{entry}H+.125
D:{stop}H+.125-1
Filter: GapDown()<=Ref(LLV(L,40),-1) and C>=O and
C>=((H-L)*.50)+L
(Go
Top) |
A:Close
B:GapUp()>=Ref(HHV(H,40),-1) and C<=O and
C<=((H-L)*.50)+L
C:{entry}L-.125
D:{stop}L-.125+1
Filter: GapUp()>=Ref(HHV(H,40),-1) and C<=O and C<=((H-L)*.50)+L
(Go
Top) |
NOTE
This EXPLORATION uses the results of several INDICATOR FORMULAS.
You must create the INDICATORS first before running the
exploration. Also, depending on your system you may have
some problems importing this into early versions of Metastock
7.
Ref(C,-1)
Ref(C,-2)
Fml("mma 3/30") +Fml("mma 5/35") +Fml("mma 8/40") + Fml("mma
10/45")+Fml("mma 12/50")+Fml("mma 15/60")
Ref(Fml("mma 3/30") +Fml("mma 5/35") +Fml("mma 8/40") +
Fml("mma 10/45")+Fml("mma 12/50")+Fml("mma 15/60"),-1)
Ref(Fml("mma 3/30") +Fml("mma 5/35") +Fml("mma 8/40") +
Fml("mma 10/45")+Fml("mma 12/50")+Fml("mma 15/60"),-2)
When(colD,>,0) AND When(colE,<=,0)
(Go
Top) |
(Note
this is not the same as the formula given in Trading Tactics.
Daryl Guppy)
Try MMA (Multiple Moving Averages). The shorter ones are
closer to the
action and the longer ones tell you about the trend. I use
two indicators
like this:
Name: MMA Long Term
--------
Mov(C,40,E);
Mov(C,45,E);
Mov(C,50,E);
Mov(C,55,E);
Name: MMA Short Term
--------
Mov(C,5,E);
Mov(C,8,E);
Mov(C,11,E);
Mov(C,14,E);
In the current market I like taking short momentum trades
where the MMA
Short is bouncing up off a slowly rising MMA Long Term.
The exit at the top
of the bubble is indicated by MMA Short turning down after
a good separation
from the underlying MMA Long.
from Jeff Lederman.
{Suggestion: Create a single TEMPLATE with all the above
indicators, giving
SHORT and LONG MMAs separate colours; e.g., RED for the
SHORTs and BLUE for
the LONGs.}
(Go
Top) |
{long-term}
Mov(C,30,E);Mov(C,35,E);Mov(C,40,E);
Mov(C,45,E);Mov(C,50,E);Mov(C,60,E)
(Go
Top) |
{short-term}
Mov(C,3,E);Mov(C,5,E);Mov(C,7,E);
Mov(C,10,E);Mov(C,12,E);Mov(C,15,E);
(Go
Top) |
by
Leon Wilson
((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)))*10;
(Mov((Mov(CLOSE,3,E)+Mov(CLOSE,5,E)+
Mov(CLOSE,8,E)+Mov(CLOSE,10,E)+
Mov(CLOSE,12,E)+Mov(CLOSE,15,E))-
(Mov(CLOSE,30,E)+Mov(CLOSE,35,E)+
Mov(CLOSE,40,E)+Mov(CLOSE,45,E)+
Mov(CLOSE,50,E)+Mov(CLOSE,60,E)),13,E))*10;0;
(Go
Top) |
if(L,>,ref(H,-1),1,
if(H,<,ref(L,-1),-1,0))
(Go
Top) |
GRIIF1
Momentum Oscillator
tsf(C,9)-ref(tsf(C,9),-1)
GRIIF2 Momentum Oscillator
(ref(tsf(C,9),-1)-(ref(tsf(C,9),-2)))
GRIIF3 Momentum Oscillator
(ref(tsf(C,9),-2)-(ref(tsf(C,9),-3)))
GRII4 Momentum Oscillator
(tsf(C,9)-ref(tsf(C,9),-1))+((ref(tsf(C,9),-1)-ref(tsf(C,9),-2)))+((ref(tsf
(C,9),-2)-(ref(tsf(C,9),-3))))
(Go
Top) |
It’s
quite easy to use MetaStock for Windows to duplicate the
Genesis of a Simple Futures Trading system which is presented
in the TASC May 97 issue's interview of Jay Kaeppel. In
MetaStock for Windows, choose System Tester from the Tools
menu. Click on the New button and enter in the following
rules:
Signal
Formulas |
Enter
Long
Cross( Mov( Close,9,S), Mov( Close,50,S))
And Close > Mov( Close,80,S) |
Close
Long
Cross( Mov( Close,50,S), Mov( Close,9,S))
And Close > Mov( Close,80,S) |
Enter
Short
Cross( Mov( Close,50,S), Mov( Close,9,S))
And Close < Mov( Close,80,S) |
Close
Short
Cross( Mov( Close,9,S), Mov( Close,50,S))
And Close < Mov( Close,80,S) |
|
When
testing futures in MetaStock it’s best to use a "points
only" test. To do this, choose Options from the System
Tester dialog and then Points Only Test from the Testing
page.
To use The Explorer to screen for futures generating a recent
signal with this system, choose The Explorer from the Tools
dialog and enter in the following rules:
Column
Formulas |
Column
A: Buy Sign
Cross( Mov( Close,9,S), Mov( Close,50,S))
And Close > Mov( Close,80,S) |
Column
B: Shrt Sig
Cross( Mov( Close,50,S), Mov( Close,9,S))
And Close < Mov( Close,80,S) |
|
Filter
Source |
Filter
Enabled: Yes |
Formula:
colA = 1 OR colB = 1 |
|
Next
choose Explore and The Explorer will search for and then
display any futures, which have generated new signals.
(Go
Top) |
If
you have Metastock formulas you would like to share,
Please email to
We look forward to hearing from you!
To learn
more about how to use Metastock and its formula click
here.
copyright
2003 MetaStock Website Home
Metastock®
is a registered trademark of Equis International.
|