Decoding The Hidden Market Rhythem

Book Part 2 “Metonic Cycles” now available

I am proud to inform you about the release of the new Book Part 2 “Metonic Cycles”. A lot of content and examples have been added – so it is a real new book compared to the first initial release in 2010. Endless nights and hours of work have gone into it.

This second book of our series introduces correlations between markets and external energy cycles like gravity and geomagnetism. Digital signal processing techniques are used to reverse engineer Gann’s master cycles, resulting in a 100% mechanical cycle-based trading system that has shown a compounded growth rate of 20% per year over the last 30 years when back-tested using the Dow.

In addition, it introduces new non-linear indicators and reviews the significance of a cyclic sentiment predictor for the Dow Jones Industrial Average Index. To that end, using daily data covering the period from 1935 to 2013, ancient cycles are condidered as predictors to forecast daily sentiment for years ahead of time.

Forecasts, plotted as an non-linear indicators, are transformed into a mechanical trading rule whose profitability has been evaluated against the major markets buy-and-hold performance of 1990-2013. The results suggest that trading based on non-linear indicators (“cyclic time”) significantly outperforms the linear-time based indicator strategies in nearly all performance metrics, including net return, profitability, and Sharpe ratio.

Includes TradeStation / EasyLanguage code to rebuild indicators and use the trading system. Generic pseudo code and step-by-step guidelines included.

The book is available via CreateSpace / Amazon. Order your book here:

HOW-TO: Scripting AND/OR/IF rules to generate trade entry/exit signales

As the scripting engine was updated for performance reasons, AND/OR conditions must now be coded in mathematical terms. The follwing examples show how to code AND/OR statements to produce final trade entry/exit signals in comparison to the “old” scripting format.

 


 

Example 1 – Bollinger Bands Script:

Old Version:

SET BOTTOM = BBB(CLOSE, $N3, $N4, EXPONENTIAL)
SET TOP = BBT(CLOSE, $N3, $N4, EXPONENTIAL)
((REF(CLOSE, 1) > REF(TOP, 1)) AND CLOSE < TOP) OR CLOSE < BOTTOM * 0.98


New Version:

SET BOTTOM = BBB(CLOSE, $N3, $N4, EXPONENTIAL)
SET TOP = BBT(CLOSE, $N3, $N4, EXPONENTIAL)
SET s1 = ((REF(CLOSE, 1) > REF(TOP, 1)) + (CLOSE < TOP))
SET s2 = (CLOSE < (BOTTOM * 0.98))
SET sellsignal = (s1>1) + (s2>0)
if (sellsignal>=1,true,false)

 


 

Example 2 – Simple CSI Turnover Script:

Idea: Generate sell signal if indicator is above dynamic OB line and turns down and generate buy signal if indicator is below dynamic OS line and turns up. Here is the script to capture the turns of the indicator if it is above/below the bands:

 

Buy Script:

#set values
set csi = lvtcsi(40,0.1)
set lowband = lvtcsilb(40,0.1)

#generate critea
set oversold = csi < lowband
set upturn = CROSSOVER(csi> REF(csi,1), 0.5)

#build AND signal condition
set buysignal = upturn + oversold

#check if signal was generated
if (buysignal=2,true,false)

 

– SHORT BUY SCRIPT VERSION –

set csi = lvtcsi(40,0.1)
set buysignal = (CROSSOVER(csi> REF(csi,1), 0.5) + (csi<lvtcsilb(40,0.1)))
if (buysignal=2,true,false)

 

Sell Script:

#set values
set csi = lvtcsi(40,0.1)
set highband = lvtcsiub(40,0.1)

#generate critea
set overbought = csi > highband
set downturn = CROSSOVER(csi< REF(csi,1), 0.5)

#build AND signal condition
set sellsignal = downturn + overbought

#check if signal was generated
if (sellsignal=2,true,false)

 

– SHORT SELL SCRIPT VERSION –

set csi = lvtcsi(40,0.1)
set sellsignal = (CROSSOVER(csi< REF(csi,1), 0.5) + (csi>lvtcsiub(40,0.1)))
if (sellsignal=2,true,false)

 

Example 3 – Combination of Indicators


OLD SCRIPT:

TREND(EMA(CLOSE,20),15) = DOWN
AND TREND(MACD(13,26,9,SIMPLE),5) = DOWN

 

NEW SELL SCRIPT:

# setup indicators
SET T1 = TREND(EMA(CLOSE,20),15)
SET T2 = TREND(MACD(13,26,9,SIMPLE),5)

# build final signal with AND condition
# make sure that no UP or SIDEWAYS trend is active in T1 AND T2
set sellsignal = (t1<3) + (t1>1) + (t2>1) + (t2<3)

