previous   this   next   contents   reference   index   search
Tutorial: A Walk Through EAS
Below is a short tutorial on how many of the features of EAS might be used to analyze an equity. Included in this tutorial are construction of a combined chart using several technical indicators and constructing two custom indicators called Position within Bands and 10 Day Momentum. Position within Bands is an example of creating a complex indicator, while 10 Day Momentum is a good example of designing a more simple indicator. In addition the EAS Pattern/Target Menu will be used to assess possible entry and exit points. It is not meant for the reader to trade based on this analysis or these indicators, just to observe how the charts and indicators were constructed. It is hoped that the concepts outlined in the EAS help manual will be illustrated by example.

Combined TA Chart
Any good technical analyst will take a number of factors into account when trying to assess the technical position of a stock. Momentum, volume and timing are excellent tools to try to determine entry and exit points. One of the best ways to get a complete picture is to combine several technical indicators on one chart and apply some overlays.

A complete commented EAS script file for constructing this chart can be found in the my_drive:/EAS/utility/charts directory in the file tutorial1.oms. (see also combined chart EAS script code ). An ellipsis "..." means the line is continued to the next line in the code.  

The (CMF) Chaikin's Money Flow indicator will be used along with the Accumulation-Distribution Overlay over the price chart to get an idea of the accumulation or distribution that might be occurring.

To aide in timing a purchase or exiting a trade the Stochastic Oscillator indicator will be used in conjunction with the short term (KST) Know Sure Thing to evaluate trends and longer term cycles.

To plot price the candlestick plotting method is selected as candlesticks tend to contain a lot of information on short term trading tendencies. Volume is also plotted to verify breakouts and breakdowns in price.



The resulting chart contains a lot of useful information. The KST tells us with pretty good accuracy the direction of the prevailing trend and when the momentum starts to weaken and change. The CMF indicator tends to support the stronger price moves predicted by KST EMA signal line crossovers and divergences with its brand of accumulation/distribution analysis. Using the stochastic to enter long position when the KST is above zero tends to pinpoint profitable entries and exits are targeted by using similar combinations of situations. The Accumulation-Distribution Overlay also signals high accumulation or distribution or a turnaround in price when it crosses its EMA or is rising or falling. As of this writing it could be signalling an end to the current uptrend.

Using the Pattern/Target Menu
To get a clue as to how profitable a trading setup might be and to establish price targets at which to re-evaluate the technical position, is where the EAS Pattern/Target Menu tools can be most effectively applied. Using the same chart developed above we can apply a few of the pattern and trendline techniques to establish price objectives. Using the same chart and zooming up on the region from June to August, 2000 we could see that the technical position was improving as outlined below. Notations on the chart were made using EAS's EAS Draw/Annotate Menu and EAS Pattern/Target Menu tools.



Near the between June 20th and near the end of July GMCR broke a short term down trend on good volume. The target established by the Trendline Break technique was about $17 and the breakout price was around $13 per share. The predicted resulting move was for approximately 31% gain on the long side. Notice also that a little over a week prior to this move, there was a relatively large red candlestick on a very large volume spike at the time. This indicated an exhaustion of selling, so the trendline breakout and subsequent reversal had little resistance to fight through, improving its chances of success. Notice that the Stochastic Oscillator also gave a buy signal from the oversold condition and the KST crossed over its EMA signal line at the same time as the trendline break. This was a pretty sure thing and 31% is nothing to sneeze at. The move was predicted correctly and GMCR moved up to the vicinity of the target price and paused just above it for some time.

It was time to re-evaluate the technical position. GMCR had run up pretty good over a short time, but volume declined all the way up through the target price. Chaikin's Money Flow was negative indicating some selling was taking place. Once price began to decline the stochastic gave a sell signal near the peak in late August. The KST had crossed over the zero line, however, indicating that momentum was still up. Volume was low so an imminent sell-off was not evident. It was probably a good time to take some profits, but maybe not the entire long position and the technicals certainly did not indicate a short.

After a period of relative inactivity GMCR began an unprecedented rise probably sparked by excellent earnings, superior relative price strength compared to the market and a decline in coffee prices. The Accumulation/Distribution Line Overlay showed that there was plenty of buying pressure occurring. It rose above its 21 day EMA and stayed there for some time. At the moment the A/D line may be forecasting a pause in the trend, since it failed to reach a higher high along with price.



The Stochastic Oscillator also rose above 50 and stayed there for some time indicating superior strength and momentum. It wasn't of much help in terms of overbought/oversold signals, however. Nevertheless, the crossovers of the %K and %D lines did yield valid buy and sell signals. The tool that proved best in evaluating entry and exit points for GMCR was the 2-Point Pattern target projection method based on the flag continuation pattern with the stochastic crossovers providing support for buying opportunities.



Its a little tough to see on this price chart, but the flag targets were essentially achieved after each predicted breakout. The breakouts were validated by the heavy volume on the price increase and the possibility of breakdown was limited from the lack of selling volume. CMF also indicated heavy buying pressure. Buying on the stochastic/flag breakouts and selling at the target price would have been very profitable for the short term trader.

Constructing a Simple Custom Indicator
To show how an indicator might be constructed and subsequently charted we should start with a simple function. Momentum is a well known concept in technical analysis that is used to evaluate trending characteristics. Let's begin this section of the tutorial by constructing a 10 Day Momentum indicator. This is simply the closing price 10 days prior to any data point subtracted from the price on the day the momentum will be plotted. So for this indicator 10 is the lookback period.

