Google
 

Friday, September 7, 2007

Range Expansion Search Code

In creating a list of patterns for trading programs, there are two ways to proceed. The first method is to observe the markets and investigate hunches as to market behavior. Occasionally, using this method, useful trading patterns will be detected. This is the method I used until I came across the written opinions on the subject of star trader, Monroe Trout on this subject. Trout learned to trade while working for my former employer, Victor Niederhoffer in New York. Trout logically proposes the idea that a more efficient method of pattern research is to simply test all possible parameters and intermarket relationships to see if any of the results look statistically valid.
What I will present to you in this chapter is a sample program that you can use to test all possible patterns of a technique called range expansion. If you are unfamiliar with the concept of range expansion, let me explain. Range expansion refers to any system that takes the value of one chart point, subtracts the value of another chart point and then adds or subtracts this value from an opening or close to derive a buy or sell point.
In many cases, we will be using a percentage of the value we calculate and then add or subtract this value to tomorrow's opening for our buy and sell points. Since it is easy to run a comprehensive search of all volatility expansion patterns and then to consider the possibilities, we will demonstrate the technique.
Our Tradestation program to find volatility expansion sell signals reads as follow:

Inputs: cha(O), opt(O), per(O), tday(O);
Vars:voll(0), vol2(0);
voll=highest(high,cha) - lowest(close,opt);
vol2=highest(close,cha)-lowest(low,opt);
if day of week (date)=tday and
voll [ vol2 then sell tomorrow at open tomorrow -(voll*per) stop;
if dayofweek(date)=tday and
vol2 [ voll then sell tomorrow at open tomorrow - (vol2*per) stop;
Our program to search for volatility expansion buy signals looks as follows:
Inputs: cha(O), opt(O), per(0), tday(O);
Vars:voll(0),vol2(0);
Voll=highest(high,cha)-lowest(close,opt);
Vol2=highest(close,cha)-lowest(low,opt);
If dayofweek(date)=tday and
Voll [ vol2 then buy tomorrow at open tomorrow+(voll*per) stop;
If dayofweek(date)=tday and
Vol2 [ voll then buy tomorrow at open tomorrow + (vol2*per) stop;
This program will test every day of the week for volatility expansion trades. It alters the values that are searched as well. Since the highs, closes and lows are inputs, we can test all values from 1 -5 days ago and all days from 1 -5 (Monday to Friday) and all percentage expansions from 109& to 200%. We will use the lesser of the two values that we calculate. In addition, we will test all parameters of each of the three components to get a sense as to whether there is a range of values that shows some promise.
If we only find a single working value, we must suspect an over-optimized system and avoid it. Our general rule is to base our trading only upon pattern systems that have profit factors above 3 and percentage accuracy in the area of 70% or better and many similar profitability reading at different parameters.


No comments: