Demo: Harmonic Oscillator Indicator (StockEval)

(Posted December 1, 2001)

StockEval has a number of technical indicators, but they are of a different sort than the traditional ones.  Several of these are combined on the Main Graph to give a clear picture of the technical situation of the stock at any given time.  There is also a set of six indicators in two splitter windows that are of the traditional form of a graph, but these indicators are different than the traditional ones.  As explained below, each of these actually combines several of the traditional indicators.  The technical indicators in StockEval are more advanced than the traditional indicators, and also more intuitive and easier to use.  We feel that they encompass and replace most of the traditional technical indicators. 

Technical Indicators in StockEval

StockEval has two sets of three indicators, in two splitter windows, which have been named the Harmonic Oscillator and the Technical Indicators.  These are displayed in two splitter windows with three panes each.  The Harmonic Oscillator indicator is so named because it behaves like a simple harmonic oscillator in physics.  The feature that makes these indicators unique is that they are extended into the future using Linear Prediction and smoothed using the Savitzky-Golay digital smoothing filter.  These advanced technical indicators are intended to replace the traditional indicators from the past.  They contain most of the same information, and are much more intuitive and easy to interpret.  These six technical indicators are described as follows:

Relative Price:

The bottom pane of the Harmonic Oscillator, which is the Relative Price, shows the price fluctuations relative to the Reference Curve.  The digital smoothing essentially picks out the N-day and longer price fluctuations from all the shorter period Fourier modes.  For N-day trading, you buy at a (local) minimum of this curve and sell at a (local) maximum.  This indicator may be thought of as the smoothed version of the price fluctuations within the Bollinger Bands on the Main Graph.  When the daily price moves outside the Bollinger Bands, the Relative Price indicator will be colored red or green, showing that the sell stop or the buy stop, respectively, are in effect.

Velocity:

The middle pane of the Harmonic Oscillator, which is the Velocity, is the first derivative, or rate of change, of the Relative Price.  This is the indicator that is most similar to the majority of the normally used technical indicators, as will be described below.  It indicates the slope of the tangent line to the bottom curve.  When this slope is zero, there is a minimum or maximum of the bottom curve, corresponding to a buy or sell signal.  So when the Velocity goes through zero from negative to positive, this indicates a buy signal, and when it goes through zero from positive to negative, this indicates a sell signal.

Acceleration:

The upper pane of the Harmonic Oscillator, which is the Acceleration, is the second derivative, or curvature, of the Relative Price.  This indicator should reach a positive maximum at a buy point (positive curvature) and a negative maximum at a sell point (negative curvature).  In a classical harmonic oscillator from physics, the oscillator itself would be represented by a sine wave, the velocity of the oscillator would be the same sine wave except 90 degrees ahead in phase, and the acceleration of the oscillator would be the same sine wave except 180 degrees ahead in phase.  This is indeed approximately true in the case of the Harmonic Oscillator indicator (at least, for the N-day fluctuations).

Trading Rules:

The bottom pane of the Technical Indicators displays the recommended N-day position, or Trading Rules, with the centerline corresponding to the normal or Core position.  This indicator is a combination of appropriate functions of the three components of the Harmonic Oscillator indicator, as described above.  You set the combination of the three components by means of three slider bars in the Trading and Portfolio Parameters dialog box.  The buy/sell points indicated on the Main Graph as green and red rectangles, and on both splitter windows as green and red lines, are derived from the Trading Rules indicator.  On the Main Graph, the first buy and sell points have a green and red horizontal line extending back to the present point in time, to indicate the recommended buy/sell levels for GTC limit orders.  When the daily price moves outside the Bollinger Bands, the Trading Rules indicator will be colored red or green, showing that the sell stop or the buy stop, respectively, are in effect.

Price Momentum:

The middle pane of the Technical Indicators displays the Price Momentum indicator, which is the difference between the daily (logarithmic) close and open prices multiplied by the actual volume, then subjected to N-day smoothing.  This is intended to display the rate of change of accumulation/distribution.  When the Price Momentum is positive, this is a buy signal, and when it is negative, this is a sell signal.

Volatility:

The Volatility indicator displays the spread between the (logarithmic) high and low daily prices, subjected to N-day smoothing.  This indicator should be of use to short-term traders in estimating the relative degree of N-day price movements.

Sample Indicators

With one of the stock data files open, choosing Harmonic Oscillator will display the Harmonic Oscillator splitter window:

MERindic1

