Page 1 of 2

### Test results: 4 different entries + Random Exits

Posted: Fri Mar 23, 2007 8:37 pm
Van Tharp's book Trade Your Way to Financial Freedom discusses a system with random entries + good exits. I decided to explore the reverse: good entries + random exits. My hypothesis is that some entry signals are so good that they can generate profits even when used with random exits, even after commissions and slippage.

I tested the Random Exit systems the same way Van Tharp tested his Random Entry system: using \$100 per contract for round-turn commissions+slippage, and using a portfolio of 10 futures markets. He ran his tests for the most recent ten years (i.e. 1981 to 1991), and so did I: from March 1997 to March 2007.

I decided to implement a particularly ugly form of Random Exits: once a trade has been entered, generate a random number "R" uniformly distributed between 1 and 30. Hold this trade exactly "R" bars and then exit on the close. (Each trade generates a new random number R and so each trade is held for a different, random, number of bars.) This is the ugly part: the short hold-time, 1-30 bars. Most trendfollowing systems hold onto trades, particularly winning trades, up to 100 or 200 bars; by restricting my test to 1-30 bar hold times, I'm applying additional stress. Roughly speaking, it takes more than 10 or 15 bars of hold time to get the average profit per trade above the commission and slippage costs (\$100/contract). But I'm forcing random hold times as small as 1-2 bars. Ouch! Losing trades are cut short, and so are winning trades; both pay \$100/contract commission and slippage. c.f. tested random exits having a random hold-time between 20 and 150 bars; nickmar chose a random hold-time between 20 and 200 bars. I'm sticking with the "ugly" choice of 1-30 bars, because it's a worst case test; if entry signals can make profits with these terribly punishing exits, then the benefits of good entries are demonstrated even more strongly.

First, to get a baseline, I tested Random Entries + Random Exits. Once a trade is entered, the Random Exit generates a new random number R1 and holds that trade for R1 bars, then it exits on the close. (R1 is uniformly distributed between 1 and 30 bars). After a trade exit, the Random Entry generates a new random number R2, stays out of the market (waits) for R2 bars, and then enters in a random direction (long or short) at the market price. The random wait time before new entry, R2, is between 1 and 30 bars, uniformly distributed. The system was coded into Blox and a picture of its parameter settings is shown below.

The figure called "Result1" shows the Random Entry + Random Exit system in action. Fifty different runs of this system are overlaid on the same graph, the better to visualize the min, typical, and max performance. 48 of the 50 runs lost money, and the median run (25th best out of 50) had a Compound Annual Growth Rate of -8.4 percent per year. We can think of -8.4%/yr as the Frictional Cost of commissions and slippage. Since random trading has no systematic advantage ("edge"), the expected result is breakeven, minus commissions and slippage. From this figure we see that an entry signal needs to have an "edge" of at least +8.4%/year, just to overcome C&S and achieve breakeven.

"Result2" shows another system, this time using the "ADX Burst" entry signal from Tushar Chande's book Beyond Technical Analysis. The idea behind ADX Burst is quite simple: When it appears that the trend has accelerated very quickly, jump aboard! Chande defines "a quick acceleration of trend" to be a very large one-day jump in the ADX indicator. Since ADX only measures strength of trend but not direction, Chande uses 2 moving averages to tell whether a long or a short entry is warranted. In pseudocode,

Code: Select all

``````if( today's ADX(18days) > (1.0 + yesterday's ADX(18days))), AND
if( EMA(4days) > EMA(16days) ), THEN Enter a Long Position``````

The ADX Burst entry is profitable enough to overcome Commissions and Slippage, even with Random Exits. 42 of the 50 runs were profitable, and the Median run (25th best out of 50) had a Compound Annual Growth Rate of +3.1% per year, including the effects of slippage and commissions. It's no great surprise that the ADX Burst entry signal handily beats Random Entries: median CAGR= +3.1% versus Random Entry median CAGR = -8.4%. ADX Burst Entries are significantly better than random entries.

Posted: Fri Mar 23, 2007 8:54 pm
Next, the Channel Breakout Entry was paired with Random Exits ("Result3"). Go long on a stop order at the highest high of the most recent 220 bars; go short on a stop order at the lowest low of the most recent 220 bars. After entry, generate a new random number R (uniformly distributed between 1 and 30), hold the trade for R bars, and then exit on the close. "Result3" shows that the median of the test runs (25th best out of 50) had a Compound Annual Growth Rate of +5.1% per year, which trounces the -8.4% per year of Random Entries. All 50 out of 50 test runs were profitable. Please notice that the increase in profits (5.1 + 8.4 = 13.5% per year) are exclusively due to the use of good entries; the same random exit signals were used in both systems. Channel Breakout entries are significantly better than random entries.