# evaluate to true if AND statement is given (sellsignal must be =4)
if(sellsignal=4,true,false)


[…]
You must have membership level. Please go to whentotrade.com to configure your account.
[…]

Nonlinear Science: Evidence of synchronous, decadal to billion year cycles in geological, genetic, and astronomical events

Stephen Puetz has done a lot of work on cycles reserach and cycles impacting financial datasets. I highly recommend his book “Unified Cycle Theory” and his current work. He has recently published a new article in the Journal “Chaos, Solitons & Fractals” which aims to be a leading journal in the interdisciplinary field of Nonlinear Science, and Nonequilibrium and Complex Phenomena.

He also states the dynamic nature of cycles in this article:

“Period variability – Many natural cycles exhibit considerable variation between repetitions. For instance, the sunspot cycle has an average period of ∼10.75-yr. However, over the past 300 years, individual cycles varied from 9-yr to 14-yr. Many other natural cycles exhibit similar variation around mean periods. In this scenario, a time-series with fewer than ten repetitions occasionally gives an inaccurate estimate of the cycle’s mean period.”

Source: “Evidence of synchronous, decadal to billion year cycles in geological, genetic, and astronomical events”, Chaos, Solitons & Fractals,Volumes 62–63, May–June 2014, Pages 55–75.

The paper is available as Open Access article in the Journal database and can be downloaded as pdf. It is a scientific research paper and has no direct relation to trading purposes. However, an important publication on nonlinear, extra-terrestrical cycles.

http://www.sciencedirect.com/science/article/pii/S0960077914000472


Title:
Evidence of synchronous, decadal to billion year cycles in geological, genetic, and astronomical events

Abstract:
Studies on continuously improving records of geological, biological, and astronomical events and processes led to increased awareness of common cycles in the records. Here we enhance the analytical scope of earlier discoveries by showing that most of these cycles occur in unison, as a harmonic series. The cycles oscillate in multiples of three, cascading into a period-tripled set of cycles. We provide one equation combining the characteristics of 32 theoretical cycles, with periods ranging from 57.3 years to 1.64 billion years. Our statistical tests show that the astronomical and geological cycles are phase-locked synchronously, while the biological cycles lag. This synchrony suggests a common astronomical cause for geological and biological cycles. This suggests that divisible matter is distributed fractally throughout the universe, as postulated by fractal cosmologies, bifurcation theory, and chaos theory.

Author:
Stephen J. Puetz, Andreas Prokophb, Glenn Borchardtd, Edward W. Masond

Date published:
April 2014

Genetic Algorithm

Trading Intraday Volume Cycles Using a Genetic Algorithm

Detect Intraday Volume Cycles for the E-mini S&P 500 Futures using a Genetic Algorithm

One of the ways of analyzing cycles in financial data is to detect cycles in traded volume. In particular, there are interesting correlations between the fixed amount of volume traded and price reversals in intraday trading. If you are able to detect these static volume figures that can explain intraday price movements, you have an edge for your trading strategy.Thus, instead of time-based cycles, it makes much sense to look for fixed amount of volume cycles to spot market turns.

However, once you have detected the active correlations between volume cycles and price movements, this behavior will not remain static. It is, therefore, quite difficult to keep pace with the dominant volume cycles as these cycles are dynamic. On a daily basis, the volume cycles will adjust according to the traders available as they represent the available volume that needs to be traded in either direction for the direction of the price movement to change.

A genetic algorithm (GA) is a promising way to detect volume cycles and to incorporate the flow of traders intraday. It is a new alternative to using digital signal processing for detecting possible cycles. Akin to chromosomes in a genome, a GA will check possible cycle length settings for long, short, and exit signals. The genome transforms based on an evolutionary process that involves mutation, crossover, and survival of the fittest. Similarly, based on a random population of cycle genomes, the GA will evolve to detect useful volume cycles at different starting points and optimize these cycles based on the rules of natural evolution. Each genome is measured against a special fitness function that simply checks the equity curve if you would have traded these volume cycles.

This strategy requires a charting and analysis platform that can chart the data, apply cycle analysis, use GAs, and apply alerts based on the strategies identified for real-time trading. The WhenToTrade charting software allows you to incorporate all these requirements into your trading strategy.
The following example illustrates the application of this strategy of trading volume cycles in practice. The strategy was actually applied before market hours and has been recorded live during the trading session. Thus, you can review the trade result through the video link at the end of this article.

Setting up the chart before the trading day starts

This strategy uses an 8000 volume chart for the S&P500 eMini futures; that is, a bar will be plotted after the trading volume has reached 8k. Thus, the x-axis indicates a linear fixed amount of volume and not time. Thus, the cycle length in these charts does not represent a fixed time period, but a fixed amount of volume.