In this splitter window, you can see the three technical indicators that make up the Harmonic Oscillator indicator.  The bottom indicator, called the Relative Price, is the N-day smoothed price relative to the 256-day smoothed Reference Curve.  It is similar to a type of MACD indicator, except that there is no time lag.  This is the indicator you would use in a Buy Low--Sell High type of strategy.  Above it is the Velocity indicator, which is the rate of change of the Relative Price.  It shows the slope, or rate of change, of the N-day smoothed price (relative to the Reference Curve).  This is the indicator you would use in momentum trading.  The top indicator is the Acceleration, which shows the curvature of the Relative Price.  This indicator shows the turning points of the Relative Price; positive curvature for a buy point and negative curvature for a sell point.

Through all three graphs you will note green and red vertical lines.  These correspond to the buy/sell points displayed on the Main Graph.  They are derived from the Trading Rules indicator on the Technical Indicators splitter window.  In turn, this latter indicator is constructed from the three indicators of the Harmonic Oscillator.  You will note that the green buy points pass very nearly through the minima of the Relative Price curve, and the red sell points pass very nearly through the maxima of the Relative Price curve.  In turn, the green buy points pass very nearly through the zero points moving upward, and the sell points through the zero points passing downward, of the Velocity indicator.  Similarly, the green buy points pass very nearly through the maxima, and the sell points through the minima, of the Acceleration indicator.  This corresponds to the Velocity being the first derivative, and the Acceleration being the second derivative, of the Relative Price.

Note that the present time is indicated by the vertical yellow line which passes through the ZERO point on the time scale.  The rest of the time scale is in days relative to the present.  The future buy/sell points tend to move around as the historical data are updated every night, but you can time your trades by estimating the point at which the green and red lines pass through the yellow line, denoting the present.  This will give you good approximate buy/sell points.

The part of the Relative Price indicator colored in red indicates that a sell stop is in effect, because the (average) price lies below the outer Bollinger Band.  This means that all long positions should be liquidated, and you will notice that there is no buy point recommended at that point.  If the price is above the upper Bollinger Band, where a buy stop is in effect, then the Relative Price indicator will be colored green.  This means that all short positions should be liquidated, and there will be no sell point recommended at that point.  

With one of the stock data files open, choosing Technical Indicators will display the Technical Indicators splitter window:

MERindic2

The bottom pane of the splitter window shows the Trading Position (or Trading Rules) indicator, which shows the recommended N-day short-term trading position as calculated by StockEval.  (This does not include the Core Position, which is derived from the expected returns and risk measured with respect to the Reference Curve, and calculated by the Portfolio Optimization routine.)  The actual numbers for the Core and N-day Positions are shown in the Short-Term Trading dialog box and the Portfolio Report.  It will be seen that the buy points (green lines) pass through the maxima of the Trading Position indicator, where the position should be maximum, and the sell points (red lines) pass through the minima of the Trading Position indicator, where the position should be minimum.  The form of the Trading Rules are determined by the three Trading Parameters settings in the Trading and Portfolio Parameters dialog box.  The three controls correspond to the Relative Price, Velocity, and Acceleration indicators of the Harmonic Oscillator.

The middle pane shows a Price Momentum indicator, which represents the rate of accumulation/distribution.  It consists of the daily close minus open (logarithmic) price, multiplied by the actual volume.  Thus, it is a measure of the actual significance of a (daily) price move, since it takes into account the volume of the move.  This indicator may be thought of as the rate of change of the On Balance Volume indicator.

The top pane shows the daily Volatility (after N-day smoothing).  This is the high minus low (logarithmic) price for the day.  It is known that the two-point correlations for non-linear functions such as volatility are not random; hence the Linear Prediction of this indicator should be of special significance.  The Volatility indicator may be of use in timing your trades on an intra-day basis.

If you choose Show Short-Term Trades from the toolbar, or right-click the mouse anywhere in the program, this brings up the Short-Term Trading dialog box:

MERindic3

This dialog box is useful because it encapsulates all the trading and recommended position information in one place.  It contains a list of all stocks in the Stock Group which are included in the portfolio by having their Trade this stock? check box checked (in the Form View).  For each stock the current position, Core Position, N-day Position, and recommended GTC buy/sell positions and prices are shown.  By clicking on any stock on the left, the right-hand list box shows the expected average price and volatility range for the upcoming trading day, calculated by Linear Prediction.  (The volatility limits correspond to the Prices where the Position is indicated as 100%.  The Position indicates the percentage of the volatility range.)  Below that are the Last Average, Open, High, Low, and Price, which you can get intra-day by doing an Intra-day Update from Dial/Data.  If the last update was end of day, these are the end of day prices.  The date and time of the last intra-day or end of day update is recorded in the upper right corner of the dialog box.  So this Short-Term Trading dialog box is very useful for organizing your trading activities during market hours.

