How to Design a Trading System Within MetaStock.

tanewbie

Well-Known Member
#1
Recd this by email. As I dont use metastock I cant answer any questions on it.


How to Design a Trading System Within MetaStock.

Let`s start right where we left off. We had just finished discussing the major components when designing any mechanical entry system. They included a measure of:
1. Price.
2. Liquidity.
3. Trend.
4. Volatility.
Now how do we code this into MetaStock?
Well let me offer the most valuable gem of knowledge I have learned over the years regarding MetaStock formula writing. This one secret, although very simple, will ultimately turn you into a MetaStock master...
Let me put it this way... Do you think I know all of MetaStock`s hundreds of preprogrammed formulas and propriety indicators? No, I`m good... but not that good ;-)
So what is my secret?
Well, when coding in MetaStock, the key to getting it "right" is to write "down in English" what it is you are trying to achieve. Once done, it is quite easy to convert this into MetaStock formula.
Let`s see what I mean by looking at an example. Our first entry condition is a measure of price. As mentioned in the last issue, the aim of setting price minimums is to remove speculative stocks.
Please note: the values you select will depend on the exchange you are trading (some markets tend to be more expensive than others.) However, for this example, we are looking to design a long-term trend following system to trade on the Australian Stock Exchange.
In Australia, anything under $1 could be classed as speculative. So how do you stipulate those stocks must be greater than $1? Now here comes the "write it in English first" part:
We want stocks with a 21-day average of closing price to be greater than $1.
Next, we must convert this into MetaStock formula.
Using the formula reference guide in the MetaStock Programming Study Guide, you can check the syntax of a moving average. With this information, it`s simply a matter of plugging in the correct numbers. Then, by using the "greater than" symbol, you can stipulate the price to be greater than e.g. $1.
The MetaStock code looks like this:
Mov(c,21,s) > 1
See? I told you it was easy.
Let`s move onto the next component... Liquidity. This is a measure of how much money a stock trades. It is important to identify stocks that have enough money moving through them so you`re never caught with a stock you can`t get out of.
For our example, let`s say we require...
The 21-day average of volume multiplied by the closing price to be greater than $200,000.
In MetaStock language this would be:
Mov(v,21,s)*C > 200000
Our next component is trend identification. Remember "the trend is your friend" and you always want to trade with it, not against it.
Think of it this way, if you were swimming in the sea, and got yourself caught in a rip, is it easier to swim with the current or against it? Similarly, do you think it is easier to trade with the trend or against it?
There are many ways to identify trends, and it`s not important which method you use, just that you have a method in place.
One of my preferred methods for identifying trending stocks is to find stocks trading at their current highs. One way to do this is stipulate that the highest high price must have been achieved in the last "x" number of days.
Once again, the variables you use will depend on the time frame you are trading. But for our example: We want the highest high price in the last 240 days to have occurred in the last 20 days.
Using the formula reference guide in the MetaStock Programming Study Guide, we know the syntax of the highest high function and therefore it is simply a matter of plugging in the details. Then, using the "less than" symbol, we can stipulate the number of days must be less than 20.
In MetaStock language that would be:
HHVBars(H,240) < 20
Last, we need a volatility measure. The aim of including this formula is to identify stocks that move enough for us to make a profit, yet they aren`t so erratic that they keep you awake at night.
There are a few ways to measure volatility. However, my favorite is the ATR method (covered in a previous edition of the MetaStock Formula Newsletter.) In basic terms, it indicates how much a stock will move, on average, over a certain period.
For example, a one-dollar stock might move five cents on average over the last 20 days. We can simply divide this value by the price of the stock and you will be given the average percentage movement of a stock. With these values, we can stipulate a minimum and maximum daily volatility value.
For example:
We may want the ATR divided by the average closing price, over the last 21 days, to be greater than 1.5%. In short, we are saying that the average minimum volatility must be greater than 1.5%.
Additionally we may want the ATR divided by the closing price, over the last 21 days, to be less than 6%. In short, we are saying that the average maximum volatility must be less than 6%.
In MetaStock language that would be:
ATR(21)/Mov(C,21,S)*100 > 1.5 and
ATR(21)/Mov(C,21,S)*100 < 6
Now let`s put all our code together to see what our entry system looks like:

C>1 and
Mov(v,21,s)*C > 200000 and
HHVBars(H,240) < 20 and
ATR(21)/Mov(C,21,S)*100 > 1.5 and
ATR(21)/Mov(C,21,S)*100 < 6
Congratulations!!
You have now been a part of creating a workable entry system. Not only did we construct a robust system... but this system also adheres to the KISS principal (Keep It Simple Simon.)
This system can now simply be cut and pasted into the Explorer within MetaStock... that said, please realize, the entry (what we have just designed) is the smallest component of a successful trading system.
In later parts of this series, you`ll find what it really takes to have a profitable trading system.
This concludes part two of our "How to Design a Trading System within MetaStock." It is extremely important you keep an eye out for next month`s issue since we`ll work through our exit conditions and code them into MetaStock.
 
U

uasish

Guest
#3
Simon,
After many months could see someone do things in Metastock easily,looking forward to your next post,i would still love it more if each variables are each being assigned one lines ,so that in future when necessary we can call each seperate functions by different fmls,embedded in one.
Asish
 
#4
Hi,

Thanks for a very good article on MS.

Would you be able to find out the source or how to access the other parts of this tutorial? There appear to be other parts to this tutorial on MS - thats why I am asking.

Thanks & Regards,
-feltra


Recd this by email. As I dont use metastock I cant answer any questions on it.


How to Design a Trading System Within MetaStock.
 
#7
Recd this by email. As I dont use metastock I cant answer any questions on it.


How to Design a Trading System Within MetaStock.

Let`s start right where we left off. We had just finished discussing the major components when designing any mechanical entry system. They included a measure of:
1. Price.
2. Liquidity.
3. Trend.
4. Volatility.
Now how do we code this into MetaStock?
Well let me offer the most valuable gem of knowledge I have learned over the years regarding MetaStock formula writing. This one secret, although very simple, will ultimately turn you into a MetaStock master...
Let me put it this way... Do you think I know all of MetaStock`s hundreds of preprogrammed formulas and propriety indicators? No, I`m good... but not that good ;-)
So what is my secret?
Well, when coding in MetaStock, the key to getting it "right" is to write "down in English" what it is you are trying to achieve. Once done, it is quite easy to convert this into MetaStock formula.
Let`s see what I mean by looking at an example. Our first entry condition is a measure of price. As mentioned in the last issue, the aim of setting price minimums is to remove speculative stocks.
Please note: the values you select will depend on the exchange you are trading (some markets tend to be more expensive than others.) However, for this example, we are looking to design a long-term trend following system to trade on the Australian Stock Exchange.
In Australia, anything under $1 could be classed as speculative. So how do you stipulate those stocks must be greater than $1? Now here comes the "write it in English first" part:
We want stocks with a 21-day average of closing price to be greater than $1.
Next, we must convert this into MetaStock formula.
Using the formula reference guide in the MetaStock Programming Study Guide, you can check the syntax of a moving average. With this information, it`s simply a matter of plugging in the correct numbers. Then, by using the "greater than" symbol, you can stipulate the price to be greater than e.g. $1.
The MetaStock code looks like this:
Mov(c,21,s) > 1
See? I told you it was easy.
Let`s move onto the next component... Liquidity. This is a measure of how much money a stock trades. It is important to identify stocks that have enough money moving through them so you`re never caught with a stock you can`t get out of.
For our example, let`s say we require...
The 21-day average of volume multiplied by the closing price to be greater than $200,000.
In MetaStock language this would be:
Mov(v,21,s)*C > 200000
Our next component is trend identification. Remember "the trend is your friend" and you always want to trade with it, not against it.
Think of it this way, if you were swimming in the sea, and got yourself caught in a rip, is it easier to swim with the current or against it? Similarly, do you think it is easier to trade with the trend or against it?
There are many ways to identify trends, and it`s not important which method you use, just that you have a method in place.
One of my preferred methods for identifying trending stocks is to find stocks trading at their current highs. One way to do this is stipulate that the highest high price must have been achieved in the last "x" number of days.
Once again, the variables you use will depend on the time frame you are trading. But for our example: We want the highest high price in the last 240 days to have occurred in the last 20 days.
Using the formula reference guide in the MetaStock Programming Study Guide, we know the syntax of the highest high function and therefore it is simply a matter of plugging in the details. Then, using the "less than" symbol, we can stipulate the number of days must be less than 20.
In MetaStock language that would be:
HHVBars(H,240) < 20
Last, we need a volatility measure. The aim of including this formula is to identify stocks that move enough for us to make a profit, yet they aren`t so erratic that they keep you awake at night.
There are a few ways to measure volatility. However, my favorite is the ATR method (covered in a previous edition of the MetaStock Formula Newsletter.) In basic terms, it indicates how much a stock will move, on average, over a certain period.
For example, a one-dollar stock might move five cents on average over the last 20 days. We can simply divide this value by the price of the stock and you will be given the average percentage movement of a stock. With these values, we can stipulate a minimum and maximum daily volatility value.
For example:
We may want the ATR divided by the average closing price, over the last 21 days, to be greater than 1.5%. In short, we are saying that the average minimum volatility must be greater than 1.5%.
Additionally we may want the ATR divided by the closing price, over the last 21 days, to be less than 6%. In short, we are saying that the average maximum volatility must be less than 6%.
In MetaStock language that would be:
ATR(21)/Mov(C,21,S)*100 > 1.5 and
ATR(21)/Mov(C,21,S)*100 < 6
Now let`s put all our code together to see what our entry system looks like:

C>1 and
Mov(v,21,s)*C > 200000 and
HHVBars(H,240) < 20 and
ATR(21)/Mov(C,21,S)*100 > 1.5 and
ATR(21)/Mov(C,21,S)*100 < 6
Congratulations!!
You have now been a part of creating a workable entry system. Not only did we construct a robust system... but this system also adheres to the KISS principal (Keep It Simple Simon.)
This system can now simply be cut and pasted into the Explorer within MetaStock... that said, please realize, the entry (what we have just designed) is the smallest component of a successful trading system.
In later parts of this series, you`ll find what it really takes to have a profitable trading system.
This concludes part two of our "How to Design a Trading System within MetaStock." It is extremely important you keep an eye out for next month`s issue since we`ll work through our exit conditions and code them into MetaStock.

ur explanation as great about ATR so i just looking for good expert advisor for metastock software . if u have knowleadge about this plz inform me xxxxxxxxxx
 
Last edited by a moderator:

Similar threads