Art

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 34

Playing with the Bands (2) From Squeeze

to Momentum Burst
Posted by Han-Sheng Peng
8/29/12 5:47 PM
Blog 6: Playing with the Bands (2) From Squeeze to Momentum Burst
The interesting thing about designing a trading algorithm is that you can collect the existing ideas,
put them together, and add a bit of your flavor to create your own trading style. Lets give it a try.
Last week we learned about the Bollinger Bands (you can find the article here). Today we will
introduce a squeeze system, in which we add 5 different components along with Bollinger Bands.
These components are Exponential Moving Average (EMA), Momentum Index, Average True Range
(ATR), Keltner Channel, and Market Indicator. This system is designed to identify stocks with great
momentum that are ready to burst. Once these stocks start to move, we can capture the huge run on
them. Before we delve into the trading strategy, lets walk through a quick introduction of the five
indicators:
Exponential Moving Average (EMA):
As we mentioned in the previous article, the simple moving average can show the current trend
direction but with a lag. Exponential Moving Averages will reduce the lag by applying more weight to
recent prices. The weighting applied to the most recent price depends on the number of periods in
the moving average as seen in the following formula,

where the "Time Period" denotes the periods of exponential moving average you want to use, and "t"
denotes the current time.

Momentum Index:
The Momentum indicator is a speed of movement indicator, which is designed to identify the strength
of a price movement. Usually, the momentum indicator compares the most recent closing price to a
previous closing price. The formula is as below:

where "n" is a specific length of the previous closing prices. The momentum indicator identifies when
and by how much the price is moving upwards, or downwards, with the indicator above 0 moving
upwards and below 0 being downward.

Average True Range (ATR):


This indicator is developed by J. Welles Wilder to measure the volatility. One common way to
measure volatility is to calculate the standard deviation by just using previous close prices. It would
fail to capture volatility form the gap or limit moves of stock price. To capture the missing volatility,
the ATR indicator uses three different ranges of the stock price to capture that missing volatility. Lets
go through the steps and calculate the ATR.
1. Calculate the True Range (TR) by taking the greatest value from the following calculation.

A gap occurs when the previous close is


greater than the current high, which signals a potential gap down or limit move, or the previous close
is lower than the current low, which signals a potential gap up or limit move.
2. Calculate the n-period Average True Range (ATR) :

Keltner Channel:

If you are already familiar with Bollinger Bands, this indicator will be quite easy for you. Keltner
Channels are volatility-based envelopes. Different from general Bollinger Bands, Keltner Channels
use exponential moving average as its mean(central line) and use the Average True Range (ATR) to
set the channel distance. The channels (the upper band and the lower band) usually are set two ATR
values above and below its mean. You also can use this indicator to play the revert-to-the-mean
strategy. Now you may wonder what are the differences between Bollinger Bands and Keltner
Channels? First, as we stated above, the mean in Bollinger Bands is using simple moving average,
while the mean in Keltner Channels is using exponential moving average. This would make the
Keltner Channels more sensitive to the recent price movement. Second, the Keltner Channel is
smoother than the Bollinger Bands. Why is that? Now we all know that the width of Bollinger Bands
is decided by the standard deviation, which is calculated based on the closing prices. Since the
closing prices are more volatile than the trading ranges, it makes the Bollinger Bands tend to expand
and contract faster than the outer bands of Keltner Channels. This characteristic is pretty important,
and will be the core of our following strategy.

