Australian (ASX) Stock Market Forum

Metastock Formulas - Trend Intensity Index & Flatliner

Joined
21 February 2009
Posts
21
Reactions
0
Hi all,

Anyone had much use for the Trend Intensity Index in OmniTrader at all?

Seems to be giving some fairly good results in picking trends and thought I'd put it up here for people that are interesting in using it as part of a formula in Metastock as part of an Expert or just as a general trend indicator.

This is Metastock format. Just drop it in as a new Indicator and voila!

Trend Intensity Index

x:=Input("number of periods", 5,100,14);
ma:=Mov(C,2*x,S);
sdp:=Sum(If(C-ma>0, C-ma,0),x);
sdm:=Sum(If(ma-C>0, ma-C,0),x);
Mov((sdp/(sdp + sdm)),7,TRI) * 100


Another one I've been working on lately is what I call "The Flatliner". It helps in weeding out any stocks that have no real trading activity for certain periods, i.e. lots of flat lines.

Flatliner

chartdays:= (Cum(C/C));
check:= (O=C AND H=C AND L=C);
flatliner:= Cum(check);
result:= chartdays - flatliner;
percentage:= (flatliner / chartdays)*(100/1);
percentage


Anyway, using this in an Explorer type situation it can give you a percentage of how many flat-spots each chart has and helps weed out those stocks that aren't really trading. Working on putting some type of weighting system into it at the moment as current prices are more important than ancient history.

Anyway, let me know if these formulas help. Been working on a lot of my own formulas over the past eight years so can probably offer some suggestions to anyone that needs help with creating formulas in Metastock or just maths theory/login.

I have another formula that is VERY GOOD and pretty much picks the peaks and troughs of any trending stock but it's still in development; yes I know, I've heard it can't be done and also that anyone that tells you they can do it is a liar but all I have to say to that is "just because it's not easy to do or hasn't been done before doesn't mean it CAN'T BE DONE!"

Anyway, I hope these formulas help and have a good one!


Christian
 
Christian

Your trend indicator--what are the rules for application?
 

Attachments

  • Trend.jpg
    Trend.jpg
    53.4 KB · Views: 43
I've decided to rewrite the last post and the moderators have set the board to 20 minutes. Anyway, here is a bit better explanation. (Can I have the previous post deleted please? :))

Hi,

The main application of the Trend Intensity Index is as a trend confirmation type signal to be used in conjunction with a Stochastic Oscillator or MACD. Probably best for swing trading.

E.g. How to read it is as follows: When it starts to rise from the 0 line the price of a stock tends to increase and when the indicator reaches its peak and starts to decline the price will usually begin a decline. You might have to adjust the periods it's using though to generate the correct rise and fall.

If you correlate it to a MACD and Stochastic it's quite good for use in an Expert in Metastock also. This will help minimize stray signals that Stochastics sometimes generate when using them to generate buy and sell signals.

Adjusting the formula by smoothing it through use of a Triangular Moving Average can often help smooth and produce even more reliable signals.

It's also quite good for use in the Trends section of an Expert to show the long term trends of the market and discovering whether the stock is in a bullish or bearish phase. You'd have to change it from a 14 day view though to a longer term one to generate this.

Anyway, hope this helps explain a little better the methodology behind its use.


Regards,


Christian
 
Hi all,

I thought in follow-up to what I'd already written I'd put up a chart so you can see a visual example instead of just a text description of how the Trend Intensity Index works.

Anyway, hope it assists in seeing how to apply it to making stock decisions.

I've highlighted the points of interest in blue circles so you can see where the price action correlates to the indicator readings. Really a very simple method of trading a nice volatile stock.

Enjoy!

Christian
 

Attachments

  • Trend_intensity_example.jpg
    Trend_intensity_example.jpg
    109.9 KB · Views: 41
Flatliner
chartdays:= (Cum(C/C));
check:= (O=C AND H=C AND L=C);
flatliner:= Cum(check);
result:= chartdays - flatliner;
percentage:= (flatliner / chartdays)*(100/1);
percentage

Hi Christian,

Going through this code line by line, there are some savings to be made:

chartdays:= (Cum(C/C));
is just a bar counter and is the same as:
chartdays:= Cum(1);


check:= (O=C AND H=C AND L=C);
this implies H=L and if the H=L then open and close prices must also be the same (unless you have shonky data) so we can save some more processing by using:
check:= H=L;


flatliner:= Cum(check);
no problems here.


result:= chartdays - flatliner;
isn't addressed so can be removed from the code.


percentage:= (flatliner / chartdays)*(100/1);
the 1 divisor is redundant, but I can see the way you think.



So my take on the code would be:

chartdays:= Cum(1);
check:= H=L;
flatliner:= Cum(check);
percentage:= 100 * flatliner / chartdays;
{plot/return}
percentage;


You might also consider that looking back through the entire history on the chart might not be that relevant to the latest price action, so you could use a lookback setting to view the percentage of "flatbars" in a given period, something like:


{requires the free forum.dll for the adaptive sum function}
lookback:=255; {bars}
lookback:=If(Cum(1)<lookback,Cum(1),lookback);
check:= H=L;
flatliner:= ExtFml("forum.Sum",check,lookback);
percentage:= 100 * flatliner / lookback;
{plot/return}
percentage;



Hope this gives some more ideas?

wabbit :D
 
Hey Traderc,

I find a very straight forward and effective filter for flat days (where the low equals the high) is as follows:

Periods:=X;
MaxFlatties:=Y;
(Ref(Sum((H=L),Periods),-1)<=MaxFlatties)

This counts the number of days where L=H over the last X periods. Funnily enough, I called this a "flatties counter" as opposed to flatliner. Set your periods (X) and maximum number of flat days (Y) and away you go.

I don't think it's necessary to get complicated with this kind of formula, the above does the trick for me.

Cheers,

AMSH.
 
Hey Traderc,

I find a very straight forward and effective filter for flat days (where the low equals the high) is as follows:

Periods:=X;
MaxFlatties:=Y;
(Ref(Sum((H=L),Periods),-1)<=MaxFlatties)

This counts the number of days where L=H over the last X periods. Funnily enough, I called this a "flatties counter" as opposed to flatliner. Set your periods (X) and maximum number of flat days (Y) and away you go.

I don't think it's necessary to get complicated with this kind of formula, the above does the trick for me.

Cheers,

AMSH.


Hi AMSH,

In regards to the formula I created, the reason I made it like that is that it creates a "percentage" view of it rather than requiring a constant. I much prefer formulas I never have to adjust again. Since I use this as a base formula I can just give it a percentage I want to to cull from and that's it.

The problem with constants is you're limiting the field of it though I do understand it can also have the benefit of being able to review only a specific field/timeline. You can never know the specific data set you're going to have. e.g. a share might only have 20 bars and you're telling it to search 200 bars. Giving it a percentage will always work whereas a static number that is outside the range won't work.

I find that to make formulas fit a little better percentages are the way to go since they can be applied to any stock and be automated as opposed to having to set static numbers which means you'd have to change the formula to fit specific data sets (in general).

Anyway, it's always a "if it works for you" type scenario in the stock market and as long as the formula achieves the objectives you're trying to reach and the desired outcome then you're home and hosed.

Just my 2c on static vs. percentage in formulas.


Christian
 
Hi wabbit,

Thanks for showing me that. It achieves the same as what I was doing with less lines of code. Thanks for streamlining it.

My formula still arrived at the place, just a little slower! ;)

Anyway, I'm working on some Explorers at the moment to cull the list of stocks based on "flatlines", volume surge, stochastic, MACD and Trendline Index so I think I've almost got a formula that finds very nicely set up trade points.

Think it's almost ready to give it a burl.

