June 24th, 2014
Following my previous note, there was only one thing left to do and that was to perform all the mentioned long term tests. First, on the original program version as published on WealthLab in July 2002. Then on one of my modified version of this trading script DEVX (version 3) and leave for the end improvements that could push performance results higher using general trading policies rather than trying to optimize parameters.
DEVX (v3) is a strange creature. It doesn't follow indicators per say, it enters a position following the outcome of random functions and yet it is a trend following trading system. As if there was a contradiction in terms in using trend and randomness at the same time.
In anticipation of the conclusion, DEVX (v3) came in second in the three 25 year tests performed. Remarkable and impressive results, but still second place. Nonetheless, there is much to learn from this script.
But first, there was a need to know how good was the original trading script published in 2002. It would have to survive over some 12 years of out of sample data (OOS) on the back end, and some 7 years of OOS data on the front end since the strategy was tested only over the 6 years of data prior to July 2002. And the original XDev trading strategy might not have seen any of the stocks in the DOW 30. Quite a challenge for an old script: never seen data, never tested before over 25 years and fixed in its code structure for the duration. On WealthLab, this strategy is referenced as: "XDev Long V1", originally coded by fdpiech and later modified and republished by Gyro, July 5 2002".
The original XDev program executed on XOM (Exxon) gives the following chart covering its last 11 months of trading activity:
XOM using Original XDev v1  
What was this program's mode of operation?
The strategy designed a none trading zone, where it would buy shares below and sell them above it. This way, it could accumulate some shares below the channel and dump them once it had crossed above its higher channel line. Relatively simple and relatively effective. It's not a new trading idea, it's what about everyone has been trying to do for ages. I resume this to a simple buy and sell at a profit kind of strategy.
Note:
duing the preliminary tests, I found data inconsistencies in the price series of AIG and C. Ratter than redo all the tests on this script, I opted to simply eliminate AIG and C and replace them with more current DOW components (TRV and V). Doing so, I also realized that my DOW list was outdated. This generated a new problem: do I replace those as well? I came to the conclusion: yes. But then, V and GS didn't have 25 years of data. Therefore, I opted to replace them with stocks outside the DOW. This is done without loss of generality as the changes won't affect the trading ideas and concepts presented in these tests. If they worked on other stocks, they might as well work on these too (stocks never seen by this strategy either, all OOS data). I found this solution preferable to others going forward. Therefore, from this point on, all DOW 30 tests will be done using the new stock list with its 6 replacement stocks (2 of which are not in the DOW). I have more tests to do so I might as well use clean data.
When applied to the amended 30 stocks portfolio over 25 years, the original Xdev v1 trading strategy gave:
XDev V1 (2002 version) 30 stocks (25 years)  
It turns out that the original version of this program performs much better than the other two original versions already tested: Σ(H(XDev_orig).*ΔP) >> Σ(H(BBB_orig).*ΔP) > Σ(H(LMK_orig).*ΔP). It also ends up mostly in cash with practically no inventory on hand, with 15 stocks having no inventory at all (meaning being totally in cash). It's also the original strategy that traded the most compared to the other two: XDev_orig: 30,085 trades; BBB_orig: 7,803 trades; and LMK_orig: 1,104 trades over their respective 25 years trading history. This is an important factor when looking at long term performance levels (but not the only one to consider).
This can be explained by the following expression: Σ_{n}(Q_{j})*P_{k}  Σ_{n}(Q_{i}*P_{i}) which provides the same results as the payoff matrix: Σ(H.*ΔP). Both technically express the total generated profit or loss from applying a trading strategy to a portfolio of stocks. The first expression reads: the proceeds of all sales + the value of still opened positions minus their respective costs equals the total generated profit or loss.
Therefore, having a positive edge, no matter how it is implemented and if it holds in time; the number of trades performed matters. This can have a positive impact on overall performance levels. It's like, if on average, you can make a buck, then it becomes: how many times can you do it?
My modified trading script (DEVX version 3) gave outstanding results, but not enough to take first place in this top 10 list. It came in second (poor thing). Still impressive, but nonetheless second. I was hoping for more. I knew after testing only the first few stocks in the portfolio that it would not take first place. Here are the results:
DEVX V3 (25 Years)  
Therefore, the current top 10 list still stands with BBB Mod 01 in first place:
Σ(H(BBB_Mod01).*ΔP) > Σ(H(DEVX_V3).*ΔP) > Σ(H(LMK_0.06).*ΔP).
It could be resumed as: $5.4B > $1.6B > $1.1B. So, the difference is major, a 5 to 1 ratio between first and last. The BBB Mod 01 trading strategy therefore remains king of the road (for the moment...).
What can be learned from the above table?
The mission of this program was to accumulate shares for the long term and trade over the process. Use the proceeds of all sales to accelerate acquisitions. A feedback loop which if effective would show in the performance level reached. This is a common theme behind all my trading strategies. DEVX V3 was designed 2 ½ years ago, and has never before been tested on a 25 years time horizon over a portfolio of stocks of OOS data.
The strategy made 667,020 trades over its 25 year test with 530,799 trades closed and 633,929 trades showing a profit. This means that on the 136,311 positions still opened,103,130 are showing profits while 33,091 are still in the red (showing a loss).
The number of trades is more than sufficient for statistical analysis of the whole trading process. The strategy had a remarkable 94%+ of its trades showing a profit from closed and still opened positions.
Naturally, if you trade 667,020 trades over the course of 6,478 trading days, this averages out to 3.4 $5k trades a day for each stock. You started small, $5k at a time, and gradually grew the number of trades as the portfolio value increased. From, one here and there, to 2, 5, 10 trades at a time. The more the portfolio grew, the more the number of trades increased.
To put this in perspective, trading XOM at $100 per share, would make your initial bets be for 50 shares at a time; and as it progressed in time, XOM averaged 3 trades a day, it would represent only 150 shares a day. And this trading method does the same with the twist of accumulating shares for the long term. So, no so farfetched after all. One needs to increase his bets size to maintain a long term CAGR.
It is based on the same basic idea as the XDev trading strategy designed 12 years ago (my compliments to the authors). My trading procedures use part of the same concept. The main idea was to also design a none trading zone where buying is done below the channel and sales above it (other kind of channels could be used, the strategy is not limited to just this one).
The differences reside in the trading methods themselves. In DEVX V3, all the entry decisions are based on the outcome of random functions. The very nature of the original program was thereby greatly altered: from a trading only script playing swings to a slow share accumulation program with trading allowed over the process to feed back cash to the account in order to simply buy more shares.
Most people when you say you use random function assume that you are using coin flipping equivalents when in fact all it says is that a trade could be taken or not depending on which probability function you might want to assign. For instance, if I give a trade a probability of 1 in 10 of occurring, well that's it; it will happen once in a while with that probability measure: (1/10). I know from the start that, on average, 9 out of 10 times the trade might not happen at all.
Here is how DEVX V3 reacted on XOM under its new trading rules:
XOM on DEVX V3 (25 years)  
We can see some similarities with the original version, but the trading methods are quite different. It's when you look at the background that you see how different they really are:
Exxon Equity Curve (25 years)  
The above chart depicts a 25 years equity curve that managed a 27.95% CAGR, generating $46M in profits of which $16.6M is in cash. The continuously generated profits were used to increase trading while accumulating shares for the long term as part of its trading process. It can say mission accomplished as it ends its 25 years journey with 287,755 shares in inventory valued at $102.73 per share. Of its 19,103 trades (average 2.95 trades/day) all of them are showing a profit. That's quite remarkable. This usually happens when a stock in your portfolio reaches historical highs in its price series while in your portfolio.
Yet, this trading strategy finished in second place!
With so much in cash reserves, portfolio volatility is also reduced. The DEVX trading strategy ends with some 50% of its portfolio equity in cash. This means that for a 5% down move in stock prices, the portfolio would move down by 2.50%. However, one should observe that this 5% move in prices would still represent a $40M move in final portfolio value. This starts to change the notion and appreciation of what is a drawdown and what is an acceptable one.
Just trading would not have accomplished this. The reason is simple: as the portfolio grows, it becomes more and more difficult to flip large sections of a portfolio. It's easy to flip 5% of a portfolio when it's small (5% of $100k is just $5k), but 5% of $46M is $2.3M, and 5% of $1.6B is $81.2M. Ever seen anyone flipping this kind of cash on single trades on a daily basis! This is where trading methods like DEVX can shine. At all times, the trade size is $5k, even if you have $1.6B in the trading account. And I don't see a $5k bet on a $1.6B portfolio being a high risk proposition. Note, however, that as trading progresses, more than one bet will be placed at the same time, even if the process started slowly.
You won't get there in a day, it's still a long journey to reach your long term objectives. Compounding takes time, and your strength is your ability to wait. So, steady as it goes.
As in the previous 2 tests, I had to do the $1k bet size scenario. It was shown that reducing the bet size would also proportionally reduce the portfolio outcome. And therefore, without even having to do this test, one could estimate that:
Σ(H(DEVX_V3_5k).*ΔP) ≈ Σ(5*H(DEVX_V3_1k).*ΔP)
In the hope of making this point for the last time, I had to do this test again even if it was not necessary. You are playing fixed amounts of money, not fixed percent of equity. There is a major difference. So no surprise if the output of the $1k bet size test gave the following:
DEVX V3 ($1k scenario)  
It's amazing, even when playing in $1k chunks, by applying this script over a 25 year period, one would still have managed to obtain over $324M for his/her trouble. I do think that this would have more than compensated anyone for their time: a few minutes each trading day... albeit for 25 years...
There should be no need to do the $100 test, it should be about 10 times less than the $1k test. Each time I say something like this, I have to check even if I already know the answer. Hope no one in the future will ask to do this one again, I know I will try not to mention the $100 test again. Playing the stock market $100 at a time is not an efficient use of available capital. Nonetheless, here are the results:
DEVX V3 ($100 scenario)  
From the $1k test, it was expected that the $100 test would give about 10 times less in profits which is exactly what it did, even if all the trades might have had different random entries prices.
By playing fixed amounts, one is scaling the payoff matrix: Σ(aH.*ΔP) = aΣ(H.*ΔP). If you put twice the money on the table, you should get twice the rewards. With a $1,000 bet, you will buy 10 times more shares than with a $100 bet. Hence, you are simply scaling your inventory, exposure or participation level.
There is a long and a short explanation to this, but for now I will go for the short one. As presented at the end of the Bizarre Trading Behaviors article, my trading methodology can be explained by the following equation:
A(t) = A(0) + Σ(H(1 + r + g + T + CC + NP)^{t}.*ΔP)
where the particular part of interest for the DEVX trading script is: H(1 + g + T)^{t} and where g is the accumulation policy rate with T the contribution from the trading process. Therefore by affecting these two elements one can rescale the performance level: H(1 + a_{1}g + a_{2}T)^{t}, and have it have an exponential impact on the portfolio.
The above translates to increasing the stock accumulation process as well as increasing the contribution from trading: the pump to fuel the improvements. Based on the 3 strategies already tested, all their respective portfolios ended with excessive unused cash reserves. Thus, there would appear to be sufficient capital available to increase both contributors to overall performance.
To increase portfolio performance, the task seems to have been reduced to: increase the trading activity (number of profitable trades). This will provide the funds to accumulate more shares: a_{1} > 1, and a_{2} > 1, and job done. And since the inventory is on an exponential function: H(1 + a_{1}g + a_{2}T)^{t}, you should get the portfolio value to rise with the indirect effect of reducing the doubling time. Always one of my major concerns when designing trading strategies. This way, the longer you played this game, the more you would make. It's a compounding game after all and performance is measured in CAGR.
The DEVX trading strategy is already equipped with the necessary functions and procedures to switch gear in V3 and make it jump to V6. I usually want to answer other questions when I do tests; in this case one would be: do I fix a_{1} and a_{2} for the test duration or do I program the two factors to be modulated by price action? I opted for fix for the moment, it's already builtin; but it does say: more tests to be done...
After "boosting" DEVX V3 to V6, a new problem will arise: what ever code I would have added to improve DEVX V3's performance could also improve the performance level of the other two tested trading strategies (BBB Mod 01 and LMK 0.06). Then which one should be declared number one? The answer to that one should be relatively easy: BBB Mod 02 (not yet designed) should kept the high spot and stay number one since it too would have a boost in its alpha points.
When I'll do the test (V3 to V6), I will only see the aggregate effect of (g + T). Meaning that the holding matrix H is still path dependent. The trading strategy is ready to behave as requested, but still the prices have to fluctuate sufficiently in order to cross the no trade zone time and time again. It could be surmised that the more a price series is volatile, the more such a methodology could benefit from all the price swings of significance.
I will be able to see the aggregate effect of a1 and a2 and their influence on (g + T), which will give something like this: (1 + k)*(g + T) where k > 0, since the "pumping" effect is path dependent and will vary from stock to stock and their degree of volatility. You are kind of requesting for stock prices to fluctuate all they can over their long term trends, which is what they have been doing for over 2 centuries.
Notice that I did not mention indicators, but general trading policies and objectives. What I am aiming for is to affect the whole strategy matrix H in a single swoop (all 194,370 trading decision points) with the long term perspective of increasing the payoff:
H(1 + a_{1}g + a_{2}T)^{t} > H(1 + g + T)^{t} where a_{1} > 1, and a_{2} > 1
which when reintegrated in the payoff matrix equation will give:
A(t) = A(0) + Σ(H(1 + r + a_{1}g + a_{2}T + CC + NP)^{t}.*ΔP)
We now have the theory behind what is expected out of the boosting of DEVX V3 to V6; and since options are not covered in DEVX V3, the above should read:
A(t) = A(0) + Σ(H(1 + r + a_{1}g + a_{2}T)^{t}.*ΔP) with a_{1} > 1, and a_{2} > 1 or
A(t) = A(0) + Σ(H(1 + r + (1 + k)*(g + T))^{t}.*ΔP) with k > 0
The booster (1 + k) could be extracted and applied to other trading strategies such as BBB Mod 01. How large should k be? Well not that large. With k > 0.05 (meaning a 5% booster would translate to about 2 alpha points), DEVX V6 might or might not take first place. But if you applied (1+ k) to BBB Mod 01 and transformed it into BBB Mod 02, then BBB Mod 02 would regain its first spot. So for now, DEVX V6 is kind of condemned to remain # 2 until I find a more clever concept that could only be valid in its unique trading style and environment.
Presently, the standing of the three tested trading strategies is:
Ranking of the 3 Tested Strategies  
By adding the boosters to the other two trading strategies (after the V6 test) as described above, the ranking would be maintained:
Standing of 3 Trading Strategies with Boosters  
What is shown in the above two graphs it that over the first 10 years or so, all the curves are almost indistinguishable. One would have to zoom in to see the details. It's the later years that really count, but to get there, you had to be there for the duration. It's a long term kind of game and we should look at it with that perspective in mind.
It's now time to do the test and have DEVX V6 do its thing. Doing this one will justify the booster for the others and won't change the standings since it would be sufficient to also change the other trading strategies by incorporating the same trading procedures to their respective programs. The above was written before performing the modifications to DEVX V3 to transform it in to V6 which would be run once, what ever the results may be. But I'm confident that V6 will outperform V3; it won't be enough to over take BBB Mod 02, or BBB Mod 01 for that matter. But still, the test needs to be done. There are lessons to learn from the process.
Here are the results:
DEVX V6 ( V3 boosted by (1+k) ) 