Market Indicator:
The market indicator is chosen to gauge how the overall market goes. You hope these indicators can
give you a sense about the market sentiment, like the current market is in an uptrend, consolidation,
or downtrend. Why is it important? If you have a long-only strategy, will you put all your money in
when there is a big selloff in the market? Absolutely NOT! It doesnt mean that you cant buy stocks
in a weak market; in fact, many people will see it as a good opportunity to build positions. However, it
does give you a heads-up so that you wont blindly throw out a trade. So where can we find these
indicators? Its pretty easy. For example, VIX is a well-known fear index provided by CBOE, so you
can use it to gauge the market environment. When the market is in its selloff mode, the VIX usually
rallies. When the market rallies, the VIX usually dips hard. It tends to run the opposite way of where
the market goes. Thus, it can be a good market indicator to include in your trading algorithm. The
other indicators can be market indexes, index ETFs, or sector ETFs. The idea is that you want to find
one that is highly correlated with the stocks you are trading with. Lets look at a short example. If you
trade many stocks in the S&P 500 index, you can use SPY, in which case the ETF closely tracks the
SPX performance as a market indicator.

Strategy:
Now lets start building our strategy using all these fun indicators. First, we need to grasp the key
concept behind this strategy. As we mentioned above, usually the outer bands of Bollinger Bands

would be outside the outer bands of Keltner Channels. So the question becomes, is it possible to
see both the upper and lower Bollinger Bands come inside the Keltner Channels? When will it
occur? And what does it mean? The answer is YES. It usually occurs when the market is under the
low volatility period. This quiet transition period is called squeeze and can be seen as the time when
the stock or market is accumulating momentum and waiting for reaction. Once the period ends and
the Bollinger Bands start to come out of the Keltner Channels, the momentum starts to release and a
big move is coming. We just dont know which way - either upside or downside - will it move. To
figure out how which side the stock will go, here is the Exponential Moving Average and the
Momentum Indicator come into play. Lets take a look at the strategy:
Buy the stock when the following criteria are all met:
1. The outer bands of Bollinger Bands come out from the Keltner Channels (Squeeze is
finished)
2. The 8-period EMA is greater than the 21-period EMA, and the 21-period EMA is greater than
the 55-period EMA
3. The Momentum index is greater than zero
4. The specific index ETF is above its 34-period EMA (We use it as the market indicator)
5. The current volume is greater than its 10-period Moving Average
Close the stock positions when either one of the following criteria is met:
1. Use the entry price minus 1.5 ATR as our original stop
2. Target 1: the entry price + 1.5 ATR. Once we hit the target, close half of positions and bring
up the original stop to break even
3. Target 2: Close the rest positions when the 8-period EMA cross to the opposite side of the
21-period EMA
Once the squeeze period ends and the stock is ready to move, we use 4 more steps to decide which
direction we should go. (1) First we will have to see whether the 8-period EMA is greater than the 21period EMA, and whether the 21-period EMA is greater than the 55-period EMA. These two
measures tell us whether if the stock is relatively stronger or weaker in short-term than mediumterm. (2) Second, the Momentum Index needs to be greater than zero, which further confirms that
the stock has an upward momentum. (3) Third, we have to consider whether the market indicator is

relatively strong in the medium time-frame so that the market wont hurt our position badly. (4)
Finally, the current volume of stock needs to be at least greater than its 10-period MA. It indicates
that the recent volume is increasing to support the momentum. You may change this one to more
strict condition, like the current volume should be greater than 250,000 contracts. In terms of closing
existing positions, we inclined to use one systematic exit methodology to reduce our downside risk
and simultaneously give us a room to profit from the upside. First, when we open positions, we have
the hard stop in place, which is the entry price minus 1.5 ATR, to cut our loss short if the stock
doesn't perform well. Second, we use the entry price plus 1.5 ATR as our first profit-taking target.
Once we hit this target, we close half of our positions and move our original hard stop to break even.
In this way, we book some profit and take some risk off the table, but we still have our remaining
positions exposure to the upside. Lastly, remaining positions will be closed either when the 8-period
EMA cross to the opposite side of the 21-period EMA or be stopped out by our stop. By doing so, we
can catch a runner if the stock keep performing strong. Even if our positions be stopped out, it would
be stopped at our breakeven price, and remember we already take some profit in our pocket.

We use LNKD as an example. From the chart above, we observe that (1) we got a squeeze signal at
1/12/2011. (2) The volume met our criterion. Those two steps indicate a good potential setup for us.