Finally, "Result4" shows the pairing of a Dual Exponential Moving Average entry, with Random Exits. If the 20-bar EMA is above the 350-bar EMA, go long; otherwise, go short. Hold the trade a random number R of bars and then exit on the close. (R is uniformly distributed between 1 and 30). The median of the test runs (25th best out of 50) had a Compound Annual Growth rate of +7.1% per year (versus -8.4% per year for Random Entries). All 50 out of 50 test runs were profitable. The 15.5% increase of profits is due to the Dual EMA entry signal exclusively. Dual EMA entries are significantly better than random entries.

In summary, good entries plus random exits can produce positive profits, even after commissions and slippage, even for punishingly short trade hold-times. This demonstrates that entry signals are a significant contributor to system profitability; the oft-quoted remark that "All profits come from exit signals; entry signals are unimportant," is wrong. Dead wrong.

Posted: Fri Mar 23, 2007 9:00 pm
Here is all the Blox source code for the various systems discussed.

They are divided into modules; one exit Blok to do the Random Exit using (1 < R < N day hold times); one Money Manager Blok to do the Volatility Based positionsizing; and four entry Bloks to implement the four different entry signals discussed. There is also a "statistic" Blok which prints the equity curve values at biweekly intervals.

Fool around with it. Try your own definitions of slippage and commisisons. Change the hold-time to something less ridiculous than (1 to 30 days). Use your own portfolio of markets. Try your favorite entry signals. Change the test dates. Run it for 35 years instead of 10. Be creative, have some fun.

Enjoy!
sluggo

Posted: Mon Mar 26, 2007 11:38 am
Great contribution Sluggo!! Sorta like a stress test for your entry logic.

Posted: Mon Mar 26, 2007 11:57 am
Here is one more Entry signal that makes money even with random exits. It uses John Bollinger's "%B" oscillator, which is just Bollinger Bands wrapped into an oscillator. Parameters, results, and Blox source code are attached.

Posted: Sat Sep 22, 2007 4:56 pm
Sluggo,

I would be very interested to know, how these types of charts are created?

Kind of thinking to create similar charts to track the development of a group of trades bar by bar.

Would you mind to share your chart expertise? Did these charts come from TB or Excel or ???

Thanks,
explorer

Posted: Sun Sep 23, 2007 8:25 am
Excel. If you look at the trading system code you'll see that the equity is printed (for subsequent plotting) semi-monthly. This reduces the amount of data to be plotted by a factor of ten: from 20 datapoints per month, to 2.

Posted: Sun Sep 23, 2007 8:41 am
Thanks, I will try to create one.

explorer

Posted: Tue Sep 25, 2007 12:06 am
I managed to create a sample chart that shows the typical a trendfollowing characteristics.

The only thing that I didn't do, I didn't normalize all the trades to start from 0.

It is a pain in the neck to create manually these chart, I wish it would be a built in feature of TB.

Thanks again for the tips Sluggo,

Posted: Sat Oct 22, 2011 1:34 pm
Dear Sluggo, Tim,

I have been trying to use these blocks without success on TBB v3.8 x64.

Is it necessary to change the code to make it work with this newer version of TBB?

Using the blox as posted, variable "UnitSize" in the RandomExit_blox_MoneyManager is undefined.

However even after defining it as a floating point BPV with System scope, one gets zero trades when running a simulation?

Additionally, I get the attached error message for indicator "pctB"?

Thank you,
Dantes

Posted: Sun Oct 30, 2011 2:44 pm
Dear Tim,

Any chance you could point me in the right direction for this?

Thank you,
Dantes

### frequent contracts

Posted: Sun Oct 30, 2011 4:42 pm
"Roughly speaking, it takes more than 10 or 15 bars of hold time to get the average profit per trade above the commission and slippage costs (\$100/contract)"

It's believable but how then it could be profitable to trade futures with monthly contracts (like oil) ? Wouldn't commission and slippage at rollover times eat almost all profits?

Posted: Mon Oct 31, 2011 11:46 am
dantes wrote:Dear Tim,

Any chance you could point me in the right direction for this?

Thank you,
Dantes
Replace lines 2 & 3 with this line pair:

Code: Select all

``````   Order.SetQuantity ( (RiskPct * Test.TotalEquity) _
/ (2.0 * MyATR * Instrument.BigPointValue) ) ``````
This is required because UnitSize is now a reserved word in TB. In TB's the earlier day, which when this module was created, it was used as you now have it. Above script should get you past this issue.

