Sunday, November 18, 2007

Swing indicator - a deeper look...





-- THIS IS AN ADVANCED TOPIC ---

The 2 snapshots above give the 3 available algorithms showing good potential in capturing market dynamics by way of a no-lag realtime smoothing algorithm. Our Swing indicator uses the Lag128 algorithm, despite Lag128T being 'theoretically' the most accurate one statistically. One possible reason is stats are often simply wrong when it comes to time series. One could debate about this non-stationarity, fat-tail distributions etc, but that is besides this topic and could be a little difficult to grasp. In any case, the two calculations may sometimes come pretty close. I would certainly prefer Lag128T to be as good as Lag128, as it calculates much much faster.

Obviously the optimised algorithm in Lag128 has been tweaked for time series, in particular to favour a low error level on the most recent bars (in other words, mistakes should rather belong to the past and be ignored). Insisting on a good model over recent bars provides far better patterns overall.

The last algorithm LombSin is very very processing intensive and should be used with caution. It goes further than the other 2 in extracting salient cycles along with the phase, thus allowing a price projection over a few bars. That would seem great if only such cycles had any chance to 'survive' over time. A lot of serious physicists will indeed tell you that cycles are very elusive or show you an instantaneous picture of what cycles have just looked like, and have no predictive value whatsoever. I would tend to agree.

However, i have noticed that when the LombSin error level falls close to the Lag128 error level (which is close to optimal), one can fit cycles correctly and predict at least a few bars ahead. Having said that, one may also just as well get that information from other indicators (MM, Fib etc) in our toolset.

Retrieving Calculations (API)

A number of accessors are available in the API to retrieve various calculations done by indicators and other analysis techniques. The most commonly used are :

BV_RetrievePivotsPrices
BV_RetrievePivotsIdx

To extract pivot info from the DLL after the Swing indicator calculates realtime pivots.

The API allows retrieving such info in a separate C++ program, but it is also possible to do the same within the TradeStation environment. Two sample indicators exist for that purpose:

RetrievePivotPrices
RetrievePivotInfo

The first one is very simple as it only prints pivots prices (normalised or original prices) in the TS debug window (View menu then "EasyLanguage Output Bar").



The second one (which can be improved) goes a little further and tries to calculate Fibonacci retracement and expansion levels when possible. A distinct leg is necessary to calculate retracement levels (38.2%, 50%, 61.8%), and a second leg i.e. a 3rd pivot is needed to calculate expansion levels (also called COP, OP and XOP levels). COP is a 61.8% expansion, OP a 100% expansion, and XOP a 161.8% expansion. Levels are plotted on the right hand side of the screen (L1 to L5). One shall recognise that:
L2 = Fib COP,
L3 = Fib OP,
L4 = Fib XOP.

Saturday, November 17, 2007

Standard Settings


Here are the settings used in the StandardSet analysis group.

1) The AdLag64StoK_MTF a.k.a. MTFS is the smoothed version of the AdStoK_MTF (which is also the regular MTFS indicator). Smoothing is done through superimposition of the regular MTFS with its self-memory variation. The mix is hard-coded.

The settings do not need to be changed at all, but some users may feel more at ease with a number of bars of 8 (faster), or 24 (slower). The acceleration (adaptation to changes in volatility) is sometimes more difficult to set, so it is best leaving it unchanged. Accel values generally range from 0 to 0.5, but double adaptiveness is optimal around 0.2 to 0.25.

2) AdStoK_MTF : as above
3) HA_ModPB colour paintbars: leave unchanged
4) HHLL_tl HighestHighs-LowestLows trend lines: use only with intraday data
5) LombEntropy (calculates a Lomb-Scargle spectrum then uses dominant cycle to calculate Entropy): no change, except a Time Frame Multiplier which should be left unchanged. A time frame multiplier of 2 or 3 may detect longer cycles, but this is generally irrelevant.
6) MM (MM lines): leave unchanged
7) MM target calculated on level breakout. No change needed (display code not optimised)
8) RegisterSymbol : no parameter, but this indicator is ESEENTIAL to proper use of the DLL, and must always be placed before the Swing2 indicator
9) Swing2: automatic pivot detection. TFmult must be 1, 2 or 3 (cf previous post "Common mistake with Swing2")

The StandardSet analysis group be can applied automatically on new charts. Please note that since some calculations are computing intensive, there have been (rare)occasions of sync problems. In such case, the indicator that would not plot correctly needs to be turned off and on again.

A common mistake with Swing2 indicator