(3) We saw the 8-EMA cross over the 21-EMA. (4) Momentum index was above zero, which
indicated an upward momentum. (5) QQQ (The Market index we chose for our stocks) was above its
34-EMA line, which also signaled the market was relatively strong in the medium-term time-frame All
the criteria were met, so we bought the stock at this point. Then we waited for the crossover of 8EMA and 21-EMA in the opposite side. We had an amazing run-up and held our position for about 4
months until 5/21/2012, and eventually we booked around 50% profit per contract. Now lets
backtest this strategy with stocks listed in NASDAQ.
Result

Table. Backtesting result on all stocks listed in the NASDAQ (1/2/2001 ~ 6/11/2012). Here we use 100K portfolio and put 1% capital
($1000) per trade, and assume the 10bp for one-way transaction fee of our trade capital.

Though we can see that the winning ratio of this strategy is not high, we still make a decent profit
from this system. Comparing our equity curve with the simple buy and hold strategy for QQQ, we
can find that our performance totally beats this benchmark. We generated a great uptrend in our
equity curve even though the market was up and down drastically. We did get hit a bit around the
years of 2008 and 2009. However, given our strategy is a long-only strategy, our loss was contained
during one of the worst periods in the financial history. You may question why the result can be so
great while we only get around 50% winning ratio? Notice that every system has different
characteristics. Lets take two totally different types of strategies, revert to the mean strategy and
momentum strategy, as an example. When you trade a mean-reverting strategy, you will expect that
theres a high probability the stock price will go back to its mean. This way, you can design your

strategy to profit from that characteristic. Usually you can get a high winning ratio in this kind of
system. In contrast, the momentum strategy has a totally different nature. The goal in this kind of
system is Let the winner run and cut the losers short. We can be comfortable to experience several
small losers in a row. But as long as we catch a runner, we can have a huge profit to fairly offset the
previous loss and meanwhile retain a good profit. The system we are introducing today belongs in
this category. Thus, we shouldn't worry too much about the relatively lower winning ratio. Instead, we
can focus on how much we can earn if we are right. Take a look at the average profit per winning
trade versus the average loss per losing trade, we get almost 2 times more when the trade works in
our side.
As we have mentioned in some of our previous posts, we should have different trading strategies in
our trading portfolio to help us profit from different market environments. Now, you have one more.
Hopefully, you enjoyed this one a lot and allow your imagination to dive into the world of algorithmic
trading.

10

Trade Trend Following Strategy by using


MACD and Stochastic Oscillator
Posted by Han-Sheng Peng
9/21/12 11:27 AM
The trend following strategy is a powerful strategy that many people like when trading. Basically, the
concept of this kind of strategy is to find the bullish stocks that have continuously rising prices. To
identify these bullish stocks, you can simply use the faster moving average crosses over to a slower
moving average, that creates a market momentum and suggests further price increases. In this post,
we are going to combine two indicators, MACD and Stochastic Oscillator, to help us build a trend
following system and generate the buying signal for stocks. Lets take a quick look at those two
indicators first.
Moving Average Convergence-Divergence (MACD):
The MACD brings together momentum and trend into one indicator by subtracting the longer-term
moving average from the shorter-term moving average. Since it is all about the convergence and
divergence of two moving averages, the value usually oscillates above and below the zero line (or
called the central line). The general setting of MACD is as below,

The positive MACD means the 12-period EMA is above the 26-period EMA. As the positive values
increase, it indicates that the shorter-term EMA diverges further from the longer-term EMA and the
upside momentum is increasing. In contrast, when we get the negative MACD and the value is
decreasing, it tells us that the shorter-term EMA is below the longer-term EMA and the downside
momentum is increasing. In terms of the signal line, it is the moving average of the MACD indicator.
A bullish crossover occurs when the MACD turns up and crosses above the signal line. A bearish
crossover occurs when the MACD turns down and crosses below the signal line. And the difference
between these two values is shown by MACD Histogram.

11

Stochastic Oscillator:
The Stochastic Oscillator is a momentum indicator that shows the location of the close price relative
to the high-low range over a set number of periods.

Since the Stochastic Oscillator is a bounded oscillator from 0 to 100, it can be easily used to identify
the stock when it is in overbought or oversold levels. The Stochastic Oscillator is above 50 when the
close is in the upper half of the (HH-LL) range and below 50 when the close is in the lower half. Low
readings (below 20) indicate that price is near its low for the given time period. High readings (above
80) indicate that price is near its high for the given time period.

Now with these two handy indicators, lets look deeper into our strategy.
Strategy:
Buy to open stocks when all the following criteria are met,
1. The stock is greater than its 200-day Moving Average
2. The MACD value is greater than 0
3. The MACD Histogram is greater than zero
4. The Stochastic Oscillator is less than 50 and this reading is also heading higher
Sell to close positions when one of the following criteria is met,
1. Use the entry price minus 1.5 ATR as our original stop
2. Target 1: the entry price + 1.5 ATR. Once we hit the target, close half of positions and bring
up the original stop to break even

12

3. Target 2: Close the rest positions when the MACD value is less than zero
The rules of this strategy are simple. First, we find the stocks that are above its 200-day Moving
Average (MA); it indicates that the stocks are relatively strong in the long-term time-frame The
second and third criteria are to ensure that the stocks have great momentum to the upside. Lastly,
the Stochastic Oscillator needs to be less than 50 to make sure that the stock hasn't been extremely
overbought and give the stock a room to run higher. Combining these four criteria, we can find
stocks with a high momentum that inclines to move up. In terms of how we close our existing
positions, we used the same exit strategy as we mentioned in this post. First, in order to cut our loss
short if we are wrong, we have the hard stop in place once we open positions. Second, we use the
entry price plus 1.5 ATR as our first profit-taking target. Once we hit this target, we close the half our
positions and move our original hard stop to breakeven point. Last, the rest positions will be closed
either when the MACD value is less than zero or be stopped out by our stop. This exit strategy is
around the key concept that to reduce our downside risk but simultaneously still having some
exposure to see we can catch a runner to the upside.

As you can see from the above graph, we had a buy signal on MasterCard (MA) at 8/2/2006, and we
peeled half of the positions off at point (1) when the first target was hit, and close the rest at point (2)
when the MACD crossed below zero. From this simple system, we can take part in the trend and
keep on riding the momentum to the upside. Now lets testing this system through the stocks listed
on NASDAQ.

13

Result

Table. Backtesting result on all stocks listed in the NASDAQ (1/2/2001 ~ 6/11/2012). Here we use 100K portfolio and put 1% capital
($1000) per trade, and assume the 10bp for one-way transaction fee of our trade capital.

A Trend following system with good risk management can be very helpful to growing your wealth. In
this post, we use the specific exit strategy as our risk management rule. You also can try some
alternatives. For example, you can use other key moving averages as your stop. Once the price fall
below its support level, you close out your entire positions. It will be fun to try to tweak the system a
bit and find the one that best works for you. Our ultimate goal is to cut losses short and let profits
run.

14

Can Divergence Predict Market Reversals?


Today I am going to discuss what divergence is and how it works. Divergence
can be applied to any market you trade Stocks, ETFs, Options, Forex and
Futures.
Divergence is sometimes referred to as a leading indicator because it can
identify a potential change in momentum, even before that change appears
in the price action. Divergence sets up when both the price action and the
stochastics indicator diverges or move in opposite directions. When this
happens and divergence is present, a potential change in direction may
occur.
Now lets discuss how to identify divergence on a chart. When a new high or
low in a security occurs but is not followed by the stochastic indicator, it
indicates a potential trend reversal. For example, just in the last several
weeks, we have seen bearish divergence in the S&P 500 Index. Bearish
divergence occurs when the price made a higher high, but the stochastic
indicator made a new lower high. This is bearish divergence and shows that
the upside momentum is slowing, even though prices are continuing to make
new highs, and a trend reversal lower is very likely. There is both bearish and
bullish divergence, lets look at the current example of bearish divergence.
Bearish Divergence occurs when prices are making new HIGHER highs,
and, at the same time, the stochastic indicator is showing LOWER highs. For
example, in the S&P 500 daily chart below, the stochastic indicator is making
lower highs at the same time the price action is setting higher highs. This is
considered bearish divergence, which could be used to indicate a possible
trend reversal with the prices moving lower. Bearish divergence is happening
RIGHT NOW on the S&P 500 see the current S&P chart below. Note the
significant change in trend direction just after the bearish divergence is
indicated.