I'm just starting to work on collecting a new portfolio at the moment so am narrowing down candidates that are still strong underlying companies but have virtually collapsed. i.e. companies that were above $1 and have dropped tremendously; will see which ones pick themselves up again.

The general consensus seems to be "stay out of the markets" at the moment when speaking to people but I think they watch the news too much or have lost money and realistically, shares are now at "wholesale prices" and buying them up now especially when the bulls and bears are seemingly agreeing on price leads seems to be a good idea.

I think we may have hit the bottom of the market (or somewhere close anyway) and are back into a consolidation/accumulation period.

At least the bulls and bears agreeing on the price at the moment leads me to think there will be a reversal of sorts.

Anyway, thanks for your help with streamlining the formula and look forward to speaking with you again soon.

Regards,


Christian




Hi Christian,

Going through this code line by line, there are some savings to be made:

chartdays:= (Cum(C/C));
is just a bar counter and is the same as:
chartdays:= Cum(1);


check:= (O=C AND H=C AND L=C);
this implies H=L and if the H=L then open and close prices must also be the same (unless you have shonky data) so we can save some more processing by using:
check:= H=L;


flatliner:= Cum(check);
no problems here.


result:= chartdays - flatliner;
isn't addressed so can be removed from the code.


percentage:= (flatliner / chartdays)*(100/1);
the 1 divisor is redundant, but I can see the way you think.



So my take on the code would be:

chartdays:= Cum(1);
check:= H=L;
flatliner:= Cum(check);
percentage:= 100 * flatliner / chartdays;
{plot/return}
percentage;


You might also consider that looking back through the entire history on the chart might not be that relevant to the latest price action, so you could use a lookback setting to view the percentage of "flatbars" in a given period, something like:


{requires the free forum.dll for the adaptive sum function}
lookback:=255; {bars}
lookback:=If(Cum(1)<lookback,Cum(1),lookback);
check:= H=L;
flatliner:= ExtFml("forum.Sum",check,lookback);
percentage:= 100 * flatliner / lookback;
{plot/return}
percentage;



Hope this gives some more ideas?

wabbit :D
 
The general consensus seems to be "stay out of the markets" at the moment when speaking to people but I think they watch the news too much or have lost money and realistically, shares are now at "wholesale prices" and buying them up now especially when the bulls and bears are seemingly agreeing on price leads seems to be a good idea.

I think we may have hit the bottom of the market (or somewhere close anyway) and are back into a consolidation/accumulation period.

At least the bulls and bears agreeing on the price at the moment leads me to think there will be a reversal of sorts.


IMHO... (not to be taken as financial advice of any sort)

In history, lots of things have been written that many traders agree with and use as part of their gospel (some ignore this completely):

"Trade with the trend"

"The trend is your friend"

"Follow the smart money"

"Follow the leaders"

"A room full of contrarians is a crowd"