In our example, we set our intraday trading strategy on January 17 2014 at 7:00 am NY time, one hour before the major US market opens. We apply the GA to the data for the prior two weeks in order to evolve the cycle genomes. Data from January 2–15 is used for the GA process. Data for the out-of-sample period, January 15–16, is used to verify the results.

We use the relative strength index (RSI) to analyze the volume cycles on the price chart for this realtime example. The RSI works as an oscillator and is cyclical in nature; therefore, it can be used to detect cycles. Once the RSI for the volume bars crosses a special value, a signal will be generated. Each trading signal has two parameters—a length setting for the RSI and an individual threshold value that represents the cut-off value for the signal to be generated. The combination of the crossover threshold and the RSI length represents fixed active cycle measures through the RSI indicator. We allow individual combinations of these parameters for long, short, and exit signals. Thus, we assume that different volumne cycles are active to trigger long and short signals. This enables us to remain in sync with the real characteristics of traders’ emotions, as short cycles are mostly faster and sharper than long cycles.

The generic script to apply this signal is as follows:

CROSSOVER(
RSI(close,LENGTH), TRESHOLD )

The GA was run for just 3–5 minutes and the fittest genomes from the population were identified. There is an important benefit of GA over brute force optimization algorithms:

A brute force technique checks each parameter combination for local optima. For our example, this would imply the following search space: The RSI length can take values between 5–35 and the crossover threshold can take 30 different values. Thus, each independent signal can have 30*30=900 possible parameter combinations. This results in a search space of over 600 billion possible trading strategies (900x900x900x900).

A brute force algorithm must check all combinations for the best combination. In most cases, this is not possible within a short period and, therefore, not applicable in an intraday trading setup where the results are required in the morning before the market opens. On the other hand, the GA can spot profitable combinations within three minutes in this huge search space based on the rules of natural evolution. The process of natural evolution is more similar to the behavior of cycles and the dynamic component within the markets. Thus, the characteristics of GA are similar to the way cycles drive financial markets.

Picture 2 plots the trading system characteristics for each genome identified from the population. The genomes are sorted by the fitness function that seeks constant upward sloping equity curves based on the given fitness criteria.

Intraday Genetic Algorithm

Picture 2: GA results after three minutes

The GA was able to detect cycles within the RSI oscillator of the volume chart that generated a profitability of 76% or 86 e-mini futures points from January 2-15. The equity curve is a constant upward sloping line that indicates constant profit per trade and low risk. Even the out-of-sample equity curve for the last two days (the area to the right of the red line) exhibits the same behavior, which is promising.

Attach the “fittest” cycles found by the GA to realtime trading chart

Based on these statistics, the GA seems to be fit to be applied to real market conditions. Thus, we applied this system to live market conditions. The scripts generated in the right panel of Picture 2 can now be incorporated into any real-time alerting module. The WTT platform includes an alert generator. Thus, the scripts along with the parameters were incorporated into the live alert engine and activated a few minutes before the market opens. In Picture 3, the line “ALERT START” indicates when the alert was applied. From that point in time, the system is monitoring the volume chart according to the rules and real-time incoming signals. The alerts are shown in a special alert window and are directly plotted on the chart as red and green arrows in real time as new bars are plotted.

Picture 3 depicts the results after the trading setup was applied to the chart at market open. The arrows were plotted in real time.

GA Intraday

Picture 3: Real-time trading signals from the detected parameter combinations

As seen in Picture 3, our detected cycle parameter combinations for the entry and exit signals generated eight trades during the day. Of these eight trades, seven were profitable and generated a total profit of over 11 e-mini futures points for the trading day. The trades shown in the chart have not been incorporated ex-post. This behavior was recorded during the day and you can watch the script in live mode where the last two signals are generated in the chart during the live recording. The video link for this trading day is at the end of this article.

This example demonstrates the power of combining cycle analysis, volume charts, and GAs. Thus, it highlights the power of what is possible if you have the knowledge and tools at hand to utilize the power of cycles and GAs. This article shows how to apply a genetic engine to prepare your trading systems for the trading day.

A PDF version of the article is available for download/print.

The trading chart in large scale is available here in full screen: SHOW LARGE PICTURE 3

Realtime video snapshot of the live trading session

The real-time video, that shows (1) that the GA was run before market open and (2) the method of monitoring the signals generated in real time, is available here:

 

 

 

New Charting Module update available

We have added some enhancements and have released the update to the My Account / Download area for registered clients. Please view the ChangeLog for more details.

MIT OpenCourseware: Learning – Genetic Algorithms

This lecture explores genetic algorithms at a conceptual level. Good stuff if you want to understand the background of a GA. I recommend only for colleagues with an engineering/math background. Not related to financial markets. Pure algorithm.

We have implemented a Genetic Algorithm into the WTT platform. Please see our info page.