15

Figure 1: Bearish divergence on the S&P 500 chart and the current downturn
Bullish Divergence is the opposite of bearish divergence and we are
looking at the bottom of the market or the valleys. Lets look at an example
in the Forex market with the AUD/USD daily chart below as an example of
bullish divergence. Notice as the price action continues to make LOWER lows
at the same time the stochastic indicator in the lower window has started to
move higher, making HIGHER lows, indicating a potential change in the price
movement or trend before the price action shows any real sign of a reversal.
Again, note the significant change in trend direction after the bullish
divergence is indicated.

16

Figure 2: Bullish Divergence on the AUD/USD


Understanding the trend and potential reversals is one of the most important
things to understand as a trader, which is very relevant to equity traders who
are looking for the direction to trade. Now, having explained how divergence
works, when it shows up, there may be reversal; however, how strong or long
the reversal is going to be is still an unanswered question. No indicator,
including divergence, should be taken in isolation, but should be looked at in
context with other indicators, trends, and support and resistance levels.
In conclusion, take some time to look for these divergence signals using the
stochastic indicator. They dont happen everyday, but when they do, they are
very powerful indicators of trend changes!

17

True Strength Index (TSI)


Developed by William Blau and introduced in Stocks & Commodities Magazine, the True Strength
Index (TSI) is a momentum oscillator based on a double smoothing of price changes. Even though
several steps are needed for calculation, the indicator is actually pretty straightforward. By
smoothing price changes, TSI captures the ebbs and flows of price action with a steadier line that
filters out the noise. As with most momentum oscillators, chartists can derive signals from
overbought/oversold readings, centerline crossovers, bullish/bearish divergences and signal line
crossovers.

SharpCharts Calculation
The True Strength Index (TSI) can be divided into three parts: the double smoothed price change,
the double smoothed absolute price change and the TSI formula. First, calculate the price change
from one period to the next. Second, calculate a 25-period EMA of this price change. Third, calculate
a 13-period EMA of this 25-period EMA to create a double smoothing. The same double smoothing
technique is used for the absolute price change. After these initial calculations, divide the double
smoothed price change by the absolute double smoothed price change and multiple by 100 to move
the decimal two places.

18

Double Smoothed PC
PC = Current Price less Prior Price
First Smoothing = 25-period EMA of PC
Second Smoothing = 13-period EMA of 25-period EMA of PC

Double Smoothed Absolute PC

19

Absolute Price Change |PC| = Absolute Value of Current Price less Prior
Price
First Smoothing = 25-period EMA of |PC|
Second Smoothing = 13-period EMA of 25-period EMA of |PC|

TSI = 100 x (Double Smoothed PC / Double Smoothed Absolute PC)

The first part, which is the double smoothed price change, sets the positive or negative tone for TSI.
The indicator is negative when the double smoothed price change is negative and positive when it is
positive. The double smoothed absolute price change normalizes the indicator and limits the range
of the ensuing oscillator. In other words, this indicator measures the double smoothed price change
relative to the double smoothed absolute price change. A string of large positive price changes
results in relatively high positive readings because this signals strong upside momentum. A string of
large negative price changes pushes TSI deep into negative territory.

20