To construct a series of this data one could create a for-next or while loop and create an output vector of 10 day momentum data, however, EAS simplifies this process by supplying one of several EAS Mathematical Calculation Script Functions. The function we will use here is Running Difference of a Series Over a Set Lookback Period. To construct the 10 day running series we need only call the function and supply it closing price data and the lookback period

     mom10d=fdiff(cp,10)

We have now filled the variable mom10d with the desired momentum series. To plot the series along with a price chart we need to add a chart window and some plot commands. addstdchart will add the window and views.

     addstdchart(rowdim(cp),"mom10d","candle")

The rowdim(cp) supplies the length of the data matrices shown on the plot. "mom10d" is the name of our new indicator - this could be any non-standard EAS name, but it should be less than 6 characters. Now lets add the plots, titles, grids, a zero signal line and the date scales.

     titleset("10 Day Momentum with Price")
     gview(1)
          perplot(mom10d,1,L,10,"red","solid",5)
          emaplot(mom10d,1,L,10,"black","dotted",1)
          datescale(mmddyy,1,L)
          gxgrid("major")
          vtitle("10 Day Momentum and 10 Period EMA")
          fsigln(0,"black","solid",1)
     gview(2)
          candlechart(hp,lp,cp,op,1,1,L)
          datescale(mmddyy,1,L)
          gxgrid("major")
          gygrid("major")

This code produces the following chart:



We can see that our new indicator actually gave some timely buy and sell signals. Using the EAS Draw/Annotate Menu we can add some notes and trendlines to help weed out the trading signals. We can notice that while our momentum indicator is above the zero line and rising we tend to be in an uptrend and sell signals may be given when the indicator goes near the oversold bands and crosses its EMA. Similar occurrences happen for buy signals near oversold levels. We can also note that a trendline can be drawn below where the current strong uptrend is occurring. The complete commented code is shown here .

Constructing a Complex Custom Indicator
The Bollinger Bands Overlay is used by many chartists to gage the volatility and overbought/oversold status of any equity. Since this indicator uses the standard deviation statistic to measure likely maximum price swings and 6 times the standard deviation will contain 99% of all the statistics within a period, it would seem reasonable that a stochastic type oscillator could be developed to gage how overbought or oversold the price is within the confines of the Bollinger Bands.

To explore this possibility we need to begin by calculating a the standard deviation and a moving average over some lookback period. Let's use 14 days and compare this new indicator with the 14 day Stochastic Oscillator and (RSI) Relative Strength Index.

First we'll need to calculate the new indicator. The indicator will consist of an upper and lower bounding line based on 3 times the standard deviation plus or minus a simple moving average over the same period. So we'll need the sma , fsigma . (see EAS Mathematical Calculation Script Functions)

     ub=sma(cp,14)+3.0*fsigma(cp,14) # lower bound
     lb=sma(cp,14)-3.0*fsigma(cp,14) # upper bound
     posn=(cp-lb)/(ub-lb)*100.       # % position between the two bounds

This will generate the position within the Bollinger Bands on a percentile scale. We can also take the statistics one step further. Instead of guessing where the overbought/oversold bands are and setting them at an arbitrary 80/20 or 70/30 level, we can calculate the standard deviation of the position and choose a multiplier for that deviation that should contain most "normal" price swings. We were using statistics here anyhow!

     psigma=fsigma(posn,14,L)
     aveposn=colmean(posn(14::L))

This represents 1 standard deviation of the posn variable data. Then we need to add the chart window, scales, etc. I've also added a 5 period EMA of the posn curve.

     L=rowdim(cp)
     addstdchart(L,"pwb","stoch","ohlc")

     titleset("Oscillator Comparison with Posn in BB's")
     gview(1) # Stochastic
          stoch14=fstoch(hp,lp,cp,3,14,"data","plot",1,L)
          indnote("stoch",L,stoch14,3,14)
          gxgrid("major")
          datescale(mmddyy,1,L)
     gview(2) # RSI
          rsi=frsi(cp,p0rsi,p1rsi,p2rsi,"data","plot",1,L)
          indnote("rsi")        
          gxgrid("major")
          datescale(mmddyy,1,L)
     gview(3) # The new indicator
          perplot(posn,1,L,14,"purple","solid",3)
          emaplot(posn,1,L,5,"gray","solid",3)
          fsiglin(aveposn+psigma,"red","solid",1)
          fsiglin(aveposn-psigma,"green","solid",1)
          gyaxis("linear",0,100)
          gxgrid("major")
          datescale(mmddyy,1,L)
          vtitle("14 Period % Position within Bollinger Bands (6 Sigma)")
     gview(4)
          barchart(hp,lp,cp,op,1,1,L)
          smaplot(cp,1,L,p1cp,"red","solid",3)
          smaplot(cp,1,L,p2cp,"blue","solid",3)
          smaplot(cp,1,L,p3cp,"green","solid",3)
          gxgrid("major")
          gygrid("major")
          datescale(mmddyy,1,L)

The following chart results:



you can see from the chart that this indicator produces excellent buy and sell points although it could stand to be smoothed out somewhat. It is very similar to the RSI and stochastic plots. The statistically chosen overbought/oversold regions seem to reflect the concept we were after. I've labelled the chart with valid buy and sell signals. All three indicators give signals at nearly the same times. The complete commented code is shown here .

So you can see that when you develop an idea you want to explore EAS makes it fairly easy to construct useful charts for plotting virtually any thing you can think of from price and volume data. Even a more complex concept such as this example is made reasonably simple. I hope to make the code even easier in future releases of EAS