(Revised September 3, 2006)
by
Robert Murray, Ph.D.
Omicron Research Institute
(Copyright Ó 2006 Omicron Research Institute. All rights reserved.)
QuanTek is a stock (or any other type of security) trading program for short-term traders and long-term investors. The technical indicators and trading rules are based on modern ideas of Econometrics and Signal Processing. QuanTek uses a variety of filtering and smoothing algorithms to apply Signal Processing techniques to financial data, in order to derive a Price Projection and various technical indicators and trading rules. QuanTek also has a wide variety of statistical tests that can be used to design custom technical indicators, derive an optimal portfolio, and for general studies of market dynamics. The use of these features for short-term trading and long-term investing will be described here.
QuanTek basically has two independent sets of technical indicators. The first set is derived from the Price Projection, which is the output of the Linear Prediction filter, which is smoothed by an acausal Savitzky-Golay smoothing filter. The Linear Prediction filter makes use of correlation in the past data to make a future prediction. The Savitzky-Golay smoothing filter is like a more sophisticated version of the familiar moving average. Together, these filtering operations lead to a set of three technical indicators, called the Harmonic Oscillator, which are then displayed in a set of splitter windows, and buy/sell signals and buy/sell points are derived from them. The buy/sell points are displayed on all graphs and splitter windows, and may be used as long-term trading signals. They are re-calculated each time the Main Graph is opened, and do not require too much computation. However, their effectiveness is not tested directly. The second set of technical indicators can be custom-designed by you, the trader, and their effectiveness tested by means of several statistical tests. These technical indicators are designed using the Technical Indicators dialog box, and then tested using the Correlation Test – Indicators dialog, to allow the best possible chance of finding technical indicators that show a positive correlation with future returns. You can design and display three such indicators, called the Momentum indicators, in splitter windows, and a weighted sum of these forms the Trading Rules indicator. This last indicator can be used for short-term trading, based on the knowledge that its effectiveness has been verified by maximizing the positive correlation with future returns (of the three Momentum indicators). The effectiveness of the Trading Rules indicator in various realistic trading scenarios may also be tested directly by means of a back-testing routine called the Diagnostic Test.
QuanTek also has a variety of statistical tests for general studies of market dynamics. Perhaps the most important is the Hybrid LP Filter dialog, which is used to select the Linear Prediction filter type and parameters for each security, as well as to test the effectiveness of a filter selection. Connected with this is the Correlation Test – Filters dialog, which is similar to the corresponding Indicators dialog mentioned above, except that it measures the correlation with future returns of the direct output of the LP filter instead of the technical indicators. There are also two measures of the spectrum of the stock returns, one based on the standard Fourier spectrum (Periodogram), and the other based on the Wavelet spectrum. These tests are important, because they indicate whether the returns are really just white noise (Random Walk) or whether they contain correlation. The spectrum for white noise is just a constant spectrum, while if correlation is present the (smoothed) spectrum will be non-constant. These spectrum measurements form the basis for the Linear Prediction filters used in QuanTek, and are also important for general statistical studies of market dynamics. There is also a scatter graph measuring correlation (for varying time lag) between the returns of two different (or the same) stocks. This graph is useful for security selection in an optimal portfolio, as well as for general studies of market dynamics.
The Price Projection in the Main Graph of each stock (or other security type) data file is based upon the output of a Linear Prediction filter. (In the present version, there are five similar LP filters to choose from. Each of these uses only the historical price data of the individual data file.) This type of filter attempts to measure correlation in the past data, and then use this correlation to make a future prediction. At present, the Linear Prediction filters used in QuanTek make the assumption that the statistics of the data are stationary over the past 1024 days. This seems like a reasonable assumption, because for one thing there may not be enough data to measure time-dependent correlation on a shorter time scale. Also, you would expect the (long-term) correlation to be due ultimately to investor behavior in the stock market, and this behavior should remain relatively fixed over time spans of a few years. The prices are, of course, influenced by exogenous events such as economic and political developments, as well as earnings reports from each company, but these may not affect the long-term correlation in the data. The correlation is due to the market dynamics not being perfectly efficient, because investors are not perfectly rational and knowledgeable in their behavior, and they also may have a short time horizon. The goal is to try to take advantage of this (slight) inefficiency by searching for the correlation and then basing a set of trading rules on it.
Pundits will say, of course, that there is no correlation in the stock data, and all the LP filter is doing is “fitting to the noise”. It is indeed true that the market is very efficient and a large part of the Price Projection is indeed just that – fitting to the noise. (Although the filters based on the DWT seem to get around that problem to some extent.) Whatever correlation there is will be buried in stochastic noise and hard to isolate. However, it is necessary to try to make a prediction or estimate of future returns, no matter what, for the sake of portfolio optimization. So we assume that there is a signal buried within the noise, and try to make a prediction of the future signal apart from the noise. Hopefully the long-term estimate of future returns will “capture” the signal buried in the noise, although the shorter-term fluctuations may indeed just be “fitting to the noise”. Note that any kind of estimate of future returns based on past data will run into this same type of problem, including Technical Analysis or Fundamental Analysis. Basing this estimate on long-term trends or moving averages, as in Technical Analysis, is equivalent to using a particular kind of LP filter, but the LP filters used by QuanTek are more sophisticated than this. (In fact, the usual exponential MA is evidently just an LP filter for the MA(1) process – a moving average process with a single parameter – as opposed to the LP filters used by QuanTek which fit an autoregressive process with up to 512 parameters. A combination of Moving Average (MA) and AutoRegressive (AR) processes is what is known as an ARMA process. The QuanTek LP filters also take into account fractionally integrated processes, so these are known as ARIMA processes.) The basic assumption being made here is that the signal resides in the low-frequency, long-term changes in the returns, which is buried in the noise which corresponds to the high-frequency, short-term fluctuations in returns. After smoothing, by the Savitzky-Golay smoothing filter, we hope to filter out the high-frequency noise, leaving the low-frequency signal for use in making a Price Projection. On the other hand, there could very well be correlation in the high-frequency fluctuations as well. The central problem, therefore, is one of separating out a signal buried in stochastic noise, and this is a problem in Signal Processing.
One other point that should be mentioned is that the Trading Rules do not necessarily depend on the Price Projection. In the Correlation Test – Filters dialog the past N-day returns and future N-day price projections are measured with respect to their correlation with future N-day returns. In the Correlation Test – Indicators dialog, the indicators based on past N-day returns and future N-day price projections are measured with respect to their correlation with future N-day returns. In both cases, by choosing the time lag appropriately, the past N-day returns and the indicators based on them can be measured with respect to their correlation with future N-day returns, without reference to any Price Projection. When the output of the Correlation Tests is examined, the correlation is greater than the one-standard deviation level much more than 31.7% of the time, which it would not be if the correlation were merely random noise. This applies to the past data as well as the future projection. So a viable set of Trading Rules could be based solely on past data, irrespective of the future Price Projection.
There are two related types of trading signals in QuanTek, which we call buy/sell signals and buy/sell points. Both of these trading signals are derived from the Harmonic Oscillator indicator (see below). The buy/sell signals are for the purpose of setting buy/sell limit orders. They occupy a range of time around the maxima and minima of the Relative Price indicator, and their parameters may be set by two controls on the Trading and Portfolio Parameters dialog. The Threshold control determines the level of the buy/sell signals, above or below the N-day smoothed price level. This corresponds to the optimum setting for the buy/sell limit price. The Range control determines the range of the Relative Price indicator that triggers the buy/sell signal. In this way you can set buy/sell signals only for extremes of price, or more often for smaller maxima or minima of price. The other two criteria for the buy/sell signals are that the Velocity indicator should be positive/negative, and the Acceleration indicator should also be positive/negative for a buy/sell signal. The buy/sell signals are listed (for the upcoming day) in the Short-Term Trades dialog, which you can see at any time just by right clicking. They are also displayed in scale 4 and scale 8 of the Main Graph. (The Main Graph scale 8 only displays those buy/sell signals that were actually “triggered” as limit orders.) The buy/sell points are markers for the single points that are the first of a set of buy/sell signals. Hence they are the points that are minima/maxima of the Relative Price indicator, the zero crossings (positive/negative) of the Velocity indicator, and the maxima/minima of the Acceleration indicator. The buy/sell points are displayed as green and red arrows on scale 2 of the Main Graph, which you see when you first open a stock data graph. The buy/sell points are also displayed as green and red vertical lines on all nine of the splitter-window panes. These buy/sell points are mainly for the purpose of marking the most favorable points to buy and sell in the range of buy/sell signals, and also as markers to line up the features in all the graphs. In the splitter windows, these buy/sell points are intended to line up the maxima (max), minima (min), zero crossing moving upward (Z+), or zero crossing moving downward (Z–), points on each graph, as the case may be, for reference purposes, with respect to the price fluctuations of the historical (and future projection) price data.
Also note that on the QuanTek graphs, the buy/sell signals and points to be acted upon are the ones that pass through the present point in time on the graphs. On the Main Graph, the present time is marked by the transition from white (or black) vertical bars, denoting the past data, to blue squares, denoting the future Price Projection. On the splitter-window panes, a vertical yellow line marks the present time. The buy/sell signals and points to be acted upon are the ones that are indicated just at the present point in time. These are also listed in the Short-Term Trades dialog for each stock. The buy/sell signals and points to the future of the present time are estimated ones, based on the future Price Projection. The buy/sell signals and points to the past of the present time are computed based on perfect hindsight or knowledge of the past (for the distant past, at any rate). These are displayed for the purpose of showing the frequency and range of these signals and points, and showing what they would look like if the future had already been known. (To re-compute all of these signals for each day in the past, using only past data relative to each day, would take a very long time to compute. This type of computation is done in the Calculate (Stock) Data, which is done prior to designing and testing the Momentum indicators. We felt it was important to display the past buy/sell signals and points, based on perfect hindsight, for reference purposes, along with the future projected buy/sell signals and points.)
Probably the easiest trading strategy is to simply make use of the Price Projection and the indicated buy/sell signals and buy/sell points to make trades. Also the core position and expected return in the Optimal Portfolio should be consulted. The expected return, in turn, is calculated using the long-term 512-day acausal smoothing of the Price Projection. (This gives it a certain amount of stability, which it would not have if it were based on the unsmoothed Price Projection alone.) The core position is then based directly on the expected return, as well as the risk, in the Optimal Portfolio calculation. The Day-Trading indicator in the Short-Term Trades dialog is also based on the 1-day prediction of the LP filter. However, for independent short-term trading in individual stocks, the Momentum indicators and Trading Rules indicator form an independent set of trading signals. These are harder to design, test, and use, however, than the other indicators. But they have the advantage that they may be tested using the battery of statistical tests in QuanTek.
In the usual nomenclature, the term Momentum indicator means an indicator which signals the onset of a price move, or which is proportional to the rate of movement in price. However, for the purpose of the QuanTek program, we would like to give this term a slightly more specific meaning. In the QuanTek program, by a Momentum indicator we mean any function of past prices (and perhaps fundamental and other economic data) which shows a positive correlation with future returns, over some specified holding period. This correlation is established by means of the QuanTek Correlation Test – Indicators dialog box. So, a Momentum indicator will be some function of the past prices, which shows a positive correlation with the future returns over the holding period of N days. The Momentum indicator is computed for each trading day in the past, using all the past price data up to and including that day. The value of the Momentum indicator computed for each past trading day, using only past data up to that day, is correlated with the future returns relative to that day, and the correlation so measured is supposed to be at a positive peak.
The Momentum indicator is computed using a variety of price projection and smoothing techniques. Given all the past data set, a Linear Prediction filter is used to project the past prices into the future, using whatever correlation exists in the past data. Then the past data and its future Price Projection may be smoothed by a Savitzky-Golay smoothing filter, to yield a value for the Momentum indicator which is the value of this smoothing corresponding to the present day. However, the smoothing also yields values for all the past and future (projected) days. The smoothed values in the past are just a smoothing of the past data, and can be thought of as values of the Momentum indicator if perfect hindsight from the future is assumed. The smoothed values in the future are projections or estimates of the Momentum indicator into the future. In essence, each of these values of the Momentum indicator may be thought of as an independent indicator. When the Momentum indicator is plotted as a graph, it is this entire smoothing of the past and future projected prices that is plotted. In the Correlation Test – Indicators dialog, the correlation between each of these indexed values of the Momentum indicator with the future returns is computed and displayed. In this way, only past data are used to compute the Momentum indicator, which is supposed to be correlated with the future returns. In other words, the Momentum indicator is causal.
You can define a wide variety of Momentum indicators using the Technical Indicators dialog box. Basically, given the past price data and its Price Projection (for each day in the past), you can select a smoothing time scale based on the acausal Savitzky-Golay smoothing filter. This filter also gives you a choice of smoothing of the prices or of their first or second derivatives (rates of change). (The first derivatives of the prices are the returns.) These three different types of indicators are called the Relative Price, Velocity, and Acceleration. You can also choose the time lag of the indicator, which adjusts its phase. This is extremely important, because in this way you can adjust the time lag for a maximum positive correlation peak. You can also change the sign of the indicator, or use a difference of two such smoothings with different smoothing time scales and time lags. Between all of these choices, these encompass most of the familiar technical indicators that are (linear functions) based on price alone, or are in essence equivalent to these familiar indicators.
To use the Momentum indicators and Trading Rules indicator is straightforward. First you must open the Main Graph for a given stock, and run the Calculate (Stock) Data calculation. This will take a couple of minutes, because it calculates a Price Projection for each of 1024 days in the past (as the “present day”). Now open the Technical Indicators dialog. You can design a technical indicator for each of the three Momentum indicators. For each one, click the Calculate button to calculate it, and then open the Correlation Test – Indicators dialog. You should see a graph, representing the correlation between each index value of the Momentum indicator and future returns. You can now adjust the time lag of the indicator so that a peak (positive or negative – if negative then you can change the sign) appears under the zero index line. Switching back to the Technical Indicators dialog, this time lag is transferred to the definition of the indicator. Doing this for all three Momentum indicators, you can then compute and save all three indicators in the stock data file. You can also adjust the weights of the three Momentum indicators in the Trading Rules indicator, and this will also be saved. All four of these indicators are displayed in splitter windows, in the form of N-day forward moving averages of the indicators. This is because the N-day forward moving average indicators are supposed to be correlated with the N-day forward moving average future returns, for an N-day time horizon, which is also displayed in the splitter window. The value of the N-day forward moving average Trading Rules indicator is also shown in the Short-Term Trades dialog and the Portfolio Report. The effectiveness of the Trading Rules indicator can be tested in a variety of realistic trading scenarios in the Diagnostic Test. Then this Trading Rules indicator can be used for independent short-term trading in this stock.
When you open a stock data file, the Main Graph appears. This graph can be switched between four different magnification scales. These scales are denoted scale 1, 2, 4, and 8, which indicates their relative magnification value. (Each scale is magnified by a factor of two relative to the preceding one. Both the horizontal and vertical axes are magnified by the same factor, so the slope of the price graph is preserved.) When you first open the Main Graph, it is on scale 2. Each scale contains some different technical indicators, which are described here. You can move back and forth between scales using the blue arrows on the toolbar. You can also move back and forth between blocks of the data using the magenta arrows.
By the way, you can see all the graphs with either a black background or a white background, using the Toggle Dark Colors button on the Main Window toolbar. The black or white backgrounds use a different set of colors for the different features of the graphs. Generally, the colors for the black background are the dark versions of the colors for the white background. The black background is on by default. Lastly, one nice feature of the Main Graph is that, if you rest the mouse pointer at any point in the graph, a tool tip pops up, which lists the price level at that point and the date. This is very handy for finding the price and date of any point on the graph, without having to refer to the Stock Data list.
This is the long-term view of the stock data. Each day of data occupies one pixel of the screen, so there is no tick for the closing price on this scale. The future projection, with error bars, is the blue area to the right of the graph. On this scale, a long-term trend line is displayed which is a robust straight-line fit to the data (minimizing the sum of the absolute deviations from the line). This is shown as the centerline, in dark yellow. On either side of this line are two sets of Bollinger Bands, at one standard deviation (dark cyan) and two standard deviations (dark magenta) away from the centerline, respectively. These may be used to gauge the relative long-term variations of the price away from the long-term robust trend line. This graph is good for seeing the long-term trend of the price data at a glance.
This is the scale which first appears when a stock data file is opened. On this scale, there are two pixels per trading day. Each vertical bar ranges between the high and low for the day, and there is a horizontal tick for the closing price. If you look closely, underneath the data bars is a dark blue curve, representing the N-day (acausal) smoothing curve of the price data, where N is the time horizon that you have selected (in the Trading and Portfolio Parameters dialog box). To the right is the Price Projection, which is the output of the Linear Prediction filter, and the vertical blue bars are the one standard deviation error bars for the projection. By analogy with the Random Walk, they can be seen to grow approximately as the square root of the number of days in the future. The dark yellow curve is a 512-day (acausal) smoothing of the price data. On either side of this curve, in dark cyan and dark magenta, are the Bollinger Bands corresponding to one and two standard deviations, respectively, away from the center curve.
Featured prominently in this scale are the buy/sell points, which are the green and red arrows. These show the optimum points to buy and sell, given the selected time horizon, and correspond to the positive/negative going zero crossing points of the Velocity indicator (on the middle pane of the Harmonic Oscillator splitter window). These green and red arrows are represented in all the splitter windows as green and red vertical lines, and they serve to line up all the features on the graphs, as well as indicate the optimum buy/sell points on this time scale. The green and red arrows in the Price Projection are estimated buy/sell points, based on the Price Projection.
This graph is basically the same as scale 2, except a factor of two larger. There are four pixels per data point on this scale. This makes it easier to see the short-term price fluctuations. The main difference from scale 2 is that, instead of displaying the buy/sell points, it displays the buy/sell signals. The buy/sell signals are ranges of buy points and sell points, designed for setting limit orders, with the starting point in each range of buy/sell signals marked as the buy/sell point. It will be noticed that the buy points are a little below the N-day smoothing of the prices, and the sell points a little above. The degree that the buy/sell signals are below/above this N-day smoothing curve is set by the Threshold control on the Trading and Portfolio Parameters dialog. The range over which the buy/sell signals extend, corresponding to a range of values of the Relative Price indicator, is set with the Range control in this dialog. As just stated, the buy/sell signals may be used as a guide for placing optimal buy/sell limit orders.
This is the largest scale of the four graph scales. This scale uses eight pixels for each day of data. It will be noticed that this scale incorporates Candlestick Charting rather than the more usual bar charting of the other scales. The Candlesticks provide a way to display the high, low, close, and open prices, whereas with the bar charting the open price is not displayed. The Candlestick consists of a colored rectangle superimposed on a vertical line. The ends of the vertical line mark the high and low prices for the day, as before. However, the upper/lower edges of the rectangle mark the open/close or the close/open prices. If the close is higher than the open (an up day), the rectangle is colored sky blue, while if the close is lower than the open (a down day) the rectangle is colored dark blue. There is a whole set of technical patterns associated with and unique to the Candlesticks, which can be found in books devoted to Candlestick Charts (see also an appendix to Pring’s book on Technical Analysis [Pring (1991)]). Also displayed on this scale are the buy/sell signals that were actually triggered, meaning that the low price reached down to the buy signal or the high price reached up to the sell signal. (These are displayed using little green/red triangles.) From this you can tell the relative frequency with which these buy/sell signals were actually triggered (with the benefit of perfect hindsight, of course), and use this to set the Threshold and Range controls appropriately. For the future projection, all the projected buy/sell signals are displayed as green/red rectangles. All the other features of the graph, such as Bollinger Bands, are the same as with the other scales (except that the N-day smoothing curve is not shown on this scale). This is the best scale to use to study the price action for each individual day.
It should also be mentioned that the logarithmic volume appears at the bottom of each graph, relative to the mean value of the logarithmic volume. You can also display a horizontal line anywhere in the graph simply by pointing the mouse to that price level and left-clicking. You can draw a horizontal line for a given price using the Horizontal Line button on the toolbar. You can also insert an exponential Moving Average (of the prices relative to the 512-day smoothing curve) using the Moving Averages toolbar button. You can select a color for the horizontal line or exponential MA by using the Custom Colors button. Finally, you can toggle the buy/sell points and signals on and off using the Buy/Sell Points button. You can restore the graph to its default appearance using the Restore Data button.
Apart from the Main Graph, QuanTek displays nine technical indicators at a time, in three different splitter windows. These three splitter windows are called Harmonic Oscillator, Momentum Indicators, and Trading Rules. These nine technical indicators are designed to display different, yet compatible, aspects of the technical state of the stock data. Theoretically, the stock data contains roughly equal mixtures of Fourier components, or “waves”, of all different frequencies (although in some cases there can be cycles of a specific frequency, temporarily). Hence you can choose essentially any time horizon or scale you want, although some time scales will work better than others. After having chosen a time horizon, the technical indicators must all be smoothed according to the same smoothing filter, with the same time horizon. (Note that the smoothing time scale setting of the Momentum indicators is an independent setting from the time horizon.) Then the buy/sell points can be derived from these smoothed indicators, and they should be compatible between the different indicators. This is the purpose of the nine indicators – to arrive at a set of compatible buy/sell points and signals and trading rules. The Trading Rules indicator is built directly from the Momentum indicators, which in turn are designed by you, the trader, to show a peak in correlation with the future returns on some specified time horizon. Then the actual short-term Trading Rules are derived directly from this indicator, so in this way you have the best chance of arriving at a set of effective short-term trading rules.
Note: The Momentum indicators are defined to be analogous to the Velocity indicator of the Harmonic Oscillator, which are both supposed to represent the Returns or rate of change of price. However, the Velocity indicator is obtained from an acausal smoothing of the price, so should be “in phase” with the price changes or present returns. In other words, if the Velocity is positive, this denotes price increase, so you want to be in a long position, and if the Velocity is negative, this denotes price decrease, so you want to be in a short position. (Hence the 1-day position should be proportional to the Velocity indicator.) Thus the buy point should be when the Velocity indicator of the Harmonic Oscillator crosses zero in a positive direction (Z+), and a sell point should be when the Velocity indicator of the Harmonic Oscillator crosses zero in a negative direction (Z–). These buy/sell points are indicated by green/red arrows or lines in the Main Graph and splitter windows, respectively. However, in the case of the Momentum indicators and Trading Rules indicator, it is the N-day forward moving average that is displayed, and these are supposed to estimate the N-day future returns, where N is the time horizon for trading. Hence these indicators, and also the N-day future returns display itself, will be ahead of the Velocity indicator by approximately N/2 days. So the buy points should be well into positive territory, near a maximum, and the sell points should be well into negative territory, near a minimum, on these indicators that estimate the N-day future returns. This is a good way to judge whether the Momentum indicators have been chosen correctly. Also note that the agreement between the N-day forward moving average Trading Rules indicator and the N-day future returns display need not be perfect. Even a small correlation between the two can lead to substantial gains in short-term trading.
On the Harmonic Oscillator splitter window are three technical indicators that are fixed (not custom designed). The main purpose of these three indicators is to compute the buy/sell signals and points. These three indicators are called the Relative Price, the Velocity, and the Acceleration. The Relative Price is the (logarithmic) price, smoothed on a time scale equal to the time horizon, minus the log price smoothed with a long time scale of 512 days (the long-term yellow smoothing curve on the Main Graph). Thus it is, in essence, a smoothed and detrended price. As is well known, the buy points are supposed to be price minima and the sell points should be price maxima (“Buy Low – Sell High”!). Hence the indicated buy points should pass through the minima of this indicator, and the sell points should pass through the maxima. (Note this is only true for acausal smoothing. Causal smoothing would introduce a time lag.) The Velocity indicator is obtained by computing the smoothed first derivative of the log prices using the Savitzky-Golay smoothing filter. At price minima and maxima, the first derivative is zero, and hence the Velocity indicator should also be zero. At price minima, corresponding to buy points, the first derivative will be increasing through zero, and at price maxima, corresponding to sell points, the first derivative will be decreasing through zero. Thus for the Velocity indicator, the buy points should line up with the zero-crossings moving upwards (Z+), while the sell points should line up with the zero-crossings moving downwards (Z–). The Acceleration is obtained by computing the second derivative of the log prices using the Savitzky-Golay smoothing filter. At price minima, the Acceleration should reach a positive peak, because the upward curvature of the prices is maximum. At a price maximum, the Acceleration should reach a negative peak because the downward curvature of the prices is maximum. Hence the buy points should line up with the maxima of the Acceleration indicator, while the sell points should line up with the minima of the Acceleration indicator. These three indicators thus provide (approximate) markers for the three Momentum indicators and other indicators, showing the buy/sell points where the (smoothed) returns should change from negative to positive (buy) and from positive to negative (sell), respectively. Note that for the N-day forward moving average Momentum and Trading Rules indicators, the buy/sell points should be near the maxima/minima of these indicators, since they are N/2 days ahead of the Velocity indicator.
The buy/sell signals and points are thus obtained from the Harmonic Oscillator indicators by the following rule: A buy signal is shown when the Relative Price is negative and below a certain level, the Velocity is positive, and the Acceleration is positive. It can be seen that these last two conditions specify the buy signal to be within one-quarter cycle starting with the minimum of the Relative Price indicator (if it were sinusoidal). A sell signal is shown when the Relative Price is positive and above a certain level, the Velocity is negative, and the Acceleration is negative. It can be seen that these last two conditions specify the sell signal to be one-quarter cycle starting with the maximum of the Relative Price indicator (if it were sinusoidal). The level and range of the buy/sell signals are controlled by the Threshold and Range controls on the Trading and Portfolio Parameters dialog box. The buy/sell points are the first of a series of buy/sell signals, and are denoted by the green and red arrows on scale 2 of the Main Graph, and the vertical green and red lines in all the splitter windows. You can see that these line up exactly with the relative minima/maxima of the Relative Price indicator, the positive/negative zero crossings of the Velocity indicator, and the relative maxima/minima of the Acceleration indicator, as they should. How far a series of buy/sell signals extends beyond the buy/sell points depends on the setting of the Range control. The buy/sell signals indicate an optimum range of buy points and sell points, starting with the buy/sell points.
In the Momentum Indicators splitter window, you can display three Momentum indicators of your choice in the three panes of this window. To do this you use the Technical Indicators and Correlation Test – Indicators dialog boxes to design and test a wide variety of oscillator-type indicators using the stock price data. These three Momentum indicators are denoted Momentum 0, Momentum 1, and Momentum 2. These oscillators are constructed from smoothings of the past stock data, using the Savitzky-Golay smoothing filter, with acausal smoothing. These indicators encompass most of the usual oscillator-type technical indicators. These three Momentum indicators are adjusted in phase so that they show a positive correlation peak in the Correlation Test – Indicators dialog, with the future returns. Then the three indicators may be added together in any relative proportions using three slider bars in the Trading Rules Settings dialog box (for each stock), to yield the Trading Rules indicator. This Trading Rules indicator has been designed (by you!) to show the maximum correlation with the future N-day returns, where N is your chosen trading time horizon. This means that it is actually the N-day forward moving average Momentum indicators that are being tested for correlation with the N-day future returns, and so these N-day forward moving average indicators are the ones actually displayed in the splitter windows (along with the N-day future returns). For an approximate N-day holding period, the position should be set according to the Trading Rules indicator at the N-day buy/sell points.
If it were based on 1-day returns, the Trading Rules indicator should show a positive going zero crossing corresponding to a buy point, and a negative going zero crossing corresponding to a sell point. In other words, the Trading Rules indicator is what we call a Momentum indicator, which means that it behaves the same way as a Velocity indicator. However, the Momentum and Trading Rules indicators are representative of the N-day future returns, so we need to use their N-day forward moving average values. This means that the actual buy/sell points are after the positive/negative zero crossings of the Momentum and Trading Rules indicators, by approximately N/2 days. Hence, the zero crossings (and peaks and troughs) of the Momentum and Trading Rules indicators should (roughly) line up with each other, and the buy points should be roughly N/2 days after the positive going zero crossings, and the sell points should be roughly N/2 days after the negative going zero crossings of these indicators.
The bottom pane of the Trading Rules splitter window displays the N-day forward moving average Trading Rules indicator, which as we have stated previously, is a weighted sum of the three N-day forward moving average Momentum indicators displayed in the Momentum Indicators splitter window. The relative weights of the three Momentum indicators are adjusted using three slider bars on the Trading Rules Settings dialog box, for each stock. These three Momentum indicators are ones you have designed yourself using the Technical Indicators dialog box and the Correlation Test – Indicators dialog. They are designed to have maximum correlation with the future returns. The value of this (forward averaged) indicator is also displayed in the Short-Term Trades dialog box (to see this modeless dialog box, just right-click anywhere). This relative number ranges from –158% to +158%, and denotes the optimum relative position for short-term trading for the given time horizon, relative to the equity allocated for short-term trading in this stock. (In other words, it is a margin leverage for short-term trading in this particular stock. The ±100% points are set to be equal to the average absolute value of the Trading Rules indicator.)
The remaining two indicators on the Trading Rules splitter window should also be mentioned. In the middle pane is displayed the N-day forward moving average Returns, which is the daily returns, averaged over the next N days, where N is the time horizon. This graph is displayed for comparison with the N-day forward moving average Trading Rules (in the bottom pane), because the two are supposed to be correlated (according to the Correlation Test – Indicators display for the individual Momentum indicators). In the top pane is a N-day forward moving average Volatility indicator, which is the absolute value of the daily high-low price range, averaged over the next N days, where N is the time horizon. This indicator will be used in a future version of QuanTek which incorporates heteroskedasticity, or in other words, time-varying volatility, into the Price Projection.
There are two groups of slider bars in the Trading and Portfolio Parameters dialog box. These control the settings for the buy/sell signals and the Portfolio Optimization calculation. At the bottom of this dialog box is a list box to set the time horizon for trading, and a checkbox to specify the method of calculation of the Portfolio Optimization (Markowitz Method yes or no).
The left-hand group of two slider bars controls the display of the buy/sell signals. These buy/sell signals are displayed on scale 4 of the Main Graph. The buy/sell signals that are actually “triggered” are displayed on scale 8 of the Main Graph.
Threshold: This slider bar determines how high or low the price has to be to trigger a buy/sell limit order. The slider bar ranges from “high” to “low”. The threshold price is measured from the N-day smoothing curve of the prices on the Main Graph, where N is the time horizon, and is determined from the number of standard deviations of the price from this smoothing curve. The “high” setting corresponds to two standard deviations, so the limit order will be triggered very infrequently. The “low” setting corresponds to zero standard deviations, so a buy or sell order will be triggered almost every day that there is a buy/sell signal. The “high” setting corresponds to less frequent trading, and the “low” setting corresponds to more frequent trading.
Range: This slider bar controls the range of the Relative Price indicator over which a buy/sell signal is triggered. The range is from “min” to “max”. The “min” setting corresponds to at least two standard deviations of the Relative Price indicator from the zero line, and the “max” setting corresponds to zero standard deviations. On the “min” range setting, a buy/sell signal will be displayed only when the price is very near the extreme range of the Relative Price indicator. On the “max” range setting, a buy/sell signal will be displayed for practically every trading day that the Velocity and Acceleration indicators are positive/negative.
Time Horizon: This is a list box for setting the time horizon, which controls the time scale of smoothing of the Harmonic Oscillator indicators and the resulting buy/sell signals and points. It also controls the time scale of the N-day smoothing shown on the Main Graph. Also, the displayed Momentum indicators and Trading Rules indicator, as well as the N-day future Returns and N-day future Volatility, are constructed from an N-day forward moving average of these indicators, where N is the time horizon. The possible values of the time horizon are from 1 to 40 days, and this should be thought of as the typical holding period for short-term trading.
The right-hand group of two slider bars controls the settings for the Portfolio Optimization calculation. This calculation uses the estimated expected return and the measured volatility or risk (for each stock in the portfolio) to compute an Optimal Portfolio that maximizes returns and minimizes risk. Then the recommended number of shares and percentage of the equity for each stock is displayed in the Short-Term Trades dialog (along with the actual number of shares owned of each stock in the Core Portfolio, and the expected return.)
Margin Leverage: This specifies the (average) margin leverage that you want for the whole portfolio, given the total equity. By margin leverage, we mean the amount of money invested in the portfolio as a fraction of the equity. Then the optimal number of shares of each stock is computed based on the margin leverage. Generally, due to the way the optimization is performed, the actual margin leverage invested will be a little less than that specified. It should be equal to that specified if the percentage of equity invested in each stock turned out to be equal. If a large percentage of the equity were invested in one stock, then the total margin leverage would be substantially less than that specified. (We view this as beneficial from the point of view of risk reduction.)
Risk Tolerance: This is the other parameter in the Portfolio Optimization calculation. In order to know what relative weight to give to the expected return versus the risk, the portfolio optimization routine needs to know your degree of risk aversion. The opposite of this is your risk tolerance, which is your willingness to tolerate risk for the sake of greater returns. Setting the slider on “min” results in the least possible variance in the total portfolio return (risk), at the expense of the mean value of the return (expected returns). Setting the slider on “max” basically results in the variance of returns (risk) being ignored, and the proportion of the portfolio invested in each stock is essentially proportional to the expected returns alone (relative to the other stocks in the portfolio).
Use Markowitz Model: This checkbox at the bottom of the dialog is used to specify whether to use the Markowitz Model or a Factor Model. Supposedly, the Markowitz method is too slow for a portfolio with more than a few stocks, although we have not found any such problem. Normally, the Factor Model is used as an approximation to the Markowitz Model, because it is faster to compute. However, we see no real reason not to use the Markowitz Model for the portfolio optimization. At present, the Factor Model has not been implemented, and the Markowitz Model is used whether the checkbox is checked or not. In future versions of QuanTek, a Factor Model may be implemented, with the CAPM, making use of a reference index which you select from the Stock Group of securities.
The Trading Rules Parameters dialog box is available from the Technical Indicators dialog on the Main Graph toolbar for each stock data file. It has three slider bars that control the proportion of the three Momentum indicators that make up the Trading Rules indicator for each stock. The three Momentum indicators are displayed in the Momentum Indicators splitter window, and the Trading Rules indicator is displayed in the bottom pane of the Trading Rules splitter window.
Momentum 0: This controls the proportion of the Momentum 0 indicator in the Trading Rules indicator. In the default settings, the Momentum 0 indicator is a Relative Price indicator.
Momentum 1: This controls the proportion of the Momentum 1 indicator in the Trading Rules indicator. In the default settings, the Momentum 1 indicator is a Velocity indicator.
Momentum 2: This controls the proportion of the Momentum 2 indicator in the Trading Rules indicator. In the default settings, the Momentum 2 indicator is an Acceleration indicator.
The Trading Rules indicator, constructed as a weighted sum of the three Momentum indicators, is supposed to be a function of the past data, which has the maximum positive correlation with the future returns over the trading time horizon that you have chosen. The indicator is constructed in such a way that it serves as an estimate of the 1-day returns over an N-day time horizon, and should be in phase with the 1-day returns. Hence, day-by-day, the optimum 1-day position is simply to vary the position in proportion to the Trading Rules indicator. Then the position will be directly in proportion to the expected 1-day return, and this position can be adjusted each morning at the open to maintain the optimum position. However, for N-day trading, we want to establish the position and then hold it over the N-day time horizon. This means that we should use the N-day forward moving average Trading Rules to establish the position. This relative N-day position, as given by the N-day forward moving average Trading Rules indicator, is shown in the right-most column of the left-hand list box of the Short-Term Trades dialog.
Changing the position every day might be a practical trading strategy for some short-term traders. This strategy might actually reduce risk, because the position held in the stock is varied slowly and smoothly, rather than suddenly. In other words, this is the trading strategy which will result in the minimum variance of the position held, and hence the minimum variance of the return (risk) from the trading strategy. If the trading time horizon is 1 day, then the position can be varied smoothly each day, corresponding to the smoothing time scale of 1. However, most traders would probably want to buy or sell roughly every N days, if the trading time horizon is N days. Then, the indicated buy/sell points may be used to set the long/short position over the holding period, rather than smoothly on a daily basis. The amount to buy/sell will then be proportional to the value of the N-day forward moving average Trading Rules indicator at the buy/sell points. This is for short-term, N-day trading in an individual stock. For longer-term investing, the position can be adjusted to that indicated for the Optimal Portfolio at the buy/sell points.
It is nice to have quick access to the buy/sell signals and other numbers for trading purposes. This information can be found in the Short-Term Trades dialog box, which can be viewed at any time, from anywhere in the QuanTek program, just by right-clicking. This dialog box displays the current long-term investment position, in shares held, for each stock in the portfolio. Then the recommended number of shares, or Core Position, based on the Optimal Portfolio calculation, is displayed. Next the recommended position as a percentage of portfolio equity is displayed. After that, the estimated expected return (annualized) over the next 100-day time interval is shown. This is based on the 512-day smoothing of the Price Projection from the Linear Prediction filter, 100 days in the future, and is expressed as an annual compounded gain or loss, in percent. The computations in the Optimal Portfolio calculation are based directly on these estimates of future return. After this information, the current buy/sell/hold recommendation for each stock is displayed, along with the recommended price. The buy and sell prices are set at a certain threshold below or above the smoothed price, and the price for the hold recommendation is just the smoothed price itself. The buy/sell signals depend on the settings for the Threshold and Range trading controls. The current ranges of the buy/sell signals are displayed on the Main Graph, on scale 4. Finally, as discussed above, the relative value of the N-day forward moving average Trading Rules indicator is displayed (labeled N-day, where N is the current setting of the time horizon). The value of this should be interpreted as the relative amount of trading equity (allocated for that stock) that should be invested in that stock at that particular time. As stated before, this indicator ranges from –158% to +158%.
On the right-hand side of the Short-Term Trades dialog, there is a list box showing a set of prices and a set of percentages. In the middle row of the list box, a price is highlighted. This is the estimated or projected closing price for next-day’s close, based on the 1-day Price Projection from the Linear Prediction filter. This filter is used to estimate the 1-day return from the most recent closing price to the next close, and the resulting estimated closing price is highlighted in the center row of this Day-Trades window. In order to accommodate the widest possible variety of day-traders and their trading methods, this window has not incorporated any specific trading rules. Rather, a list of prices surrounding the center price (estimated closing price) is given, and to the right of it is a list of percentages. These percentages are multiples of 0.1%, and correspond to the prices on the left, which differ from each other by 0.1%. (Actually, the prices on the left are constant multiples of each preceding price, starting from the center, and the percentage difference is 0.1%. Thus the right-hand scale is really a logarithmic scale, for the prices listed on the left.) However, the percentages increase downward rather than upward, indicating the (approximate) percentage price difference between the estimated closing price and the selected price. The way to use this scale is simple. The percentages indicated should be (roughly) proportional to the amount invested in a day-trading strategy, at each give price throughout the day. The amount to invest for each percentage change in price is up to you, the trader. All you do is invest more when the price goes down, and less when the price goes up, in some proportion to the percentage scale on the right.
Peter J. Brockwell & Richard A. Davis, Time Series: Theory and Methods, 2nd ed.
Springer-Verlag, New York (1991)
John Y. Campbell, Andrew W. Lo, & A. Craig MacKinlay (CLM),
The Econometrics of Financial Markets,
Princeton University Press, Princeton, NJ (1997)
Sheldon Natenberg, Option Volatility & Pricing,
McGraw-Hill, Inc., New York, NY (1994)
Edgar E. Peters, Chaos and Order in the Capital Markets,
John Wiley & Sons, Inc., New York, NY (1991)
Edgar E. Peters, Fractal Market Analysis,
John Wiley & Sons, Inc., New York, NY (1994)
William H. Press, Saul A. Teukolsky, William T. Vetterling, & Brian P. Flannery (NR),
Numerical Recipes in C, The Art of Scientific Computing, 2nd ed.
Cambridge University Press, Cambridge, UK (1992)
Martin J. Pring, Technical Analysis Explained, 3rd ed.,
McGraw-Hill, Inc., New York, NY (1991)
Tonis Vaga, Profiting From Chaos
McGraw-Hill, Inc., New York, NY (1994)