AnyHour_TimeBox
A “Scalping” Strategy for Tradestation Version TS8.x
Author: Clyde Lee, SYTECH Corporation Copyright: 2003….2008
This is a licensed product and is distributed on a fee paid basis only.

See the power
of the “box”
Click on
following for License.
A license to use this strategy on a single
Tradestation platform is
available. The price of the license is $2,500
USD and as usual
the source code is
open. Click on any of these lines to
go to
the purchase zone.
The following information is
from the frontend documentation that is provided for the
AnyHour_TimeBox strategy for Tradestation Version 8.x. This version supports multiple
overlapping boxes (up to 6).
After examining this
information in detail, you will find graphic representations of these
parameters and their effect on the behavior of the strategy.
{Strategy: AnyHour_TimeBox
Author: Clyde Lee, SYTECH Corporation, Copyright 2007,2008
Over the years a number of authors have suggested that the behavior of prices
within the first hour after opening could be used as a screening tool to
determine the direction of trading (long or short) and levels at which one
should make such an entry.
After examining the above concept extensively I decided to implement a
strategy which:
1. Allowed the user to set the beginning time for construction of the set of
prices to be evaluated at any time within the trading session.
2. Allowed the user to set the period of time after the time set in 1 above
over which price behavior was to be examined/evaluated. To provide some
frame of reference a "box" is constructed with vertical sides at the time
of 1 above and time 1 plus this time period. Top and bottom of the box
will be set by the high and low values within the indicated time zone.
3. Establish a percentage of the price range within the described box at
which a price level is established to define whether the trade is to
be entered or not. Direction of the trade is established automatically
by determining whether the low of the box or the high of the box
occurred first in time.
4. Allow user to establish a stoploss point based on either a percentage
of the high/low price range of the box or a multiple of Average True
Range.
5. Allow user to establish a take profit point based on either a percentage
of the high/low price range of the box or a multiple of Average True
Range.
6. Specify a maximum time period for a trade.
7. Specify an option to invert the direction of trading.
Input:
BeginTime(9.25), {0=use begin of session time. }
{Negative=use begin of DAY time. }
{HHMM
format or HH.dd format where HH is an }
{hour
specification and .dd is a multiple }
{of 60
minutes to set the minutes. This is }
{done
to allow "optimization" without any
}
{wasted
and unachievable time values. }
NumbMinutes(75), {Number of minutes in "first
hour" box }
NumbBoxes(1), {Number of boxes to create on
following }
{Maximum number boxes = six (6). If set to }
{zero
the default is 1. }
BoxIncrement(75), {Time interval between END of boxes. }
{This
interval must be in minutes. }
EntrLimPercHL(-5), {To enter a trade long the close price
of }
{each
hour box must be above the lowest low }
{of the
box plus this % of HH-LL of the box.}
{To go
short the closing price of the box }
{must be less than the
highest high of box }
{If
this value is negative then the absvalue}
{is the
number of bars to check direction to}
{see it
is same as for box. }
{minus
this % of HH-LL of the box. }
StopLimPercHL(125),
{Stop/Reverse -- dollars for stoploss limit }
{If set
to zero then no stop will occur }
{If set
negative is a multiplier of ATR }
TakProfPercHL(250), {Take
Profit -- dollars for stoploss limit }
{If set
to 0 then no take profit will occur.}
{If set
negative is a multiplier of ATR. }
ExitAfterMins(120), {Exit
any active trade after this # minutes }
{Negative=Time for exit in HHMM or HH.dd. }
NumbCont(2), {Number of contracts/shares to
trade }
InvertTradeDir(0); {Set positive to invert trading
direction. }
The following shows
installation each hour – not recommended since strategy closes any
trades from prior instances.

The vertical lines were put
in manually to indicate time and date of installation of strategy.
You will note that whenever a
new box is entered, any trade from earlier box is closed out.
The dotted lines of the box indicate the
extremity in time and price. A diagonal line is
drawn indicating the relative position of the high and low prices in the box. So:
BeginTime(0), {0=use begin of session time. }
{Negative=use begin of DAY time. }
We now concentrate on:
NumbMinutes(90), {Number of minutes in "first hour" box }
This parameter is used to
establish the number of minutes that will be used to setup the
First “box” that provides a
set of values to establish conditions for entry and exit. The
BeginTime and NumbMinutes
parameters should ALWAYS be optimized
concurrently.
Takes some time but do it
anyway.
If the user desires to use
more than one OVERLAPPING box then such should be
Indicated using the following
input parameter. Remember, maximum of 6
boxes is
supported.
NumbBoxes(1), {Number of boxes to create on
following }
{Maximum number boxes = six (6). If set to }
{zero
the default is 1. }
If the number of boxes
defined above is greater than one then the user must specify an
Increment between the END of
each box relative to the end of the prior box.
This is
A time increment that is
specified in minutes.
BoxIncrement(75), {Time interval between END of boxes. }
{This
interval must be in minutes. }
When we have a working “box” then we need to look at:
EntrLimPercHL(-5), {To enter a trade long the close price
of }
{each
hour box must be above the lowest low }
{of the
box plus this % of HH-LL of the box.}
{To go
short the closing price of the box }
{must be less than the
highest high of box }
{If
this value is negative then the absvalue}
{is the
number of bars to check direction to}
{see it
is same as for box. }
{minus
this % of HH-LL of the box. }
and determine a level for
entry or the length of a momentum measure that will yield the
best return on
drawdown. Typically this will run somewhere around 50 for level but it
should be optimized from zero
to 95. The length of the momentum
operator will often
be around -5 but I always optimize from -21 to zero.
Because this is a scalping
system and a trade does not exist too long, it is not always
necessary to have a stoploss
setup. However, you should always test to see if one makes
sense for the model you are creating. I
always use a multiple of ATR (a negative number)
but you may find a percentage of box price size is workable.
StopLimPercHL(35), {Stop Percent of HH-LL from HH/LL }
{If set to zero then no stop will occur }
{If set negative is a multiplier of ATR }
As a scalping system/model perhaps the most influential of all the parameters is the next:
TakProfPercHL(165), {Percent of HH-LL as take profit target. }
{If set to zero then no take prof will occur}
{If set negative is a multiplier of ATR }
The strength of the scalping
– and to some extent the profitability of the strategy – is
controlled by the size of the
take profit parameter. Again, I use multiple of ATR but you
may find the percentage of box price limits to work best.
If the take profit amount is
very small the profit will be limited but the percentage of wins
will be very high. Winning percentages
can approach 90 for small take profits. However,
for maximum profit the take
profit amounts will need to be large or excluded and just use
the end of day or expiration of time limit to close the trade.
The following parameter is used to limit the length of time that a trade is active.
ExitAfterMins(0), {Exit any active trade after this # minutes.}
{Negative=Exact time for exit. }
If set to zero then exit will
be at end of session. However, I have found that an exit may well
not occur if you depend on
the Tradestation end of session exit. I strongly recommend that
you set this parameter so that there is an
exit on the bar before the end of the session.
Because of certain
requirements of internal logic it is important to tell the system how many
contracts are to be traded in
each box. The NumbCont parameter
satisfies this need.
NumbCont(2), {Number of contracts/shares to
trade }
There are starting times and
box width minutes that will result in profitable trades over a
Significant period of time.
The following optimization report indicates a couple of such
times/box width combinations that resulted in profitable trades.

However, these are not as profitable as the best “conventional” trades.
InvertTradeDir(0); {Set positive to invert trading direction. }
This parameter is available but seldom is it the most advantageous.
The following picture shows a couple of days trading using the inverted definition.

As you can see the trading is opposite what the “normal” box trading would be.
Now for a bit more discussion
on TAKE PROFIT parameter. Look at the following
picture which is an
optimization report of optimizing the take profit parameter (multiplier
of ATR was used).

The horizontal grey area
indicates the most profitable parameter (7 times the ATR) and the
black lighted column shows
the percent profitable. The beauty of this strategy is that the
user can pick and choose the performance desired.
The following are a few studies of the strategy in action.


Trading YG (mini gold) from


Trading YG (mini gold)
starting shortly after


Trading YG (15 minute mini
gold bars) starting at


Mini gold 30 minute bars
trading after


Trading Mini DOW starting
just after
Click on
following for License.
A license to use this strategy on a single
Tradestation platform is
available. The price of the license is $2,500
USD and as usual
the source code is
open. Click on any of these lines to
go to
the purchase zone.
The prior information was
related to trading just ONE box. The
following covers what
may be seen with multiple boxes.
This first picture of this group illustrates (within one day on GOOG) the three types of trades that can
occur. The system has facilities to define a stoploss trade, a take profit trade, and a trade that is based
on some time interval after entry.

The following pictures are explained by notes within each picture.






Click on
following for License.
A license to use this strategy on a single
Tradestation platform is
available. The price of the license is $2,500
USD and as usual
the source code is
open. Click on any of these lines to
go to
the purchase zone.