What the above table says is: mission accomplished. You made more profits, traded more, closed more trades, and increased the CAGR to boot. I find it remarkable for the # 2 trading strategy. I know, I'm biased, I like the way it behaves, but nonetheless, that was pretty good performance. Closing all remaining opened trades on the last day of trading would give the totals in the net profits column plus the original capital put to work.
To better see the difference between DEVX V6 and V3, I also made a difference table for the important elements:
DEVX Differences: V6  V3 (25 years)  
From the above table, one can see that all the stocks improved profit wise, all the stocks improve on their CAGR level (average 2.5%). Some 208,126 trades were added over the 25 year test, of which 112,365 were profitably closed. Of the total trades added (208,126) 194,633 are showing a profit. The cost for all this, a 0.25% reduction of the win ratio over the 25 year test. It averaged out to 1 more trade per day per stock. On the cash reserve department, V6 managed to accumulate still more cash, some $293.4M. By applying a "simple" 5% booster to the equation, DEVX V6 added some $930.7M to its long term equity. DEVX V6 paid for all the added trading activity and even got a bonus (more cash reserves) for doing so.
The last two columns show the increase in accumulated shares and their market value for each of the 30 stocks: 13.1M shares valued at $634.7M. None of the stocks suffered a reduction.
Each stock went at its own pace, followed its own path and behaved differently. Yet, the DEVX V6 trading strategy managed to affect the whole payoff matrix, from start to finish; very slowly at first, almost imperceptible but growing and growing over the long term trading interval.
And this might be the point that one should take out of the DEVX V6 trading strategy. It is not by optimizing indicators to improve timing of entries and exits that V6 was uplifted, it was by working on the whole payoff matrix at once:
A(t) = A(0) + Σ(H(1 + r + (1 + k)*(g + T))^{t}.*ΔP) with k > 0, g > 0, T > 0, r > 0
XOM (Exxon) has been used to show the trading activity of V3 at the beginning of this piece, I'd like to return to it for a moment and show its 25 year equit curve under DEVX V6:
XOM DEVX V6 Equity Curve (25 years)  
What happened from V3 to V6 can be seen on this chart by the red regression line, it was just lifted a notch, a few degrees (from 27.95% to 30.80% giving 2.13% more in alpha points), but sufficient enough that over the long term it really mattered (generating $23.6M more in profits).
Another chart of interest is the one showing Maximum Adverse Excursion and the Maximum Favorable Excursion (MAE : MFE) for all the trades taken by XOM:
XOM MAE/MFE Histogram (25 years)  
The top histogram in red shows in the background all trades that have seen red by number of trades and percentages. So 877 trades showed at one time a maximum 10% decline, just as 330 trades showed at their lowest low a 30% decline. The light red number in the foreground gives the number of trades that finished positive out of the number of trades that saw some red at each percentage level.
In the above case, both series have the same numbers. This means that for all the trades that saw red, they finished with a profit if sold, or are positive if still opened (all of them showing profits).
The bottom histogram in blue shows in the background all the trades that have shown a profit at one time and what happened to them afterward. In the foreground, all the trades show 0, meaning that none of those trades lost money. A kind of perfect score in the profit department.
Wait, you say, the guy is playing using random entries, and all his closed trades are positive! Yes. And the reason is very simple, it has nothing to do with randomness, but more with the trading strategy itself.
The main idea here is: accumulate shares for the long term and trade over the process. Therefore from the start, the strategy wants to buy shares and hold them for as long as it takes to show a profit. It's a Buy & Hold strategy at heart. The strategy will start small, $5k at a time, here and there, until some profits start showing on some of the trades. Then the strategy sells at a profit some of its holdings and wait for the proper moment to restart purchasing more shares with again the intent of holding on to them for the long term.
Doing this, all the closed trades will show a profit, by design, not by luck. And that is what the above chart shows. Of all the trades that saw drawdowns, none was sold at a loss; and its counterpart, of all the trades that saw profits, none were sold at a loss either.
This means that this trading strategy has a no stop loss policy (except for a big red emergency button). It's a: give me my profit kind of thing, or else l will most certainly wait for it. And based on the above test (V6), the "waiting" was worthwhile to say the least.
What you have however is a stop profit policy builtin the trading strategy itself. Its main objective is to accumulate shares over the long haul; and this is difficult if you do not bring new money to the table. This is why trading is encouraged over the accumulation process: to generate added cash for the system. Building a snowball effect, a feedback loop. You buy shares, sell some of them, or all, at a profit, and reused the proceeds to buy even more shares and repeat the process as much as you possibly can. This way you are always selling some shares at a profit, which makes the above histogram self evident, while also feeding your cash reserves (the pump or heart of all this).
The reinvestment policy, this attempt to always try to accumulate shares, is being thwarted by the continuous selling of shares at a profit over the long haul. It has for secondary effect of pushing profitability higher and higher at most levels of interests. You increase profitability, and should you want to increase even more, you simply would push a little more on the booster (1 + k) and voilà: more profits, more shares and more cash reserves (as shown in the V6 : V3 comparison).
All three of the currently tested trading strategies: LMK 0.06, BBB Mod 01, DEVX (V3 and V6) are end of day (EOD) trading systems. This means that trading decisions are taken on EOD data for market orders for the next day at the open. DEVX V3 and V6 have the particularity that the EOD data might not matter that much since all trades are taken on the whim of the random functions according to the rules of engagement. LMK 0.06 had 90%+ random entries, while BBB Mod 01 had about 2% to 3%. DEVX went all the way, it's at the 100% level for random entries. This meant that it could take a trade, when allowed, no matter what was the day's closing price. The method has no entry finesse at all, it just might take the trade the next day what ever the price may be at the open and at market.
It was not if I could design some "finesse" in that system that mattered or if I could be delicate enough for other considerations; it was to validate the concepts and trading ideas incorporated in DEVX. And if they had some validity, they would have to work their magic with or without finesse over the last 25 years on stocks that the strategy has never seen. A complete out of context test. A kind of if you pass this one, you are really good, and I'll have to consider this more closely.
The trading methodology, the inner workings of DEVX V6 have shown remarkable aptitudes at making a portfolio grow over the long haul. It's also scalable up or down as shown repeatedly with those $100, $1k and $5k tests. Someone wants to double the output of DEVX V6's payoff matrix, simply play with $10k bets for an added $2.5B, but first also get twice as much money as initial capital to start the ball rolling.
DEVX V6 has demonstrated that the link between trading strategy and its payoff matrix may be global. You can scale from the outside like providing twice the initial capital: 2Σ(H.*ΔP) or scale from inside like in V6: A(t) = A(0) + Σ(H(1 + r + (1 + k)*(g + T))^{t}.*ΔP). You could also do both at the same time.
If you don't use the paper profits, don't accumulate shares over the long term and don't trade over the process, the equation reduces to: Σ(H.*ΔP) which translates to doing the same thing as everybody else, and the expected outcome on this is to achieve the average long term returns of an indexed fund (the average secular market trend), often described as the equivalent of the Buy & Hold strategy.
Not shown in the DEVX V6 table above was its stock accumulation totals. The "did it do its job over the long haul?" question. The best way to resume this is by providing another table showing the ending stock inventory on hand:
DEVX V6 Ending Stock Inventory (25 years)  
DEVX V6 won on all counts: increased profits, increased alpha, increased trading, increased number of trades showing profits, increased cash reserves, increased inventory on hand, and increased inventory value of shares still held. On all desirable factors, this trading strategy did its job.
It's a remarkable feat. It demonstrates that the trading procedures used have merit and could be applied going forward. One could even do the whole thing by hand if they wanted to. They could simply "print" the program and have their trading manual in hand. Just read the instructions and execute the commands. The total blueprint provided in easy to read code.
It took all the above explanations to describe part of the inner workings of this trading strategy; its a complex trading system but what it does can be resumed in one sentence: accumulate shares for the long term and trade over the process.
The future will be different, I know, but even faced with an unknown future, the principles and ideas presented in DEVX V6 would still hold for many, many years to come  stock prices will continue to fluctuate in the future, I know it's a bold statement, but I can live with it.
All I know is that the strategy will act as it acted in the past. As for the actual numbers that will be generated in the future, I don't know. Every stock series will be different. I too will have to wait and see. I know now that I would be pleased if it could generate even half it did in the past. It's a long journey, and as the above ranking charts showed, the last few years are the most important of all. You just need to be there for the duration.
DEVX V6 is just a trading script, some code, a set of procedures to be followed to reach a goal that it be executed automatically or by hand. What is the "secret" behind the DEVX strategy? There is none, all the code is common stuff. And I think anybody could do even better. Anyone could rebuild the DEVX trading strategy to his/her taste; all the ingredients needed are provided to do so. It is why I hope that all the above might help you design a better long term trading system. If some of the ideas and concepts presented here can help you in your quest, I will have reached my goal.
This trading strategy may be complex, but its output is pure simplicity.
Created... June 24th, 2014 © Guy R. Fleury. All rights reserved.