I still think there is a bit/lot more to go in the downside, the trend is down and the popular "opinion" is to avoid the markets, nothing bullish in these sentiments. I don't listen to market commentators and don't watch Bloomberg or CNBC, so have no idea what they are reporting (read Nassim Taleb's books; for the most part, I agree with his views on the media). The only people I have seen trying to encourage traders back into the markets are the spruikers offering trading-courses and systems, and companies trying to raise capital to pay off their massive, uncontrolled debt and CEO salaries.

In my charts/data/crystal ball, I see nothing indicating the imminent reversal of the equities markets, so personally, I am staying well out of it and have my funds liquid and ready for when the market does eventually (really) turn. The recent news such as Pacific Brands, GM, Fanny Mae, Bank of Scotland etc don't give me any indication that global good times are just around the corner. In the mean time, I look towards some of the other markets such as FX, futures and have been occasionally playing (again) with a few options/warrants for some short term plays, for opportunities whilst equities are still in a state of turmoil, although these other markets are also in various states of volatility and turmoil but I believe, to a lesser extent.

I believe money in the stock markets now is money exposed to greater risk than it needs to be; I don't NEED to trade, so at the moment, I am not. Another personal belief is that too many needy traders are looking for ANY opportunity to enter the market, when smart traders look for the RIGHT opportunities to enter the market during which times they are happy to be standing on the sidelines.

You might think prices are bargains now, imagine how much more of a bargain they will be when they drop another 10/20/50/100% "Beware trying to catch the falling knife" is sagely advice once given to me, and, "Even when a dead cat bounces, it's still dead."

$0.02


wabbit :D
 
These patterns can also be advantageous for breaks to the downside too Wabbit.
 
I do agree with what you're saying and far from any stretch of the imagination do I believe that "financial good times are just around the corner". That would be foolish of anyone to think.

I simply think the fall itself is slowing a bit in that the Indexes aren't really trading at that much of a range now. Opening and closing prices for them have pretty much been in line with each other which usually means that when there is an agreement on price from the bulls and bears there tends to be a reversal standing in the wings waiting to jump out.

Even though there IS upset with a lot of the companies at the moment this is really just doomsaying and people being people and trying to find someone to blame for what is going wrong. Happens in every crisis; first rule of leadership and all that. The upper echelons get crucified and are held accountable for "what went wrong" even though it's happening world-wide and there's very little they could do except grin and "bear it" (scuse the pun).

Personally, I think that people just got too greedy and it's a case of they thought it would never come down. Has happened in every stock market crash since there was stock markets. People go into shock and think "what the hell happened. It all seemed so easy at the time" but it's kind of like the story of Icarus really, isn't it? If you are cautious it can be fun and very lucrative but if you look at the overall trends of the market, you could see that the market on the long cycle was about ready for a plunge. Whoever decided to keep their shares instead of at least taking some profit (at least getting their initial investment capital out) or having a trailing stop in place were idiots, sorry to say it. Anyone that trades without trailing stops is a fool in my opinion unless their system has something similar that will project a turn in the market.

Too bad more people don't use technical analysis or view long term market dynamics. Always after short-term profits as opposed to standing back a bit to "view the entire canvas".

...and yes, having been a chef for most of my life, I certainly understand falling knives. ;) I was missing the end of my third finger until it was sown on again, so I can appreciate more than most what you're saying about the quality of the edge of a knife... and no, I didn't catch a knife. I slipped while cutting something in the kitchen. :eek:

Anyway, seems most people can't appreciate that "what goes up, must come down" or think that by throwing a brick up in the air isn't going to result in it landing again. :banghead:

Will charge 10c for those pearls! :) Where's my bunny paw gotten to? :)

*goes off to search for his rabbits paw*
Regards,



Christian
 
Hey TC,

You're totally right mate, I just thought that perhaps a flat day indicator doesn't warrant anything other than a static-period based filter like the one i described - I suppose that it could be due to the my approach but I haven't found this type of filter to be very effective (especially trading the larger caps) and a 25 period check seems to work as well as a more complex formula.

I'm not sure if I agree with your assertion that what's happening now is (largely) doomsaying though. There's a lot of objective data out there that says we're in for a rough time (Japan's negative 12% and the US's negative 6% growth to name just a few - and these are recently released). There might be a lot of doom and gloom style reporting going on, but the economic figures are both objective and pretty scary.

I can't remember who said it but the idea that one of the private trader's biggest advantages is the ability to steer clear of the market when it's not in their favour seems to me to be pretty good advice.
 
Hey TC,

You're totally right mate, I just thought that perhaps a flat day indicator doesn't warrant anything other than a static-period based filter like the one i described - I suppose that it could be due to the my approach but I haven't found this type of filter to be very effective (especially trading the larger caps) and a 25 period check seems to work as well as a more complex formula.

I'm not sure if I agree with your assertion that what's happening now is (largely) doomsaying though. There's a lot of objective data out there that says we're in for a rough time (Japan's negative 12% and the US's negative 6% growth to name just a few - and these are recently released). There might be a lot of doom and gloom style reporting going on, but the economic figures are both objective and pretty scary.