The table above comes from an excel spreadsheet. Note that exponential moving averages are used
in the calculations. These start with a simply moving average and then use a multiplier for
calculation, which means additional historical data is needed to reach true values. Click here to
download this spreadsheet exampleand try it at home.

Interpretation
The True Strength Index (TSI) is an oscillator that fluctuates in positive and negative territory. As with
many momentum oscillators, the centerline defines the overall bias. The bulls have the momentum
edge when TSI is positive and the bears have the edge when it's negative. As with MACD, a signal
line can be applied to identify upturns and downturns. Signal line crossovers are, however, quite
frequent and require further filtering with other techniques. Chartists can also look for bullish and
bearish divergences to anticipate trend reversals; however, keep in mind that divergences can be
misleading in a strong trend.

21

TSI is somewhat unique because it tracks the underlying price quite well. In other words, the
oscillator can capture a sustained move in one direction or the other. The peaks and troughs in the
oscillator often match the peaks and troughs in price. In this regard, chartists can draw trend lines
and mark support/resistance levels using TSI. Line breaks can then be used to generate signals.

Center Line Crossover


The centerline crossover is the purest signal. The double smoothed momentum of price changes is
positive when TSI is above zero and negative when below zero. Prices are generally rising when TSI
is positive and falling when TSI is negative. The example below shows Nike (NKE) turning bullish in
September 2011 as TSI moved into positive territory (green line). The stock remained bullish as the
uptrend extended into the spring of 2012. Nike turned bearish when TSI turned negative and the
stock broke support.

Trend Lines
22

TSI often produces support and resistance levels that chartists can use to identify breakouts or
breakdowns. The example below shows Citigroup (C) with TSI establishing support in March. The
indicator broke support in early April and this breakdown foreshadowed a significant decline into
May. TSI then rebounded in June and formed a flat consolidation into July. This consolidation
resembled a falling flag and TSI broke above the trend line in late July. This breakout preceded
further strength into August.

Overbought/Oversold
Overbought and oversold levels for the True Strength Index vary according to a security's volatility
and the period settings for the indicator. The TSI range will be smaller for stocks with low volatility,
such as utilities. The TSI range will be larger for stocks with high volatility, such as biotechs. Using
shorter time periods for the smoothing will result in a wider range and choppier indicator line. Longer
time periods will result in a smaller range and smoother line. It is the classic technical analysis trade
off. Chartists get quicker signals and less lag with shorter periods, but this comes at the expense of

23

more whipsaws and false signals. Longer periods reduce the whipsaws, but these signals come with
more lag and a poorer reward-to-risk ratio.

The chart above shows the Nasdaq 100 ETF (QQQ) with TSI using two different time frames. The
upper indicator window shows TSI (40,20,7) fluctuating between -20 and +44 with 20/-20 marking
overbought/oversold. The lower window shows TSI (13,7,7) fluctuating between +78 and -69 with
50/-50 marking overbought/oversold. Notice how TSI in the lower window is much more volatile than
TSI in the upper window. Also notice that the more sensitive TSI produced two oversold readings
and four overbought readings (blue arrows). Overbought and oversold are not signals of impending
reversal. They simply suggest that prices have come too far too fast. Chartists must wait for a

24

confirming signal to suggest an actual reversal. The blue lines mark support and resistance using
trend lines, peaks or troughs. Once an overbought or oversold reading occurs, chartists can use
these lines to define a price reversal. This will not illuminate whipsaws, but it will reduce bad signals.

Signal Line Crossovers


The last parameter in the TSI setting is the signal line, which is simply an exponential moving
average of TSI. Signal line crossovers are by far the most common signals. This means there will be
good, bad and ugly signals. In an effort to reduce signals and noise, chartists should consider
increasing the settings for TSI or the price chart settings. The example below shows TSI(40,20,10)
using a weekly chart. This means the signal line is a 10-period EMA of TSI. There was no shortage
of signals on this chart as TSI crossed the signal line at least 12 times from April 2007 to July 2012.

25

