FRACTAL UP AND FRACTAL DOWN EXPERT

The formula for Up Fractal is:

(If( HIGH > Ref( HIGH , -1 ), 1 ,0 ) AND If( HIGH > Ref( HIGH , -2 ),1 ,0 )

AND

If( HIGH > Ref( HIGH , +1 ), 1 ,0 ) AND If(HIGH>Ref( HIGH , +2 ), 1 ,0 ))

The formula for Down Fractal is:

(If( LOW < Ref( LOW , -1 ), 1 ,0 ) AND If( LOW < Ref( LOW , -2 ), 1 ,0) AND

If( LOW < Ref( LOW , +1 ), 1 ,0 )AND If( LOW < Ref( LOW , +2 ), 1 ,0 ))

Put the formulas in a new Expert with up arrows and down arrows in graphics with appropriate colors. Hope this will be of help.

Manoj P Abraham

 

FRACTAL UP AND FRACTAL DOWN INDICATOR

Manoj Abraham  manopab@hotmail.com

That formula was for the MetaStock Expert. Create a new Expert and put the same in the symbols section and apply it. It will highlight the points where these occur. If you want to plot the same as lines, check this out. Use the Indicator Builder to create these two indicators.

Fractal Up

ValueWhen(1,(( HIGH > Ref( HIGH , -1 ) ) AND ( HIGH > Ref( HIGH , -2 ) ) AND ( HIGH > Ref( HIGH , +1 ) ) AND ( HIGH > Ref( HIGH , +2

))),C)

Fractal Down

ValueWhen(1,((( LOW < Ref( LOW , -1 )) AND ( LOW < Ref( LOW , -2 )) AND ( LOW < Ref( LOW , +1 ))AND ( LOW < Ref( LOW , +2 ) ))),C)

I use the fractals (we call them minor tops and minor bottoms) to add to my existing positions. Hope this helps

Manoj P. Abraham

 

UP AND DOWN FRACTAL FORMULA CORRECTION

The formula for Up Fractal is:

If( HIGH > Ref( HIGH, -1 ), 1 ,0 ) AND

If( HIGH > Ref( HIGH, -2 ), 1 ,0 ) AND

If( HIGH > Ref( HIGH, +1 ), 1 ,0 ) AND

If( HIGH > Ref( HIGH, +2 ), 1 ,0 )

The formula for Down Fractal is:

If( LOW < Ref( LOW , -1 ), 1 ,0 ) AND

If( LOW < Ref( LOW , -2 ), 1 ,0) AND

If( LOW < Ref( LOW , +1 ), 1 ,0 ) AND

If( LOW < Ref( LOW , +2 ), 1 ,0 )

Put the formulas in a new Expert, in the Trends section, with up arrows and down arrows in graphics with appropriate colours.

Hope this will be of help.

Manoj P Abraham

 

LINEAR REGRESSION TRADING SYSTEM

Here's a system that works. Its no Holy Grail but with a little common sense you'd be hard pressed losing money with it. Steve posted it a while back (his "lumber.gif") so I can hardly take credit for the idea, but I think the system is so profitable that I felt I really ought to champion it a bit. I would characterise it as being a fairly aggressive short term system, so it's not everyone's cup of tea.