I can't remember who said it but the idea that one of the private trader's biggest advantages is the ability to steer clear of the market when it's not in their favour seems to me to be pretty good advice.

I'm not saying we're out of the woods yet by any stretch. I just think the market will rebound in the short-term. Don't know by how much but realistically if it drops too much more, half of the global economies are going to go with it permanently.

We'll be putting ourselves back by 15 years in terms of growth.

I know the economy is declining a bit and I'm not silly enough to think that there's not more to come yet in terms of corporate collapse and job losses etc. but I think a lot of what is going on is being timed specifically, whether intentionally or not, like announcements etc. in the media to say "yeah, look how bad it is" and too many people staying out of the markets isn't a good thing.

Look, I'm not a complete optimist here either but I also don't think it's quite as bad as the picture these doomsayers are painting and if people had some balls and stayed in the markets, this wouldn't have happened, at least not to the extent that it has already.

Hate to say it but people are like sheep in that they follow, so if people showed some backbone and thought, "we're not going to let this happen to our country and all joined together for one big "heave-ho" and started buying up shares again, things would be alright and the markets won't plunge into the bottomless pit of the dreaded "depression".

I think the old Aussie spirit needs to show through here and people need to start buying up shares again. Firstly we might just get our dollar back to 1/1 with the USD and begin to own our integral services and private sector again instead of it being owned by the rest of the world. In the 70's the AUD was more than the USD ($1.17 or so if memory serves me correctly) so it's definitely possible for us to do that again, especially with the state of the US economy at the moment.

GO AUSSIE!

Regards,



Christian
 
A quote to haunt you by! :)~

In the 70's the AUD was more than the USD ($1.17 or so if memory serves me correctly) so it's definitely possible for us to do that again, especially with the state of the US economy at the moment.

GO AUSSIE!

Oh by the way when I also said during this same conversation that the market was making a recovery, around this same time I created a phantom portfolio with $8,500 distributed over $500 lots on stocks that originally had a value of more than $5.00 one trading year prior to when I wrote this on the belief that the stocks had simply been oversold and effectively driven into the ground though would recover.

Anyway, I'd just like to say that my theory was correct and the portfolio is now worth over $65,000 in just over one year with only 6 or 7 losers out of the lot (and they're minimal losses, $70-80 and the like).

Anyway, just thought I'd give you an update on my progress with testing the markets. A 664% profit (after taking out the initial trading capital).

This method of investing definitely works so don't miss the opportunity to start buying up cheap shares that people discarded simply due to price when in fact the underlying fundamentals of the company are still sound with the majority of them still retaining all of the assets that originally made them the blue-chips of yesteryear!

My method works out to be a blend of technical analysis which is used to search for fundamental and sound, logical reasoning.

Anyway, have fun with the stock market and I really don't think its going to be long now before we see the next boom begin in the stock market as it has been trading sideways for quite a while now; its gotta breakout one way or another (hopefully to the upside though).

Regards,




Christian
 
Hi all,

I thought in follow-up to what I'd already written I'd put up a chart so you can see a visual example instead of just a text description of how the Trend Intensity Index works.

Anyway, hope it assists in seeing how to apply it to making stock decisions.

I've highlighted the points of interest in blue circles so you can see where the price action correlates to the indicator readings. Really a very simple method of trading a nice volatile stock.

Enjoy!

Christian
Hi Christian

I just saw your Trend Intensity index formula.

How do you get this chart that you attached, with the blue circles so that I can see price action correlates to the indicator readings?

I still don't know how to write formulas. Still learning how to through readings. Right now I just cut and paste to see how it works.

Regarding the Flatliner, is it another formula or for Explorer use only. Flatliner , do i put it onto the chart or is it another indicator?

You also mentioned you have another formula which is very good and pretty much picks the peaks and troughs of any trending stock, do you have it and can you please share with me.

I would appreciate your reply.

Thanks.

Princess
 


Write your reply...
Top