Conclusions
The True Strength Index (TSI) is a unique indicator based on double smoothed price changes. Price
change represents momentum in its truest form. The double smoothing with two exponential moving

26

averages reduces the noise and produces an oscillator that tracks price quite well. In addition to the
usual oscillator signals, chartists can often draw trend lines, support lines and resistance lines
directly on TSI. These can then be used to generate signals based on breakouts and breakdowns.
As with all indicators, TSI signals should be confirmed with other indicators and analysis techniques.

SharpCharts
The True Strength Index (TSI) is available as an indicator for SharpCharts. Once selected, users can
place the indicator above, below or behind the underlying price plot. Placing TSI directly behind the
price plot accentuates the movements relative to the price action of the underlying security. Users
can apply advanced options to add horizontal lines for setting overbought and oversold levels.
Adjusting the numbers in the Parameters box will change the settings. Click here for a live example
of TSI in action.

27

28

TSI IN METASTOCK

r:=Input("first TSI time period",1,200,25);


s1:=Input("second TSI time period",1,200,13);
u:=Input("third TSI time period",1,200,7);
tsi:=100*(Mov(Mov(CLOSE-Ref(CLOSE,-1),r,E),s1,E))/(Mov(Mov(Abs(CLOSE-Ref(CLOSE,1)),r,E),s1,E));
tsi;
Mov(tsi,u,E)

===================
True Strength Index
===================
---8<--------------------------{ http://www.metastocktools.com }
pdsRoc:=Input("ROC periods",1,252,3);
pdsEma:=Input("EMA periods",1,252,5);
smooth:=Input("smoothing EMA periods",1,252,8);
display:=Input("plot TSI=1, +/- slope signals=2",1,2,1);
TSI:=100*
Mov(Mov(ROC(C,pdsRoc,%),pdsEma,E),smooth,E)/
Mov(Mov(Abs(ROC(C,pdsRoc,%)),pdsEma,E),smooth,E);
SlopeSig:=
If(TSI>Ref(TSI,-1),1,If(TSI<Ref(TSI,-1),-1,0));
0;If(display=2,SlopeSig,TSI)

29

Rainbow Charts
MetaStock Custom Indicator

To create Rainbow Charts in MetaStock for Windows, open any chart, drop the moving average
indicator from the Indicator QuickList, and drop it in the same inner windows as the price bars. Enter
two for the Periods and simple for the Method. Next plot a second moving average on the first moving
average by dragging a moving average from the QuickList and dropping it on the first moving average
(Note: The first moving average should turn light purple before you release the mouse button). If you
dropped it correctly the Parameters dialog should say Indicator for the Price Field. Click OK to accept
two periods and simple as the parameters. Change the colour of this moving average as desired. Now
plot a third moving average of the second moving average by repeating these steps. Continue this
until you have ten moving averages. Choose Yes if MetaStock prompts you about plotting a duplicate
indicator.

To save you time, Equis have created a template that allows you to bypass these steps. You can
download this template directly off of the Equis web site. Download this file to the Charts folder (e.g.
C:\Program Files\Equis\MetaStock\Charts) in your MetaStock folder. Open any chart and then click on
your right mouse button while the pointer is located on the chart. Choose Apply Template from the
Chart Shortcut menu and choose the Rainbow Chart template. You should now have a chart with ten
different coloured moving averages.

Next choose Indicator Builder from the Tools menu and enter the following formulas.
Rainbow Max
Max(Mov(C,2,S),
Max(Mov(Mov(C,2,S),2,S),
Max(Mov(Mov(Mov(C,2,S),2,S),2,S),
Max(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),
Max(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),
Max(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),
Max(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),
Max(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),

30

Max(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),
Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S))))
))))))

Rainbow Min
Min(Mov(C,2,S),
Min(Mov(Mov(C,2,S),2,S),
Min(Mov(Mov(Mov(C,2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),
Min(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),
Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S))))
))))))