I have added a stochastic crossover to its exit which gets it out just that little bit earlier sometimes. I find that to get the best signals there is no point in optimising over too long a time frame (yea, I know I'm going to get flamed -- heretic, unbeliever) so I pick a period back where the security doesn't change character too much and re-optimise if something dramatic happens.

Another trick is to initially optimise coarsely over a very wide range and then select intermediate results that appear to be heading for the sort of trades that you'd like to see (not always the most profitable). Often there are many profit peaks and if you initially optimise over too small a range you won't see the best version for that particular security.

I also attach the optimised formula as a MetaStock Expert to securities that I follow. The Buy signal is uncanny and the first few times you really wonder about your sanity.

{Enter Long}

Cross(opt2,ForecastOsc(O,opt1))

{Close Long}

Cross(ForecastOsc(O,opt1),opt3) OR

Cross(Mov(Stoch(opt4,3),opt5,S),Stoch(opt4,3))

Jeff Ledermann   j.ledermann@uq.net.au

 

ADX RISING EXPOLORATION

For ADX > 25 and rising, you could do something like this in MS Explorer:

Column A: ADX(21)

Filter: ADX(21)>25 AND

ADX(21)>Ref(ADX(21),-1) AND

Ref(ADX(21),-1)>Ref(ADX(21),-2) AND

Ref(ADX(21),-2)>Ref(ADX(21),-3)

For ADX starting to move higher, you could try:

Column A: ADX(21)

Column B: Ref(ADX(21),-1)

Filter: ADX(21)>ADXR(21) AND Ref(ADX(21),-1)<=Ref(ADXR(21),-1

 

SWING TRADING EXPERT

Inside(), outside(), rally(), reaction(), reactionwithvol() and rallywithvol() are all FUNCTIONS and described as such in the manual. These are not indicators, but can be used in writing an indicator. If you want to see rallywithvol() as an indicator, hit your formula button and call your new indicator rallywithvol. Then in the formula window, click on FUNCTIONS, highlight rallywithvol() and paste it in. Voila, you now have an indicator that reflects the rallywithvol() function. If you want to create a short term swing type trading system with these functions getting insights to their use which can be had by reading the description of these functions in the manual, create an expert and type the following:

(RallyWithVol() OR Rally()) AND Ref(Inside() OR Outside(),-1)

This is for the long side. Looking for a fast point or two in the next few trading sessions. Entry is just above the signal bar. Use a tight stop. If entry point was not hit, there is no trade. This is for "Hit and Run" style trading.

from Steve Denk

REACTION FUNCTIONS

I can help with explanations of the Reaction() function and other associated functions in the formula language. The functionality exist in the formula language ONLY and are not implemented as standard, built-in indicators. In order to access their capabilities, you must write a custom indicator or other formula-based calculation that calls the appropriate function. These functions are used mainly for a type of pattern similar to the functions used for candlestick patterns. The candlestick pattern functionality can also only be accessed through formula functions and not as standard, built-in indicators. Specifically, the following functions are related to the Reaction() function:

Reaction()

ReactionWithVol()

Rally()

RallyWithVol()

Inside()

Outside()

The user's manual attempts to describe the functionality of these functions, but we recently identified the fact that the user's manual did not correctly define how they work. A correct explanation for these functions follows:

Reaction() : Identifies a "reaction day". A reaction day occurs if the current bar's high is less than or equal to the previous rally or reaction day's high AND the current bar's low is less than the previous rally or reaction day's low.

ReactionWithVol() : Identifies a "reaction with volume day". This occurs if the current bar is identified as a reaction day AND the volume for the current bar is greater than the volume for the previous rally or reaction day.

Rally() : Identifies a "rally day". A rally day occurs if the current bar's high is greater than the previous rally or reaction day's high AND the current bar's low is greater than or equal to the previous rally or reaction day's low.

RallyWithVol() : Identifies a "rally with volume day". This occurs if the current bar is identified as a rally day AND the volume for the current bar is greater than the volume for the previous rally or reaction day.

Inside() : Identifies an "inside day". This occurs if the current bar's high is less than or equal to the high for the previous rally or reaction day AND the current bar's low is greater than or equal to the previous rally or reaction day's low.

Outside() : Identifies an "outside day". This occurs if the current bar's high is greater than the high for the previous rally or reaction day AND the current bar's low is less than the previous rally or reaction day's low.

Ken Hunt

SUSTAINED SWING EXPLORATION

{Place in MetaStock Explorer filter section. Recommended to predict sustained swings, contributed by from Rajat K. Bose.}

(ADX(14) < LLV(PDI(14),25) ) AND (ADX(14) < LLV(MDI(14), 25))

 

CCT LinReg OSC

{CCT LinRegOsc:}

(LinearReg(C,13)/Ref(LinearReg(C,13),-13))-1

{from Steve Karnish, Cedar Creek Trading (CCT)}

 

DOJI ALERT

I want to signal when a Doji occurs following a four-day consecutive increasing CLOSE. I would like this to be an ALERT, signalling if this completed pattern has occurred within the last five days.

from Barry Kales

ANSWER

Doji() AND

Alert((Ref(C,-1) > Ref(C,-2) > Ref(C,-3) > Ref(C,-4)),5)

from Richard Estes

 

DMI exploration version 2

QUESTION

I want to do a MetaStock Exploration with the Directional Movement Index. I want to scan for the crossing of the two, i.e., yesterday +DX is less than -DX; today +DX is greater than -DX; and visa versa.

from Dan

ANSWER

Although the names in the MetaStock quicklist drop down box are + or - DI, you will need to use PDI or MDI in your formulas. That seems to be causing your problem. PDI=Plus Directional Movement Index and MDI=Minus Directional Movement Index. Instead, use the following:

DIRECT:=PDI(14)>MDI(14);

DIRECT AND Ref(DIRECT,-1)=0;

from Dave Nadeau

 

DMI exploration version 3

QUESTION:

I want to do an exploration with Directional Movement Index. I want to scan for the crossing of the two, i.e., yesterday +DX is less than -DX, today +DX is greater than -DX and visa versa.

from Dan

ANSWER:

+DX(14) > -DX(14)

AND Ref(+DX(14),-1) < Ref(-DX(14),-1)

from Peter Gialames

 

EXCEL CONFIDENCE % INDICATOR

EXCEL CONFIDENCE % FOR METASTOCK

Simple Interpretation:

Excel Confidence % should oscillate between 0 and 100, usually at the extreme ends of the scale. A value of 0 indicates no confidence in the market going up, whilst 100 indicates perfect confidence in the market going up. Although this obviously isn't the holy grail of indicators, it does offer some insight into what the market is thinking and how one can measure investor sentiment. You might like to add a slower version of this (just increase the 3 day and 5 day calculations to something you believe to be appropriate - try 7 & 15) and trade the crossovers, as with stochastics. You can also just trade the values ie 90 or higher, buy, 10 or lower, sell.

Metastock code for Excel Confidence %:

(Sum(

Mov(C * (2.5/ Sqrt(50 * V)),10,S)-

LLV(Mov(C * (2.5/ Sqrt(50 * V)),10,S),5), 3 ) /

Sum(

HHV(Mov(C * (2.5/ Sqrt(50 * V)),10,S),5) -

LLV(Mov(C * (2.5/ Sqrt(50 * V)),10,S),5), 3) ) * 100

 

FRONT WEIGHTED MOVING AVERAGE

Simple Interpretation:

Front Weighted 36 Day Moving Average is similar to all other moving averages. The interpretation is just as with all others, the trend is up when prices are above the moving average and the trend is down when prices are below the moving averages. This particular variation attempts to weight the data at the front more than that at the back, with a sliding scale for each trading days value.

Metastock code for Front Weighted 36 Day Moving Average:

Fml( "1FrontWeighted36BarMA1" ) +

Fml( "2FrontWeighted36BarMA2" ) +

Fml( "3FrontWeighted36BarMA3" )

Where Fml( "1FrontWeighted36BarMA1" ) =

0.01 * Ref(P,-34) +

0.01 * Ref(P,-33) +

0.01 * Ref(P,-32) +

0.01 * Ref(P,-31) +

0.01 * Ref(P,-30) +

0.01 * Ref(P,-29) +

0.01 * Ref(P,-28) +

0.01 * Ref(P,-27) +

0.01 * Ref(P,-26) +

0.02 * Ref(P,-25) +

0.02 * Ref(P,-24) +

0.02 * Ref(P,-23) +

0.02 * Ref(P,-22) +

0.02 * Ref(P,-21) +

0.02 * Ref(P,-20) +

0.02 * Ref(P,-19) +

0.02 * Ref(P,-18)

Where Fml( "2FrontWeighted36BarMA2" ) =

0.03 * Ref(P,-17) +

0.031 * Ref(P,-16) +

0.031 * Ref(P,-15) +

0.031 * Ref(P,-14) +

0.031 * Ref(P,-13) +

0.031 * Ref(P,-12) +

0.031 * Ref(P,-11) +

0.031 * Ref(P,-10) +

0.031 * Ref(P,-9) +

0.031 * Ref(P,-8) +

0.006 * Ref(P,-7) +

0.006 * Ref(P,-6) +

0.07 * Ref(P,-5) +

0.07 * Ref(P,-4) +

0.07 * Ref(P,-3) +

0.07 * Ref(P,-2)

Where Fml( "3FrontWeighted36BarMA3" ) =

0.07 * Ref(P,-1) +

0.079 * P

 

SWING CHART

SWING CHART FOR METASTOCK

Among the single-handful of tech analysis indicators I've come to value in seeking out potentially profitable trades is the good old swing chart. This is not present in the standard MetaStock 6.5 armoury (at least my edition of it)but Equis derived the following formula to me some time ago for the daily swing -

If( High > Ref(High,-1) AND Low > Ref(Low,-1), High, If( High <

Ref(High,-1) AND Low < Ref(Low,-1), Low, PREV))

Simple really! It certainly doesn't show up as a nice rectangular pattern, but you get used to reading it just as fluently for just as correct interpretation. This formula is easily adapted for any other time period by using Highest High Value and such-like functions instead of the Ref function. Though with a little more tooling, it is also readily adaptable to price swing charting rather than time swings.

 

How to filter out dead stocks

Here is how I do it (in the MetaStock Explorer filter):

y1:=2000;

m1:=7;

dt:=25;

test:=If(Year()<>y1,1,If(Month()<>m1,1,If(DayOfMonth()<>dt,1,0)));

Test=1

Since the Explorer does not allow the Input Function, you will need to enter the Year, Month, and Day as the variables y1,m1,and dt, respectively.

from Michael

 

RSI of MACD

Q:=Input("Periods",1,1000,14);

Z:=Wilders(If(ROC(MACD(),1,$)>0,ROC(MACD(),1,$),0),LastValue(Q));

Y:=Wilders(If(ROC(MACD(),1,$)<0,Abs(ROC(MACD(),1,$)),0),LastValue(Q));

RS:=Z/Y;

100-(100/(1+RS))

from Pierre Tremblay

 

WRITING EXPERT COMMENTARY

Here's how to use MetaStock Expert function with the tab for commentary. For example, I wrote this commentary that I can attach to any stock, and it will give me the next day's projected high & low.

PRICES:

TODAY'S CLOSE WriteVal(CLOSE,2.3)

TOMMOROW's

PROJECTED HIGH

WriteIf(C<O, "WRITEVAL(-L+ (H+2*L+C)/2,25.2)")

WriteIf(C>O, "WRITEVAL(-L+ (2*H+L+C)/2,25.2)")

WriteIf(C=O, "WRITEVAL(-L+ (H+L+2*C)/2,25.2)")

PROJECTED LOW

WriteIf(C<O, "WRITEVAL(-H+ (H+2*L+C)/2,25.2)")

WriteIf(C>O, "WRITEVAL(-H+ (2*H+L+C)/2,25.2)")

WriteIf(C=O, "WRITEVAL(-H+ (H+L+2*C)/2,25.2)")

BOLLINGER BANDS

CLOSING PRICE:WRITEVAL(C,2.3)

BOLLINGERBAND TOP:

WRITEVAL( BBandTop(C,21,E,2),13.3)

21 DAY MOVING AVERAGE:

WRITEVAL(MOV(C,21,E),13.3)

BOLLINGERBAND BOTTOM:

WRITEVAL( BBandBOT(C,21,E,2),13.3)

FIRST RESISTANCE: WRITEVAL(-L+(2* (H+L+C)/3),1.2)

SECOND RESISTANCE: WRITEVAL(((H+L+C)/3) +((-L+(2*

(H+L+C)/3))-(-H+(2* (H+L+C)/3))),1.2)

FIRST SUPPORT:

WRITEVAL(-H+(2*(H+L+C)/3),1.2)

SECOND SUPPORT: WRITEVAL(((H+L+C)/3)

-((-L+(2* (H+L+C)/3))-(-H+(2* (H+L+C)/3))),1.2)

 from Michael Arnoldi

 

VOLUME FLOAT INDICATOR

mp1:=Input("Days Volume Summed",1,377,30);

mf1:=Input("Float, in X million",.1,10000,10);

mf2:=mf1*1000000;

(Sum(V,mp1)/mf2)*100;

from Claud Baruch

 

EXAMPLE OF A TRADING SYSTEM

Enter Long if

1) today's five-day RSI is greater than yesterday's five-day RSI; and

2) today's close is below the close of five days ago; and