Comparison with Traditional Technical Indicators

The Harmonic Oscillator indicator is now considered again, and each component compared to the usual technical indicator to which it is most similar.

N-day Smoothing:

Moving Averages:  The N-day smoothing of the price graph is, of course, similar to a (simple) moving average.  The main difference is that the smoothing uses both past and future data, and has no time delay, unlike the moving average, which uses only past data.  Close to the present day, the smoothed data must make use of the future projected prices a projection routine.  Also, the Savitzky-Golay digital smoothing filter preserves the shape of features with a period longer than N days, better than the moving average.  The difference of two smoothings with different time periods may be used in a similar fashion to the difference of two moving averages, except for the fact that there is no time delay in the smoothing.  So if the price is trending uniformly upward or downward, the two smoothed price curves will not lead or lag one another (unlike the two moving averages).  In the case of two moving averages, this time delay means that the difference of the two moving averages functions similarly to a derivative of the price curve.  The difference of two smoothings may be used to indicate a short-term fluctuation relative to a longer-term average, but since there is no time delay the difference does not function as a derivative.  On the other hand, derivatives may be calculated from the Savitzky-Golay digital smoothing filter directly.

Relative Price:

Moving Average Convergence Divergence (MACD):  The standard MACD indicator is the difference of two exponentially weighted moving averages, the slower moving average of 130 trading days, and the faster one of 60 days.  The difference is then smoothed by a 45 day moving average.  This is somewhat similar to what is done in the Relative Price indicator, except that the Savitzky-Golay digital smoothing filter is used instead of exponentially weighted moving averages, thereby eliminating the time lag.  In the Relative Price indicator, with the trading time scale set to N days, the difference is taken between the N-day smoothed price and the Reference Curve consisting of the 256-day smoothed price.  The result of this is that the short-term modes with periods less than N days are eliminated by the N-day smoothing, and the long-term modes with periods greater than 256 days are eliminated by subtracting the Reference Curve.  This produces a type of oscillator, with no time lag, in which the predominant modes have periods close to N days.

 

Williams' Percentage Range (Percentage R):  This indicator takes the prices over the past N-day time interval, then plots the current price as a percentage of the price interval between the highest and lowest price within that time interval.  It thus displays the current price within the trading range established over the past N days.  If this indicator were smoothed out by eliminating the shortest-term fluctuations, then it would be essentially the same as the N-day fluctuations in the Relative Price part of the Harmonic Oscillator indicator.  Both indicators show when the price swings have reached oversold and overbought limits, indicating buy/sell points respectively.  The main difference is that the Relative Price indicator filters out the daily price fluctuations, leaving only the N-day (and longer) fluctuations, and it shows the overbought/oversold conditions relative to the long-term trend, not relative to the N-day range of prices.  This is in accord with the overall trading strategy of StockEval, which is that overbought/oversold conditions relative to the short-term average do not have much relevance.  The Harmonic Oscillator has no time delay, because it uses the Savitzky-Golay digital filtering, and the Percentage R indicator also has no time delay, since it plots the most recent closing price as a percentage of the most recent N-day range of prices.  However, the Harmonic Oscillator indicator contains a lot more price information than does the Percentage R indicator, because the Harmonic Oscillator is a smoothing of an N-day range of average prices, with each average price the sum of the open, high, low, and close prices divided by four.  But the Percentage R indicator consists of just the single latest closing price relative to a single N-day high and low price, so the total information content is much less.

Velocity:

Oscillator:  The traditional Oscillator of Technical Analysis is closely related to the Velocity part of the Harmonic Oscillator indicator of StockEval.  The traditional Oscillator is just the difference between the most recent closing price and the closing price N days ago, expressed as a point within the range of prices covered within the last N days.  This range of prices is usually normalized to the interval between -1 and +1.  But the traditional Oscillator can be seen to be the average price velocity over the past N days.  However, once again, it can be seen that the traditional Oscillator contains far less price information than the Velocity of the Harmonic Oscillator indicator.  This is because it is only the difference between two closing prices, whereas the Velocity is the first derivative of the smoothing of N average prices, with each average price as described above.  The traditional Oscillator is intended to identify potential N-day minima and maxima in the price curve, corresponding to buy and sell points.  It does this because the traditional Oscillator is a time delayed indicator, by an average of N/2 days, but the price velocity of an oscillator with a period of 2N leads the price curve by one quarter cycle, which is N/2 days.  The N-day Oscillator will in general smooth out the price fluctuations with periods shorter than 2N days, for which a half cycle is N days, leaving the 2N day cycle as the shortest cycle.  Then, since the velocity leads the prices by N/2 days but the traditional Oscillator lags the price data by that same amount, interpreting the Oscillator as representing the 2N-day cyclic price swings leads to an estimate of the buy/sell points.  The Velocity part of the Harmonic Oscillator indicator measures the price velocity directly, with better "statistics" and no time lag, so its buy/sell points are indicated by zero-crossing points corresponding to local minima and maxima of the price curve.

 