This indicator purposely does not use "automatic barsback" calculation. The reason is that TS goes through the code to find which setting is appropriate when loading the chart. As this indicator is fairly computing intensive and as the number of bars is known (multiple of 128 bars), it is up to the user to set this parameter properly.

This setting never changes, and can (and should) be saved in an Analysis Group once for all.

By default, the indicator uses a TF multiplier of 1 (128 bars), so only change it to a number over 256 for TFm = 2 or over 384 for TFm = 3. The indicator will not return an error code if there are not enough bars on your chart, and will just cancel calculations.



As a reminder, SD is the Search Depth parameter (0 for default, 1 for refined in most cases), and Fuzzy Neighbourhood allows finding fuzzy pivots, 1 being 'crisp' and the parameter being generally up to 3 or 4 max.

Monday, November 5, 2007

Some thoughts...

Who uses this indicator toolset?

The technique outlined in this blog, in its current version, is suitable for discretionary traders. An API is available and other tools can be developed inside or outside TradeStation. Some of those tools may be published or sold separately at some point, but it is for the time being more important to me to deliver interesting analysis tools, independent on each and everyone's trading strategy and money management.

How did this technique come about?

Well, 15 years of experience, system development, trading have certainly helped me eliminate a few dead ends, hence a few guidelines here given, which may suprise a few 'dogmatic' traders, shaped by most trading tools commercially available... including TradeStation.

Most indicators, either custom made or built in trading platforms, do calculate one or several mathematical outputs at each bar. One may also (correctly) say that prices are noisy, chaotic in nature, which obviously make "market reading" rather difficult. However, in my opinion, the problem is elsewhere... Indeed, most of the time, there is simply nothing to read in the market, and more pragmatically, buying and selling are essentially discrete decision points. This simply means that trading is inherently dependent on an event driven technique. In other words, if you wish to crunch large amount of numbers in any crude or sophisticated way, irrespective of the rare salient events where effective decision making is only sensible, well... you might just be wasting your time... and LOTS of so-called trading gurus are quite willing to take you for a ride along the meanders of the never ending quest of the Holy Grail...

Any sound decision can only make sense in perspective or context, unless you stick to quick scalping or to the simplest reversal strategy, assuming you get your pivot calculations right too.The best way to represent context is to work in a multi-time frame environment (2, 3 or even 4 time frames). It seems obvious that a move in your time frame of choice, determined by indicators lining up nicely either long or short, can only show strength if supported by a similar set-up in a higher time frame. Choice of adequate time frames may however not always be easy. For synch purposes, time frames will often be in multiples like 1, 2, 4, 8 minutes. In addition, some will prefer finding confirmation from 2 or more higher time frames. Others may find more suitable to balance their time frame analysis with one higher and one lower time frame. It is likely that using a conservative rule base over 4 time frames can reduce trading ambiguity to next to zero.

There are always times of congestion, relative market inactivity, which will inevitably affect indicator calculations. One way to reduce such impact on indicator reading is to opt for tick charts or volume charts, or alternative market representations like Renko charts.
Markets are highly dynamic. Prices are chaotic, non stationary etc... Still, this is no reason to try and throw everything but the kitchen sink into your favorite trading platform. Do not forget to still be able to fully understand the method you are trying to put together... You are the trader... don't ever forget this subtle point. Successful traders always know the finest details in trading calculations.

Markets are chaotic, and contain fractal features. Once you have found a sound technique, it should work the same on another set of time frames, as well as on other financial instruments. This is the 'acid test'. Many models just fit one instrument on a single time frame, and are bound to fail sooner or later. There may of course be some adjustments needed (not more than a few degrees of freedom if possible) to adapt from one instrument to the next, but not more than that.

More to come soon... and comments welcome as always...
bv

Saturday, November 3, 2007

MurreyMath - Gann ... More details

This article was previously included within a RUT commented chart on the Market Snapshot blog.


MM Line Interpretation

Murrey Math is a trading system for all equities. This includes stocks, bonds, futures (index, commodities, and currencies), and options. The main assumption in Murrey Math is that all markets behave in the same manner (i.e. all markets are traded by a mob and hence have similar characteristics.). The Murrey Math trading system is primarily based upon the observations made by W.D. Gann in the first half of the 20th century. While Gann was purported to be a brilliant trader in any market his techniques have been regarded as complex and difficult to implement. The great contribution of Murrey Math (T. H. Murrey) was the creation of a system of geometry that can be used to describe market price movements in time. This geometry facilitates the use of Gann's trading techniques.