3) today's close is less then or equal to the average of the last five day's closes.

Long:=RSI(5)>Ref(RSI(5),-1) AND C<Ref(C,-5) AND C<=Mov(C,5,S);

Exit tomorrow at the market if:

1) today's close is higher than the average of the last five days' closes; or

2) you have been in the trade 10 days.

If(Long=1 AND (C>(Mov(C,5,S) OR (Ref(Long,-10)=1 AND Ref(Long,-11)=0)),0,Long)

from Ton Maas

 

DIRECTIONAL MOVEMENT INDEX EXPLORATION

I want to do an MetaStock Exploration with Directional Movement Index (DMI) that will scan for the crossing of the two: i.e., yesterday +DX is less than -DX, today +DX is greater than -DX, and visa versa.

ANSWER

Ref(Cross(MDI(14) , PDI(14)),-1) AND

Cross(PDI(14) , MDI(14))

from Ton Maas

 

NORMALISING INDICATORS

In his article "Normalization", Brian Bell introduces some methods for normalizing indicators. These methods can be easily created in MetaStock 6.52 or higher.

Select Indicator Builder from the Tools Menu, click New and enter the formula for the desired method.

Name: Simple Moving Average Oscillator

OscP(4,8,S,$)

Name: Simple MA Osc norm to Std Dev

OscP(4,8,S,$)/Stdev(C,8)

Name: Simple MA Osc norm to Ave True Range

OscP(4,8,S,$)/ATR(8)

Name: Simple MA Osc norm to Historical Range

OscP(4,8,S,$)/WillR(200)

Note: To apply these methods to different indicators replace the Simple Moving Average Oscillator portion with the desired indicator's formula.

Cheryl C. Abram, Equis International, Inc.

 

Custom Relative Momentum Index (RMI) Indicator for MetaStock

Q:=Input("RSI Time Periods",1,1000,14);

M:=Input("Momentum Time Periods",1,1000,5);

B:=Input("Field: 1=Close, 2=Open, 3=High, 4=Low, 5=Volume",1,5,1);

Bval:=If(B=1,C,If(B=2,O,If(B=3,H,If(B=4,L,V))));

Mom:=Bval-Ref(Bval,-M);

Z:=Wilders(If(ROC(Mom,1,$)>0,

ROC(Mom,1,$),0),LastValue(Q));

Y:=Wilders(If(ROC(Mom,1,$)<0,

Abs(ROC(Mom,1,$)),0),LastValue(Q));

RMS:=Z/Y;

RMIcust:=100-(100/(1+RMS));

Mov(RMIcust,M,S)

from Ton Maas

 

RSI OF THE MACD

In the indicator builder, you can create RSI of MACD (with MS 6.5 and later) :

Q:=Input("Periods",1,1000,14);

Z:=Wilders(If(ROC(MACD(),1,$)>0,ROC(MACD(),1,$),0),LastValue(Q));

Y:=Wilders(If(ROC(MACD(),1,$)<0,Abs(ROC(MACD(),1,$)),0),LastValue(Q));

RS:=Z/Y;

100-(100/(1+RS))

 

From Custom Relative Strength Index (RSI) from Equis site ...

http://www.equis.com/customer/support/formulas/cf00098.html

...I just put MACD in the formula.

I hope this helps...

Pierre Tremblay

 

How can we calculate the RSI of MACD?

Warmest regards,

Alex Spiroglou

 

Create an indicator called 'System - Volatility Breakout'.

Then copy this crude code in:

*************************************************

{Volatility Breakout System - returns Profit}

Commission:=21; {for Buy+Sell+Stop}

TradeAmt:=10000;

Buy:=O+((Ref(H,-1)-Ref(C,-1))*.7);

Sell:=C;

Stop:=O;

Trade:= O<Ref(C,-1) AND H>Buy AND Ref(C,-1)<Ref(C,-2) AND

Ref(C,-2)<Ref(C,-3) AND Ref(C,-3)<Ref(C,-4); {Trigger for Trade}

HitStop:= If(Trade AND Stop>=Sell,TRUE,FALSE);

{Have we hit our Stop}

TradeSize:= TradeAmt/Buy;

Profit:=If(Trade,-Commission-TradeSize*Buy,0);{Purchase}

Profit:=If(HitStop=TRUE,{then}

Profit+Stop*TradeSize,

{else} If(Trade AND HitStop=FALSE, {then}

Profit+Sell*TradeSize,0)); {Sale}

Win:=If(Profit>0,1,0);

Loss:=If(Profit<0,1,0);

Cum(Profit)

*****************************************************

The indicator charts your profit. You just have to set the first 6 variables as per your system. The MS If structures are a pain and I'm sure there must be easier ways to do this. This is also my first attempt to prove if it works.

If you then create an Expert Advisor with the following in the Commentary definition, you'll get some summary statistics for the system.

*****************************************************

Volatility Breakout System

Security Name: <Name>

Security Symbol: <Symbol>

Totals: Trades writeval( Cum( FmlVar("System - Volatility

reakout","trade") ),0.0 ), Wins writeval(cum( FmlVar("System - Volatility

Breakout","WIN") ),0.0), Losses Writeval(cum( FmlVar("System - Volatility

Breakout","LOSS") ),0.0)

Percentage Wins/Losses: writeval(cum( FmlVar("System - Volatility

Breakout","WIN") )/Cum( FmlVar("System - Volatility

reakout","trade") )*100,2.0)%

Profit: $Writeval(cum( FmlVar("System - Volatility

Breakout","PROFIT") ),0.0)

Commission: $Writeval( FmlVar("System - Volatility

Breakout","COMMISSION"),0.0 )

Trade Amount: $Writeval( FmlVar("System - Volatility Breakout","TRADEAMT"),

0.0)

****************************************************************************

If you want to Highlight the Winning days in one colour and the Losing days in another, just use 'FmlVar("System - Volatility Breakout","WIN")' as the condition for a WIN, etc.

The above is the only way I can see to test a system in MS that specifies the entry/exit prices. I suppose the other alternative is Excel!

Sean Taylor

 

McClellan Oscillator:

1. Create a composite security in DownLoader consisting of NYSE

Advancing Issues minus NYSE Declining Issues. Name the new

security something like "Adv-Decl Issues."

2. Open the Adv-Decl Issues chart in MetaStock.

3. Create a new inner window.

4. Create two custom indicators in MetaStock:

a) First is the McClellan Oscillator:

Mov(CLOSE,19,EXPONENTIAL) -

Mov(CLOSE,39,EXPONENTIAL)

b) Second is the McClellan Summation Index:

Cum(Mov(CLOSE,19,EXPONENTIAL) -

Mov(CLOSE,39,EXPONENTIAL) )

5. Plot the McClellan Oscillator custom indicator in the main chart

window over top of the data plot and select "Display New Scale

on Right." This will eliminate the Adv-Decl Issues' scale.

6. Select the Adv-Decl Issues data plot by clicking on it, then right

click it and select "Adv-Decl Issues Properties" and change the

bar colours to the same colour as your background to make it

invisible. The raw data is needed for indicators, but need not be

displayed.

7. Plot the McClellan Summation Index in the inner window.

8. Add whatever base lines you want.

from Glen Wallace

 

ATR KELTNER BANDS

Pds1:= Input("EMA Periods?",1,100,20);

Pds2:= Input("ATR Periods?",1,100,10);

Mult:= Input("ATR Multiple?",1,10,2.5);

EMA:= Mov(C, Pds1, E);

Diff:= ATR(Pds2) * Mult;

UBand:= EMA + Diff;

LBand:= EMA - Diff;

Ema; UBand; LBand;

See also TAS&C Dec. 1999 p.45, 'Keltner Channels' by Stuart Evens.

Various STOCHASTIC RSI OPTIONS

Mov((RSI(14)-LLV(RSI(14),9))/(HHV(RSI(14),9)-(LLV(RSI(14)+.00001,6))),4,E)*100

Equis' StochRSI - Tushar Chande

(RSI(14)-LLV(RSI(14),14))/(HHV(RSI(14),14)-LLV(RSI(14),14))*100

Bell Ringer's StochRSI14 - John A. Yurko

(Sum(RSI(14)-LLV(RSI(14),14),3)/Sum(HHV(RSI(14),14)-LLV(RSI(14),14),3))*100

StochRSI oscillator - Craig DeHaan

{configurable formula for the StochRSI oscillator to quickly find what time

periods/method you prefer to work with. CDH's List-post.

(Sun, 15 Nov 1998 "Re: Finding the Stochastic of the Relative Strength")}

mp1:=Input("RSI Periods",1,377,13);

mp2:=Input("Stochastic Periods",1,377,13);

mp3:=Input("Smoothing Periods",1,377,8);

mat:=Input("MA Type: S, E, W",1,3,2); {1=S,2=E,3=W}

If(mat=1, Mov((RSI(mp1)-LLV(RSI(mp1),mp2))/(.0000001+

HHV(RSI(mp1),mp2)-LLV(RSI(mp1),mp2)),mp3,S)*100,

If(mat=2, Mov((RSI(mp1)-LLV(RSI(mp1),mp2))/(.0000001+

HHV(RSI(mp1),mp2)-LLV(RSI(mp1),mp2)),mp3,E)*100,

If(mat=3, Mov((RSI(mp1)-LLV(RSI(mp1),mp2))/(.0000001+

HHV(RSI(mp1),mp2)-LLV(RSI(mp1),mp2)),mp3,W)*100,0)))

============================================================

Stochastic Relative Strength Index { from www.equis.com }

rev. 01/06/97

In his book The New Technical Trader, Tushar Chande defines the Stochastic RSI as:

StochRSI = (RSI - RSIL)/(RSIH -RSIL)

where RSIL and RSIH are the lowest and highest values of the RSI over a given period.

In his book he uses 14 periods. The MetaStockT formula for the Stochastic RSI is:

( ( RSI ( 14 ) - LLV( RSI (14 ) ,14 ) ) / ( ( HHV( RSI (14 ) ,14 ) ) - LLV(RSI (14 ),14 ) ) )

from Ton Maas

 

PSYCHOLOGICAL INDEX

There was an overbought/oversold indicator described in the June 2000 Futures Magazine called the Psychological Index. It looked sort of interesting, so I wrote the MetaStock code for it:

{Futures Magazine, Vol.29 No.6, June 2000, P.48}

LookBack:= Input("Number of lookback periods", 2, 100, 12);

UThreshold:= Input("Upper threshold (%)", 0, 100, 75);

LThreshold:= Input("Lower threshold (%)", 0, 100, 25);

UpDay:= If(CLOSE > Ref(CLOSE,-1), 1, 0);

PsychIndex:= Sum(UpDay,LookBack) / LookBack * 100;

PsychIndex; UThreshold; LThreshold

from Glenn Wallace

 

Buy and Hold Indicator

periods:=Cum(If(C>0,1,0));

dollars:=C-ValueWhen(1,periods=1,C);

percnt:=C/ValueWhen(1,periods=1,C);

percnt; [or] dollars;

You can quickly run an exploration and look at the buy and hold on everything in dollars or in percentage terms.

Michael

 

PERSISTENCY OF MONEY FLOW

Period := Input("Period",10,200,20);

Mov(If( CMF(Period ) > 0, 1, -1),Period,S)/Period;

0;

from Bob Sims

 

Doji alert

I want to signal when a Doji occurs following a four-day consecutive increasing CLOSE. I would like this to be an ALERT, signaling if this completed pattern has occurred within the last five days. from Barry Kales

Alert(Doji() AND

Ref(C,-1) > Ref(C,-2) AND

Ref(C,-2) > Ref(C,-3) AND

Ref(C,-3) > Ref(C,-4) AND

Ref(C,-4) > Ref(C,-5),5)

from CatLady

 

Sine wave

This is a 28 period sine wave. The "flaw" is that it starts from the first period loaded in the chart rather than an absolute date. Change the -12 to shift the wave right or left.

Ref(Sin( Cum(360/28) ), -12)

There's also MetaStock's built-in cycle lines drawing tool.

 from CatLady

 

Displaced moving average system test

Here's an example of how to specify displaced moving average in the system tester . . . .

Buy:

Cross(C,Ref(Mov(C,50,e),-15)) {uses 50ema displaced by 15 days}

Sell:

Cross(Ref(Mov(C,50,e),-15),C)

from Paul Beattie

 

Volatility Exploration

ATR(20) / MOV(Close,20,Simple)

from Glen Wallace

 

Smoothed adapative Stochastic Oscillator

n:=Input("**Volatility** lookback length",1,50,20);

x:=Input("%K smoothing (exponential smoothing)",1,50,3);

y:=Input("%D smoothing (exponential smoothing)",1,50,3);

lenmax:=28;

lenmin:=7;

v1:=Stdev(C,n);

v2:=HHV(v1,n);

v3:=LLV(v1,n);

v4:=((v1-v3)/(v2-v3));

currlen:=(Int(lenmin+(lenmax-lenmin)*(1-v4)));

hh:=HHV(H,LastValue(currlen));

ll:=LLV(L,LastValue(currlen));

RawStochK:=((C-ll)/(hh-ll))*100;

SmoothedStochK:=Mov(RawStochK,x,E);

StochD:=Mov(SmoothedStochK,y,E);

20;

80;

StochD;

SmoothedStochK;

from iamken

 

GUPPY MULTIPLE MOVING AVERAGE EXPLORATION for Metatstock V7.                       

Exploration notes    This uses the results of 6 custom indicators          HINT When constructing this exploration use the PASTE FUNCTIONS button to transfer the exact formula name to the exploration.

Col A: close            CLOSE         

Col B: Ref(C,-1)        

Col C: Ref(C,-2)        

Col D: Fml( "MMA 3/30") + Fml( "MMA 5/35") + Fml( "MMA

            8/40") + Fml( "MMA 10/45") + Fml( "MMA 12/50") +         

            Fml( "MMA 15/60")

Col E:             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)     

Filter            When(colD,>,0) AND When(colE,<=,0)        

                       

CUSTOM MMA  INDICATORS – Must be installed using the Indicator builder before Guppy Multiple Moving Average Exploration can be run.

MMA 10/45

If(OscP(10,45,E,%)>0,+1,-1)

MMA 12/50

If(OscP(12,50,E,%)>0,+1,-1)

MMA  15/60

If(OscP(15,60,E,%)>0,+1,-1)

MMA 3/30

If(OscP(3,30,E,%)>0,+1,-1)

MMA  5/35

If(OscP(5,35,E,%)>0,+1,-1)

MMA 8/40

If(OscP(8,40,E,%)>0,+1,-1)

 

Finding rising moving averages
You just want to ask for an MA higher than yesterday, or higher than last week. So e.g., "mov(c,20,s)>ref(mov(c,20,s),-1)" or
"mov(c,20,s)>ref(mov(c,20,s),-7)"

Malcolm Scott



Using the call function
Create a few indicators and add them to your formula by calling on them via the formula call function:

Example: Create a few new indicators, e.g., n=1,2,3, etc.

Name: MyIndicator-n
Formula: Mov(c,10,s)

Now use the formula call function, e.g., create yet another indicator:

Name: MyCalls
Formula: fml (" MyIndicator-n ")

Place the above line in the formula field and repeat the line as needed.

from Ton Maas



Call function explanation

"When I use the FML() function in a formula to call a Multiple Expression formula my formula only sees one of the Lines. Why? "

The FML() function cannot call multiple values from one formula to another formula. The FML function can only call one value from one formula to another. If FML() calls a Multiple Expression formula it can only return the value of the Last Expression in a Multiple Expression formula, from one formula to another.

For example the following formula creates a Customized MACD with 3 trigger lines. When plotted it plots a total of 4 lines, exactly as expected.

Mov(C,11,E)-Mov(C,30,E);
Mov(Mov(C,11,E)-Mov(C,30,E),12,E);
Mov(Mov(C,11,E)-Mov(C,30,E),25,E);
Mov(Mov(C,11,E)-Mov(C,30,E),50,E)

In this example Mov(Mov(C,11,E)-Mov(C,30,E),50,E) is the Last Expression in this Multiple Expression formula. An FML() call to this formula returns the value of Mov(Mov(C,11,E)-Mov(C,30,E),50,E).

If you need to use FML() to call multiple values into another formula it is best to break the Multiple Expression Formula into Separate formulas. Then call each separate formula with a separate FML() call.

The following example formula uses FML() calls but would generate multiple plots when displayed in a chart:

FML("Mov(C,11,E)-Mov(C,30,E)");
FML("Mov(Mov(C,11,E)-Mov(C,30,E),12,E)"); FML("Mov(Mov(C,11,E)-Mov(C,30,E),25,E)");
FML("Mov(Mov(C,11,E)-Mov(C,30,E),50,E)")

You could also assign variables to each expression and then use the FMLVAR() function to call each of the expressions.

For example:

Formula: Multiple

One := Mov(C,11,E)-Mov(C,30,E);
Two := Mov(Mov(C,11,E)-Mov(C,30,E),12,E);
Three := Mov(Mov(C,11,E)-Mov(C,30,E),25,E);
Four := Mov(Mov(C,11,E)-Mov(C,30,E),50,E);
One;
Two;
Three;
Four

Formula: Call

FMLVAR("Multiple","One");
FMLVAR("Multiple","Two");
FMLVAR("Multiple","Three");
FMLVAR("Multiple","Four")

Refer to the MetaStock 6.5 manual and/or on-line help for more information on using variables and the function FMLVAR().

from Equis Support and Ton Maa



Example of use of Prev function
vPrev:=PREV;
Ndays:=If(Cum(1) < 50,Cum(1),vPrev);
Ndays2:=If(Ndays>0,Ndays,LastValue(Ndays>0));
Ndays2

{fromTon Maas}


Chandelier Exit variation
Below is a variation of the Chandelier Exit that I came up with. It doesn't solve the original question, but I like the way it plots better. It holds
the highest value every time the stop moves up, and never moves lower unless the stop is hit, in which case its value is reset.
from Barry Marx

Stop1:=If( PREV < L,
{then} If(( H - 3*ATR(10) ) >= PREV,
{then} ( H - 3*ATR(10) ),
{else} PREV),
{else (L <= PREV)}
( H - 3*ATR(10) ));

Stop2:=If( PREV < L,
{then} If(( C - 2.5*ATR(10) ) >= PREV,
{then} ( C - 2.5*ATR(10) ),
{else} PREV),
{else (L <= PREV)}
( C - 2.5*ATR(10) ));

StopVal:=If(Stop1>Stop2,Stop1,Stop2);

StopVal;


Zero lag MACD 2
Here's my MetaStock v6.2 coded version of the Zero Lag Moving Average, as described in the April, 2000, issue of Technical Analysis of Stocks and Commodities. I've also used it to construct a Zero Lag MACD and a Zero Lag MACD trigger signal.

Period:= Input("What Period",1,250,10);
EMA1:= Mov(CLOSE,Period,E);
EMA2:= Mov(EMA1,Period,E);
Difference:= EMA1 - EMA2;
ZeroLagEMA:= EMA1 + Difference;
ZeroLagEMA

from J. Seed



RSI of MACD
UpCl:= C * (C > Ref(C, -1));
Sum(UpCl,14);

from HHP


Three day Engulfingbear short trade

Buy again three days after the signal.

ENTER SHORT
Engulfingbear()
{Means: today there was an engulfingbear signa, so enter trade.}

EXIT SHORT
Ref(Engulfingbear, -3)
{Means: as of the current day, there was an EngulfingBear three days previous, so exit the trade today.}

from Walter Lake and HHP



Buy trigger trading system
{Enter long}
{System Tester options are set to enter on the Close}
BuyTrigger:=(MOV(C,10,E) - MOV(C,30,E)) / MOV(C,30,E);
BuyTrigger > 0.05

{Close long}
BuyTrigger:=(MOV(C,10,E) - MOV(C,30,E)) / MOV(C,30,E);
BuyPrice:= If(PREV <= 0,
{Then did you go long today?}
If(BuyTrigger > 0.05, CLOSE, 0),
{Else did you exit today?}
If(Close >= PREV*(1+BuyTrigger), -PREV,
PREV));
BuyPrice < 0

{In this formula, BuyPrice is the close on the date BuyTrigger exceeds your threshold. If you are in a trade and have just received a sell signal, BuyPrice is redefined as a negative, and System Tester is told to close your long position. If you are not currently in a trade, BuyPrice is assigned a zero value and System Tester is told to watch for a new long entry.}

{from Glenn Wallace}


GANN-HiLo 2

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;



Gann hi lo crossover
I took the "GANN-HiLo" indicator one step further, exploring in EOD which stocks crossed the GANN-HiLo dots.

cola buy:
Cross(C, Fml("GANN-HiLo")) AND
CLOSE > Fml("GANN-HiLo")

colb sell:
Cross(C, Fml("GANN-HiLo")) AND
CLOSE < Fml("GANN-HiLo")

filter:
cola=1 or colb=1


from Mike Arnoldi