Posted: Sun Nov 20, 2011 10:04 am
Thank you Roger.

For some reason I had missed your kind pointer - it now works perfectly!

Dantes

Posted: Thu Mar 22, 2012 4:30 pm
Dear Roger, Sluggo,

I'm probably just being dense here... but I was taught that if you don't ask, you never learn...

I don't quite understand what the "2.0 *" is for in the formula below from the Unit Size script in the RandomExit_blox_MoneyManager Blox?
Order.SetQuantity ( (RiskPct * Test.TotalEquity) / (2.0 * MyATR * Instrument.BigPointValue) )
Any help would be much appreciated.

Thank you,
Dantes

Posted: Thu Mar 22, 2012 6:11 pm
Let's take all of the equation for others who might want more:

Code: Select all

``````   '  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Original algorithm
Order.SetQuantity ( (RiskPct * Test.TotalEquity) _
/ (2.0 * MyATR * Instrument.BigPointValue) )
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Define Property Values
'  Example Values that could be in the above properties
Test.TotalEquity = 200,000.00

RiskPct = 1.0% OR 0.01 as a decimal

Instrument.BigPointValue = 1,000 (E.G. Crude Oil)

MyATR = 0.50 Points (Average TrueRange Calculation on Order Day)

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  To determine Size using a Fractional Risk Rate, an early Step is To
'  Determine How Much Can be Risked on this Order
0.01    * 200,000.00

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Let's calculate the Risk-Points this order will carry
'  to create a Close to Protective price estimate
Order_Risk = 2.0 * MyATR
2.0 * 0.50

Order_Risk = 1.0 Points

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  In order to understand the value of that risk in dollar terms,
'  Order_Risk needs to convert its value to a currency value so the
'  Available_Trade_Risk_Equity_Amount can be used in the next step
EntryRisk_Dollars = (Order_Risk * Instrument.BigPointValue)
1.0     *       1,000.00

EntryRisk_Dollars = 1,000.00

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Using Sluggo's algorithm, we can now take the equation and put
'  into this format to determine how many contracts will be give
'  to this Order's Unit Size
2,000                 /     1,000.00

Order.Quantity = 2 Contracts
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``````

Posted: Thu Mar 22, 2012 6:26 pm
Hi Roger, thanks for the quick reply.

The calculation was actually clear, but I still don't see why one needs to have

Code: Select all

``Order_Risk = 2.0 * MyATR * Instrument.BigPointValue``
as opposed to just

Code: Select all

``Order_Risk = MyATR * Instrument.BigPointValue``
?

Why would you multiply the ATR value times 2?

Thanks again,
Dantes

Posted: Thu Mar 22, 2012 6:55 pm
Sluggo's calculation is a estimating approach that attempts to provide some reasonable risk estimation that isn't too far from what would happen had the order been generated with a protective price.

With an example point of 0.50 as the MyATR value, that puts the protective price very close to the price action. While it is possible to use 1.0 instead of 2.0, for estimate process is it better to be conservative, if trading survival is important.

Risk estimation for generating a fractional amount on which to base an order's size isn't anything other than a best guess process. It is a best guess process because if it needed to more realistically reflect what the actual risk of the trade an order would have carried, the risk points provided would have been generated by the distance to a protective stop price from the order day's Close price instead of an expanding MyATR calculation.

When signals generate orders without a protective price, a risk estimator like Sluggo's example is a fall-back method for creating some form of volatility measure that won't be off the planet when the risk is absorbed by a failed trade. Even then, without a protective estimate there isn't any reasonable belief that the actual cost of a failed trade will be close to the risk estimation because the risk estimate is assuming no protective price. Positions without protective prices carry an infinite risk level, and that is usually more than 2.0 * MyATR.

With the above in mind, you can change the 2.0 to just about anything you want. A smaller number will increase size for the same MyATR value, and a larger number will reduce the size for the same MyATR level when used with Crude Oil.

Does this help?

Posted: Thu Mar 22, 2012 8:54 pm
At the time, 2007, there was much enthusiasm for using "Original Turtle Style" calculations/definitions of "trade risk". See page 264 of WAY OF THE TURTLE for the details.

Or, alternatively, see "Stop Placement" (internal page number 24; adobe page number 28 ... ) of document below.

Posted: Sun Mar 25, 2012 6:15 pm
Dear Roger, Sluggo - once again thanks for sharing your thoughts on the forum.

Dantes