The Murrey Math trading system is composed of two main components; the geometry used to gauge the price movements of a given market and a set of rules that are based upon Gann and Japanese candlestick formations. The Murrey Math system is not a crystal ball, but when implemented properly, it can have predictive capabilities. Because the Murrey Math rules are tied to the Murrey Math geometry, a trader can expect certain pre-defined behaviours in price movement. By recognizing these behaviours, a trader has greatly improved odds of being on the correct side of a trade. The overriding principle of the Murrey Math trading system is to recognize the trend of a market, trade with the trend, and exit the trade quickly with a profit (since trends are fleeting). In short, "No one ever went broke taking a profit".

The Murrey Math geometry mentioned above is "elegant in its simplicity". Murrey describes it by saying, "This is a perfect mathematical fractal trading system". An understanding of the concept of a fractal is important in understanding the foundation of Murrey Math. For readers interested in knowing more about fractals I would recommend the first 100 pages of the book,"The Science of Fractal Images" edited by Heinz-Otto Peitgen and Dietmar Saupe. The book was published by Springer-Verlag, copyright 1988. An in depth understanding of fractals requires more than "8'th grade math", but an in depth understanding is not necessary (just looking at the diagrams can be useful).

The size (scale) of basic geometric shapes are characterized by one or two parameters. The scale of a circle is specified by its diameter, the scale of a square is given by the length of one of its sides, and the scale of a triangle is specified by the length of its three sides. In contrast, a fractal is a self similar shape that is independent of scale or scaling. Fractals are often constructed by repeating a process recursively over and over.

The next question, of course is, "What does a fractal have to do with trading in equity markets?" Imagine if someone presented you with a collection of price-time charts of many different equities and indices from many different markets. Each of these charts has been drawn using different time scales. Some are intraday, some are daily, and some are weekly. None of these charts, however, is labelled. Without labels, could you or anyone else distinguish a daily chart of the Dow from a weekly chart of IBM, or from an intraday chart of wheat prices. Not very likely. All of these charts, while not identical, appear to have the same general appearance. Within a given time period the price moves some amount, then reverses direction and retraces some of its prior movement. So, no matter what price-time scales we use for our charts they all look pretty much the same (just like a fractal). The "sameness" of these various charts can be formally characterized mathematically (but this requires more that 8th grade math and is left as an exercise to the interested reader).

Gann was a proponent of "the squaring of price and time", and the use of trend lines and various geometric angles to study price-time behavior.Gann also divided price action into eighths. Gann then assigned certain importance to markets moving along trendlines of some given angle. Gann also assigned importance to price retracements that were some multiple of one eighth of some prior price movement. For example, Gann referred to movement along the 45 degree line on a price-time chart as being significant. He also assigned great significance to 50% retracements in the price of a commodity. The question is, "A 45 degree angle measured relative to what?" "A 50% retracement relative to what prior price?"

These angle or retracement measurements are made relative to Gann's square of price and time. Gann's square acted as a coordinate system or reference frame from which price movement could be measured. The problem is that as the price of a commodity changes in time, so must the reference frame we are using to gauge it. How should the square of price and time (the reference frame) be changed so that angles and retracements are measured consistently?
This question is one of the key frustrations in trying to implement Gann's methods. One could argue that Gann recognized the fractal nature of market prices changing in time. Gann's squaring of price and time, however, did not provide an objective way of quantifying these market price movements. If one could construct a consistent reference frame that allowed price movement to be measured objectively at all price-time scales, then one could implement Gann's methods more effectively.

This is exactly what Murrey Math has accomplished.For more details, it is recommended to study Murrey Math literature etc (http://www.murreymath.com/)
Here below is a short description extracted from a document published a few years ago by Tim Kruzel , which since seems to have disappeared from the face of the WWW.·

Commented chart (audio soundtrack)

Here is a commented audio soundtrack (8m25s) to complement the Oct 21st SPY chart.

The audio/AVI file (~24MB) and can be downloaded here.
The audio/MP3 file (~8MB) can be downloaded here.
The purpose is to teach traders how simple it can be to read charts using this TradeStation technique. The purpose of the commented charts published on Market Snapshot is to develop a 3 to 5 bar outlook, mostly at daily level. One therefore tries to estimate where the market is going about 1 week ahead. Since this was done on Oct 21st, I here also include the chart dates Oct 24th, which confirms the retracement scenario (it was admittedly easy).


Please note that these indicators can be used unchanged on various symbols and time frames. The technique was designed to remain as simple as possible so that decision making remains quick and as unambiguous as possible. It must also be noted that all indicators feed an API allowing developers to build their own rule set to contribute to even easier decision making.