Wilder's Relative Strength Index (RSI):  This index is also similar to the Velocity of the Harmonic Oscillator indicator in that both are related to the first derivative of the N-day smoothed prices.  The Velocity indicator shows this directly, of course.  The RSI indicator is a more indirect measure of the first derivative and is again lagged in time by N/2 days.  The RSI indicator is constructed by counting the number of Ups and Downs over the N day interval.  An Up is the difference in closing price on a certain day minus the closing price the day before, if this quantity is positive, and zero if it is negative.  Likewise, a Down is the difference in closing prices if it is negative, expressed as the absolute value (a positive number), and zero if the difference is positive.  The RSI is then defined as the sum of all the Ups divided by the total Ups plus Downs over the N-day interval, multiplied by 100.  It thus ranges between zero and 100.  (They should have defined it as (Ups - Downs)/(Ups + Downs), a number between -1 and +1, but oh well.)  This indicator still contains less price information than the Velocity of the Harmonic Oscillator indicator, since it still uses only closing prices.  The RSI indicator actually contains essentially the same information as the traditional Oscillator described above, since the modified version of the RSI that was just suggested is virtually identical to the definition of the traditional Oscillator.  (The (Ups - Downs) is just the difference in closing prices between now and N days ago, and the (Ups + Downs) is roughly the expected range in prices over the N days.)  As before, the Velocity of the Harmonic Oscillator indicator measures the same thing, except with better "statistics" and no time lag.

 

Lane's Stochastics:  This is a composite indicator consisting of the RSI indicator over a short time interval, together with three moving averages of this indicator.  Actually, in Eng's book the definition of this indicator is a little ambiguous, because although it is defined to use the RSI indicator, in the actual description of how to set up the indicator it sounds more like it uses a variation of the Percentage R indicator.  However, there should not be a whole lot of difference between a short time period RSI indicator and the Percentage R indicator, so either will probably work.  In both cases, the overbought signals are at the troughs of the indicator, and the oversold signals are at the peaks.  To complete the Lane's Stochastics indicator, one takes a short time moving average of the RSI or Percent R, then a moving average of that moving average, and finally another moving average of the second one.  One plots the first two indicators together, and the last two indicators together, forming two separate graphs.  The buy/sell points are indicated at the crossover points of the two moving averages in each graph.  Note now that comparing two moving averages with different time scales is similar to the concept of taking a derivative, and the crossover points of the MAs correspond to the zero-crossing points of the derivative.  If RSI is used, then this is effectively a way to determine a time-delayed second derivative of the prices, while if Percent R is used; the result is effectively a first derivative of the prices that is not time-delayed.  In either case, the crossover point is equivalent to the zero-crossing point of the Velocity of the Harmonic Oscillator indicator.  So, instead of comparing two moving averages to effectively get the zero-crossing points of the first derivative of the price graph, it is much better to calculate this quantity directly by using the Savitzky-Golay smoothing filter in the Harmonic Oscillator indicator.

Acceleration:

Lane's Stochastics:  None of the usual indicators seem to calculate a second derivative directly, although Lane's Stochastics calculates a kind of effective time-delayed second derivative if one mentally pictures the difference of two moving averages of the RSI indicator.  However, it is much more straightforward to calculate this smoothed second derivative directly using the Savitzky-Golay smoothing filter in the Harmonic Oscillator indicator.  This second derivative, or Acceleration indicator should be used as a confirming indicator to the Relative Price and Velocity parts of the Harmonic Oscillator indicator.

Price Momentum:

On-Balance Volume:  The Price Momentum indicator is the difference between the daily (logarithmic) close and open prices multiplied by the actual volume, then subjected to N-day smoothing.  This is intended to display the rate of accumulation/distribution, and may be thought of as the rate of change of the On-Balance Volume indicator.  (The On-Balance Volume is an integrated form of the Price Momentum indicator.)

Conclusion

To be honest, it appears that many of the standard technical indicators were devised before the days of personal computers, and were constructed the way they were because they were the only quantities that were easy to calculate by hand.  The Harmonic Oscillator indicator and other technical indicators in StockEval evidently contain the same information and are easier to interpret than these standard technical indicators.  

return to Demonstrations page