Rainbow Oscillator
100 * (CLOSE - ((Mov(C,2,S)+
Mov(Mov(C,2,S),2,S)+
Mov(Mov(Mov(C,2,S),2,S),2,S)+Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S)+
Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S)
Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S) +

31

Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S)+
Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S)+
Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S)+
Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(Mov(C,2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S),2,S)) /
10))/(HHV(C,10)-LLV(C,10))

Lower Rainbow Band


-100 * (Fml("Rainbow Max") - Fml("Rainbow Min")) /
(HHV(C,10) - LLV(C,10))

Upper Rainbow Band


100 * (Fml("Rainbow Max") - Fml("Rainbow Min")) /
(HHV(C,10) - LLV(C,10))

Plot the Rainbow Oscillator in a new inner window of your chart with the ten moving averages, by
dropping the custom indicator from the QuickList onto the charts heading. Right click on the Rainbow
Oscillator and choose properties, then change the Style to a histogram. Now plot the Lower Rainbow
Band and the Upper Rainbow Band in the same inner window as the Rainbow Oscillator. If the scaling
dialog appears when plotting these indicators, choose Merge with Scale on Right. Change the colors
of the Upper and Lower Rainbow Bands as desired. Now save this as a new template by choosing Save
As from the File Menu and changing the File Type to template, so you can easily apply it to any chart.

5,35,5MACD
MetaStock Formula

The 5,35,5 MACD is a variation of the standard 12,26,9 MACD and was made popular by Chris
Manning, who uses it to identify major market divergence points:
((Mov( CLOSE, 5, E) - Mov( CLOSE, 35, E))-(Mov((Mov( CLOSE, 5, E) - Mov( CLOSE, 35, E)),5,E)))

When first plotted on a chart, the 5,35,5 MACD will appear as a solid line with no horizontal line at the
value of zero (as shown in picture below).

32

After applying the 5 35 5 MACD indicator to your chart, use the following steps to create a histogram
with vertical line at zero.

Double click the indicator to open the properties dialogue box.


Select the Color\Style tab and using the Style drop-down list, select the histogram setting

(second
from the bottom).

Select the Horizontal Lines tab and enter a value of zero (0) for the horizontal line value.
Click Add.

Click OK (indicator will appear as per picture below)

Bollinger Bands
MetaStock Indicator

"Trading bands are one of the most powerful concepts available to the technically based investor, but
they do not, as is commonly believed, give absolute buy and sell signals based on price touching the
bands. What they do is answer the perennial question of whether prices are high or low on a relative
basis. Armed with this information, an intelligent investor can make buy and sell decisions by using
indicators to confirm price action.

But before we begin, we need a definition of what we are dealing with. Trading bands are lines plotted
in and around the price structure to form an ''envelope". It is the action of prices near the edges of the
envelope that we are particularly interested in."

-- Taken from Stocks & Commodities, V. 10:2 (47-51): Using Bollinger Bands by John Bollinger

33

For further interpretation refer to the above article found in the February 1992 issue of Technical
Analysis of Stocks and Commodities.

Bollinger Bands are built into MetaStock, however you may prefer to use the individual custom
formulas.

The custom formulas for the components of the Bollinger Bands are as follows:
Upper Band:
mov( C,20,S ) + ( 2 * ( std( C,20 ) ) )
Lower Band:
mov( C,20,S ) - ( 2 * ( std( C,20 ) ) )
Middle Band:
mov( C,20,S )
%B :
( ( C+2 * std( C,20 ) - mov( C,20,S ) ) / ( 4 * std( C,20 ) ) ) * 100
Band width:
( ( mov( C,20,S) + ( 2 * ( std( C,20 ) ) ) )- ( mov( C,20,S) - ( 2 * ( std( C,20 ) ) ) ) )
/ mov( C,20,S)

True Strength Index - Metastock Indicator Formula


January 1993 issue of Technical Analysis of Stocks and Commodities.
100 * ( Mov( Mov( ROC(C,1,$),25,E),13,E) / Mov( Mov(
Abs( ROC(C,1,$)),25,E),13,E))

34

You might also like