How to identify the best performing sector, and then the best performing stocks in that sector.

Open the explorer and click new.

Give your new exploration a name. For example “Sectors sorted by performance”

In the Notes box, write a brief description of the scan. For example “To rank the sectors by their historical performance”

There are two types of columns in the explorer, the alphabetical columns, and the filter column.

The alphabetical columns simply work out a value for you. For example if you type “close” in column A, MetaStock will calculate and display the close price.

The filter column is different, it allows you to make rules or conditions, and only allows stocks that have passed these conditions to show up in the report. For example you can say “close > 10” and MetaStock will filter out any stocks that are below $10.

For this scan we will only use the alphabetical columns.

**We want to know which sectors have had the best performance over the last month, 3 months, and 12 month periods. The best way to do this is to use the “rate of change” indicator. Here is how to use it:**

**First type “1 month” into the small “col. A Name” box. Then copy and paste the below formula into Column A:**

### 21

ROC(CLOSE,21,%)

**Then type “3 month” into the small “col. B Name” box. Then copy and paste the below formula into Column B:**

### 63

ROC(CLOSE,63,%)

**First type “12 month” into the small “col. C Name” box. Then copy and paste the below formula into Column C:**

### 250

ROC(CLOSE,250,%)

Identifying resistance levels using the explorer has always been difficult. This is because support and resistance is easier to see visually on a chart than it is to explain in mathematical terms. My solution was to allow a little leeway in the formula which is explained below. As a result the search works quite well.

Please don’t be put off by all the details in this email, it’s not that complicated, in fact the entire process should take no longer than 5 minutes.

To add this search to your copy of MetaStock, open the explorer and click “new”.

Give your new exploration the name “Stocks near resistance level”

In the notes box type “Looking for stocks close to or touching resistance levels”.

Just like last week, we need to put some values in the alphabetical columns.

Again these codes are very simple, they tell MetaStock to return a value of “one” if a chart has had a peak at the same price level, or a value of “zero” if did not. This scan is using both a 10% and 15% zigzag to gauge where the peaks have occurred. As mentioned above, I have allowed a bit of leeway to this rule. I ask MetaStock to allow stocks to pass this filter if their peak is within 6% of a prior peak.

The next step is to copy and paste the following code into each of the alphabetical tabs, starting with column.

First type “Close” into the small “col. A Name” box. Then copy and paste the below formula into Column A:

Close

Then type “Ave Vol$” into the small “col. B Name” box. Then copy and paste the below formula into Column B:

Mov(CLOSE,100,S)*Mov(VOLUME,100,S)

Then type “10peak+2” into the small “col. C Name” box. Then copy and paste the below formula into Column C:

If(Peak(2,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak+3” into the small “col. D Name” box. Then copy and paste the below formula into Column D:

If(Peak(3,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak+4” into the small “col. E Name” box. Then copy and paste the below formula into Column E:

If(Peak(4,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak-2” into the small “col. F Name” box. Then copy and paste the below formula into Column F:

If(Peak(2,C,10) < HHV(CLOSE,100)*1.04,1,0)

Type “10peak-3” into the small “col. G Name” box. Then copy and paste the below formula into Column G:

If(Peak(3,C,10) < HHV(CLOSE,100)*1.04,1,0) Type “15Peak+2” into the small “col. H Name” box. Then copy and paste the below formula into Column H: If(Peak(2,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak+3” into the small “col. I Name” box. Then copy and paste the below formula into Column I:

If(Peak(3,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak+4” into the small “col. J Name” box. Then copy and paste the below formula into Column J:

If(Peak(4,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak-2” into the small “col. K Name” box. Then copy and paste the below formula into Column K:

If(Peak(2,C,10) < HHV(CLOSE,100)*1.03,1,0)

Type “15Peak-3” into the small “col. L Name” box. Then copy and paste the below formula into Column L:

If(Peak(3,C,15) < HHV(CLOSE,100)*1.03,1,0) Lastly copy and paste this into the filter box: CLOSE > HHV(CLOSE,100)*.96 AND colB>100000 AND colC+colD+colE+colF+colG=5 OR

CLOSE > HHV(CLOSE,100)*.96 AND colB>100000 AND colH+colI+colJ+colK+colL=5

So how does the scan work?

The alphabetical columns are going to calculate and display a value. The value will be either one or zero depending on whether we have a peak within 6% of the peak that took place before. Just like last week “one” means yes, and “zero” means no.

The filter simply says that we need three peaks to be within 6% of each other.

If you look at the formula, you will notice the values are either being multiplied by .97 or by 1.03. This is to allow the 6% tolerance. In other words it’s ok to be either 3% below or 3% above the previous value.

It’s easy to alter this tolerance, for example change the filter to:

If(Peak(1,C,15) > HHV(CLOSE,100)*.90,1,0)

This simply says that it’s ok to be 10% below the prior peak.

Did you know that you can use the MetaStock explorer to find some specific chart patterns. For this example I will start with a Japanese candlestick pattern called the “hammer”. The hammer pattern (as you would expect) looks like a hammer, it has a long bottom spike where the stock traded at a low, but the open and close are at the top of the daily range.

MetaStock already knows all of the major candlestick patterns, and so making an exploration to find them is extremely easy. All you need to do is:

Open the explorer

Click new.

Give the explorer a name: Hammer according to MetaStock.

In the filter tab, click in the empty formula box.

Select “Functions”

This brings up the functions box, on the left click candlesticks.

Make sure both “paste argument” and “show English name” boxes are ticked.

On the right hand side choose the candle pattern you would like to use in your search (in this case the hammer) and hit OK.

This essentially writes the formula for you.

You can simply run this scan over the market and your done.

You may have already known how to do that; so here is where I want to deviate from the standard pre-built chart patterns built into Metastock. These pre-built patterns work well, and will indeed find the candlestick your looking for, but I prefer to have more control over the exact details of what I want to find. The problem I found is that my idea of a hammer and MetaStock’s Idea of a hammer don’t always agree with each other.

Below I have written (and explained) my version of a hammer pattern. Why not compare the two and see how writing your own pattern can work as well as, or better than, those that come out of the box.

Just like the above example.

Open the explorer

Click new.

Give the explorer a name: Hammer according to “enter your name here”.

In the filter tab, click in the empty formula box.

Paste the below formula in:

H-L > ATR(14)*1.5 AND (H-C)/(H-L).11

Here is the explanation for each part of this formula:

Rule1. I wanted today’s trading range to be above average. So this formula demands that the range (calculated from the high minus the low) is at least one and a half times the average true range.

H-L > ATR(14)*1.5

Rule 2. I wanted the close to be in the upper 25% of that range.

(H-C)/(H-L)<0.25

Rule 3. I also wanted the open to be within the upper 25% of the daily range.

(H-O)/(H-L).11

I think that the first and fourth rule are probably the most important. This is because I believe a hammer pattern should have a reasonable daily range and be close to a significant low. These are things the standard pre-built patterns don’t allow for.

I believe trailing stops work best in most cases, and allthough MetaStock comes with its own trailing stop loss indicator built in, here is the formula for a simple trailing stop loss indicator you can build yourself. This one works well as a general all-rounder and I have found it really helpful.

HHV(CLOSE – 3*ATR(5),20)

You can copy and paste the above indicator straight into the indicator builder, using the instructions.

Open the indicator builder (the F(x) symbol at the top of your MetaStock program)

Click “New”

Enter name “Trailing stop loss”

Copy and paste the below formula into the formula box:

HHV(CLOSE – 3*ATR(5),20)

Then simply click OK and then drag and drop the indicator into your chart.

In this example we are looking back 20 periods for the “highest high value” of a 5 period “average true range” indicator (with a multiplier of 3). These values can be changed, and in the next article we talk about how to figure out the best stop loss values for any stock in your portfolio by back testing the variations.

In the previous article we used a basic trailing stop loss indicator: HHV(CLOSE – 3*ATR(5),20)

This time we will use the system tester to see if we can improve on these values.

Have a look at the indicator and remember the numbers its using 3, 5 and 20. The goal here is to test and see which parameters work BEST on the stock you are trading. Perhaps you can improve on the values 3, 5 and 20.

Before we start, it’s good to have a basic understanding of how this indicator works. This indicator is based on the average true range (ATR). It calculates the average range that the stock moves over the last 5 periods (one week) and then multiplies that value by a factor of 3. Finally it subtracts this value from today’s closing price. So let’s imagine a stock is trading at $1.00. It might have an average true range of 4c (or 4%). If we multiply that by 3 we get 12c. We then subtract this figure from the $1 close price and come up with a theoretical stop loss of 88c.

The idea is that more volatile stocks need more leeway to prevent getting stopped out on normal price fluctuations.

The indicator then tracks the stop price as it rises, but maintains its highest level (over the prior 20 periods) when the stock begins to fall. In effect; locking in profit each time the stock moves in our favour.

Regardless of what your entry criteria may be, try and use a trailing stop loss the next time you run a back test. Instead of assuming that a one week ATR is best or that multiplying the ART by a factor of 3 is best. You can ask MetaStock to test a multiple of combinations and tell you which values have worked best in the past. In this example I am using a simple moving average as an entry condition.

Open the system tester.

Click “new system”

In the “general” tab, give your new trading system a name.

In the “Buy Order” tab enter the following: cross(c,mov(c,80,s))

In the Sell Order” tab enter the following: cross(HHV(CLOSE – opt1*ATR(opt2),opt3),c)

In the “Optimisation” tab you will see the opt1, opt2 and opt3 that you have created.

You need to tell MetaStock a minimum and maximum value for MetaStock to test.

Opt1 is how many times you would like to multiply the ATR.

Opt2 is the number of periods over which the ATR is calculated.

Opt3 is how many periods MetaStock should look back when calculating the highest value of the stop loss.

Double click the opt1 values and enter the following:

Opt1: Minimum 2, Maximum 10, and step 2.

Opt2: Minimum 5, Maximum 30, and step 5.

Opt3: Minimum 5, Maximum 100, and step 5.

Click Ok and then New simulation. Select the System and then hit “Next”. Choose a stock using the add security tab and hitting open. Then next, and next and then start.

The system will take some time to run as it has to calculate all of the combinations of indicator variables. It then comes back with the results of the best performing values.

When the system test is complete, view the results by clicking on the $ sign and select the report.

On the right hand side of the report you will now see values in the “opt” columns. These are the values you should use for your stop loss.

For example if the opt columns display opt1 = 2, opt2 = 15 and opt3 = 45, then the best stop loss indicator to use would be:

HHV(CLOSE – 2*ATR(15),45)

You can easily alter the stop loss indicator parameters to reflect the results:

Remember we started off with 3, 5 and 20.

We started with HHV(CLOSE – 3*ATR(5),20)

We then removed the numbers and replaced them with “opt” like this: HHV(CLOSE – opt1*ATR(opt2),opt3)

Now that we have the best results for that indicator we can choose (as an example): HHV(CLOSE – 2*ATR(15),45)

In the last artical we looked at how to back test a stop loss. Remember we started off with the values 3, 5 and 20.

We started with HHV(CLOSE – 3*ATR(5),20)

After testing we decided to change the values to 2, 15 and 20.

This leaves us with the problem of having to re-write our stop loss indicator with these new values.

So in the below examples I show you how to get MetaStock to prompt you to enter the values you would like to use into your own custom indicator as soon as you drag it onto the chart. This makes entering different values into your own customer indicator easier. I will start off with a simple moving average example first:

Normally, you would write a 21 day simple moving average like this:

Mov(CLOSE,21,S)

But you can get rid of the “21” and replace it with some text, in this example “Movperiods” (but you can use any text so long as it is matched up with an input). Then, all you need to do is tell MetaStock to ask for the input value. That way it’s easy to change it from a 21 day to say a 13 day moving average. Here is the code:

Movperiods:= Input(“Enter the Move Ave Periods”,1,100,21);

Mov(CLOSE,Movperiods,S)

The input needs to know the minimum, maximum and default values for your indicator. In the above example we have a minimum of 1 and maximum of 100 and a default of 21. Copy and paste both lines of code into the indicator builder to see how it works.

A 21 day moving average is easy, since there is only one input to change. However, our stop loss indicator had three inputs.

We started with HHV(CLOSE – 3*ATR(5),20)

So, just like we did with the moving average example above, we simply replace the numbers with text for our custom Stop loss indicator.

Copy and paste the inputs below (4 lines) into the indicator builder to create your own custom Stop loss indicator in MetaStock.

multiplier:= Input(“Enter ATR multiplier “,1,10,3);

atrperiods:= Input(“Enter ATR periods”,1,40,5);

hhvperiods:= Input(“HHV Period”,1,50,20);

HHV(CLOSE – multiplier*ATR(atrperiods),hhvperiods)

This exploration can be modified to suit your exact criteria by altering the 50 to a number that suits your timeframe better.

In Metastock open the explorer and select new exploration. Copy the code below and paste it into the filter tab.

Now select the stocks to run the exploration over and hit explore.

(C>Mov(C,50,E) AND Ref(C,-5)<Ref(Mov(C,50,E),-5)) AND C>5

The below example looks for stocks where today’s volume is at least 10 times greater than average over the previous 50 periods.

Open MetaStock; Open the explorer and click new. Give your new exploration a name. For example: Volume Spike In the notes box, write a brief description of the scan. For example: Find stocks with unusually high volume.

In column A: Column name: Avrg Vol Formula: Mov(V,50,S)

In column B: Column name: Volume Formula: V

In column C: Column name: Liquid Formula: Mov(V,50,S) * Mov(C,50,S) This bit of code allows you to see what the average $ value traded on this stock has been ie to gauge liquidity in your search results.

In the filter: colB>(colA*10) This bit of code is asking for volume to be ten times the average volume and can easily be changed to *15 or any amount. This scan can be modified or used in conjunction with other criteria. For example you can add to the filter to exclude stocks unless they are trading above the 50 day moving average by adding an “and” statement, then a moving average filter like below. colB>(colA*10) and c > mov(c,50,s) This part of code can also be changed to suit your needs ie and c > mov(c,20,s) or stocks above a 20 day moving average

If you need help with this scan feel free to email us at info@metastockaustralia.com.au

How to make your own expert advisor in MetaStock.

The expert advisor icon is located at the top of the MetaStock screen, the icon is that of a man in a bowler hat.

Open the “Expert Advisor” Click “New” on the right hand side. This brings up a new box that has a number of tabs. The first tab “name” allows you to choose a name and add a note to your new expert.

For this example I have named my system “MSAUST Trending Expert” Next click on the “highlights” tab at the top. In the highlights tab hit “new” on the right hand side. Give this box the name “Up trend” and choose the colour green from the color box at the top.

Next either type or copy and paste the below formula into the “condition” box. C > HHV(L – 3*ATR(9),20) AND CLOSE > Mov(C,34,S) Click ok and then hit new again.

Repeat the process only this time name your box “Down trend”, choose red as your colour, and use the below formula: C < HHV(L – 3*ATR(9),20) AND CLOSE < Mov(C,34,S) Click Ok.

Congratulations, you have now created your own expert advisor. To view your expert advisor, open a chart, select your expert from the list and click attach, then close. Your chart should appear with green and red highlights based on your MSAUST Trending Expert system.

Find stocks with a rising moving average.

This exploration can be modified to suit your exact criteria by altering the 50 to a number that suits your timeframe better.

In Metastock open the explorer and select new exploration. Copy the code below and paste it into the Filter tab.

C> Mov(C,50,E) AND

Mov(C,50,E)>Ref(Mov(C,50,E),-1)*1.003

Now select the stocks to run the exploration over and hit explore.

How to search in Metastock’s explorer to find over bought and oversold stocks based on a RSI (14) indicator.

Overbought exploration.

Open Metastock, click on explorer and select new.

Paste the following code into the FILTER section.

HHV(RSI(14),10)>70

Oversold exploration.

Open Metastock, click on explorer and select new.

Paste the following code into the FILTER section.

LLV(RSI(14),10)

How to search for stocks in Metastock priced between .50c and $5.00 or any variation of these prices.

This exploration need to be entered into three windows in Metastock’s explorer, ColA, ColB and the Filter.

Open the explorer and select new.

Enter the below code into the relevant window in the explorer and select save.

ColA CLOSE > .5

ColB CLOSE < 5

Filter colA AND colB = TRUE

Now run this scan across any group of stocks or exchanges.

Identifying resistance levels using the explorer has always been difficult. This is because support and resistance is easier to see visually on a chart than it is to explain in mathematical terms. My solution was to allow a little leeway in the formula which is explained below. As a result the search works quite well.

Please don’t be put off by all the details in this code, it’s not that complicated, in fact the entire process should take no longer than 5 minutes.

To add this search to your copy of MetaStock, open the explorer and click “new”.

Give your new exploration the name “Stocks near resistance level”

In the notes box type “Looking for stocks close to or touching resistance levels”.

We need to put some values in the alphabetical columns.

Again these codes are very simple, they tell MetaStock to return a value of “one” if a chart has had a peak at the same price level, or a value of “zero” if it did not. This scan is using both a 10% and 15% zigzag to gauge where the peaks have occurred. As mentioned above, I have allowed a bit of leeway to this rule. I ask MetaStock to allow stocks to pass this filter if their peak is within 6% of a prior peak.

The next step is to copy and paste the following code into each of the alphabetical tabs, starting with column A.

First type “Close” into the small “col. A Name” box. Then copy and paste the below formula into Column A:

Close

Then type “Av Vol$” into the small “col. B Name” box. Then copy and paste the below formula into Column B:

Mov(CLOSE,100,S)*Mov(VOLUME,100,S)

Then type “10peak+2” into the small “col. C Name” box. Then copy and paste the below formula into Column C:

If(Peak(2,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak+3” into the small “col. D Name” box. Then copy and paste the below formula into Column D:

If(Peak(3,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak+4” into the small “col. E Name” box. Then copy and paste the below formula into Column E:

If(Peak(4,C,10) > HHV(CLOSE,100)*.96,1,0)

Then type “10peak-2” into the small “col. F Name” box. Then copy and paste the below formula into Column F:

If(Peak(2,C,10) < HHV(CLOSE,100)*1.04,1,0)

Type “10peak-3” into the small “col. G Name” box. Then copy and paste the below formula into Column G:

If(Peak(3,C,10) < HHV(CLOSE,100)*1.04,1,0) Type “15Peak+2” into the small “col. H Name” box. Then copy and paste the below formula into Column H: If(Peak(2,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak+3” into the small “col. I Name” box. Then copy and paste the below formula into Column I:

If(Peak(3,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak+4” into the small “col. J Name” box. Then copy and paste the below formula into Column J:

If(Peak(4,C,15) > HHV(CLOSE,100)*.97,1,0)

Type “15Peak-2” into the small “col. K Name” box. Then copy and paste the below formula into Column K:

If(Peak(2,C,10) < HHV(CLOSE,100)*1.03,1,0)

Type “15Peak-3” into the small “col. L Name” box. Then copy and paste the below formula into Column L:

If(Peak(3,C,15) < HHV(CLOSE,100)*1.03,1,0) Last copy and paste this into the filter box: CLOSE > HHV(CLOSE,100)*.96 AND colB>100000 AND colC+colD+colE+colF+colG=5 OR

CLOSE > HHV(CLOSE,100)*.96 AND colB>100000 AND colH+colI+colJ+colK+colL=5

So how does the scan work?

The alphabetical columns are going to calculate and display a value. The value will be either one or zero depending on whether we have a peak within 6% of the peak that took place before. Just like last week “one” means yes, and “zero” means no.

The filter simply says that we need three peaks to be within 6% of each other.

If you look at the formula, you will notice the values are either being multiplied by .97 or by 1.03. This is to allow the 6% tolerance. In other words it’s ok to be either 3% below or 3% above the previous value.

It’s easy to alter this tolerance, for example change the filter to:

If(Peak(1,C,15) > HHV(CLOSE,100)*.90,1,0)

This simply says that it’s ok to be 10% below the prior peak.

How to find stocks priced < $1 with minimum volume of > 300,000

Many customer ask for this type of exploration, it is a simple code that looks for all stocks priced less than $1 with minimum volume of 300,000 shares; the variables can be easily altered to suit your personal needs.

For example you may wish to substitute the $1 for $5 etc

Open a new exploration in Metastock and enter the follow text into the following columns and the filter tab.

Cola CLOSE < 1 Colb V > 300000

Filter colA AND colB = TRUE

Now click the OK button and the exploration will be added to your list and can be run across your selected stocks.

This Metastock exploration searches for stocks where the 50 period exponential moving average has crossed above the 100 period exponential moving average in the past 5 periods.

I like to add a close and volume column to my explorations to allow me to filter the exploration results by price or volume.

To do this we need to add the following to Column A and B, please note these columns do not have any effect on the exploration, they are only there to allow us to filter the results.

Cola ( large text box ) C

Cola ( small name box) close

Colb ( large text box ) V

Colb ( small name box ) Vol

Filter tab

(C>Mov(C,50,E) AND (Mov(C,100,E))AND Mov(C,50,E) > Mov(C,100,E) AND Ref(Mov(C,50,E),-5) < Ref(Mov(C,100,E),-5))

This Metastock exploration looks for stocks that are trading at a new high for the past 250 periods. The look-back on this exploration can easily be altered to suit your preferred period by replacing the 250 in the code with a 100 or 500 etc. We have also added a filter that looks for stocks making a new high over the last 250 periods, but this new high must have occurred yesterday ( the -1 in the code), this part can also be changed to say a -5 to find stocks where the new high has occurred in the past 5 days etc.

The code has a few parts, each column has its own criteria as does the filter. Select a new exploration in Metastock and enter the following information under each column heading and filter tabs.

ColA HHV(H,250)

ColB Ref(HHV(H,250),-1)

ColC (HHV(H,250))/(Ref(HHV(H,250),-1))*100-100

Filter H=HHV(H,250) AND

Ref(Cum(H=HHV(H,250)),-250) = Ref(Cum(H=HHV(H,250)),-2) AND Cum(H=HHV(H,250))>Ref(Cum(H=HHV(H,250)),-1)

Bull Power: H – Mov(C,13,E) (High minus the moving average)

Bear Power :L – Mov(C,13,E) (Low minus the moving average)

To plot the Elder Ray Indicator:

Create the two custom formulas from above.

Open the base security.

Plot a 13-Period Exponential Moving Average of the closing price in a new inner window.

Drag the Bear Power formula and drop it in a new inner window.

Drag the Bull Power formula and drop it in a new inner window.

Or, you may drop all three indicators in the same inner window if you wish.V*(C-ref(C,-1))To plot this formula as a histogram, after dropping the formula in an inner window, right click on the indicator and select properties. Select styles and choose the histogram.

NOTE: This formula requires the presence of volume data to work

The formula for the force index is:

V*(C-ref(C,-1))

**NOTE: This formula requires the presence of volume data to work**

To plot this formula as a histogram, after dropping the formula in an inner window, right click on the indicator and select properties. Select styles and choose the histogram.