Site icon R-bloggers

Trend Vigor Part IV: Shorting and Walk Forward Test

[This article was first published on QuantStrat TradeR » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

While Trend Vigor has potential on the long end (as seen in part III of this investigation here), as Andreas Clenow has stated in his article “Trend Following Does Not Work On Stocks”, the short side of trend following gets killed in equities. And, since by far and away most of the securities in this backtest were equity-based ETFs (most of the ones available before 2003 were equity index ETFs), the results can basically be summed up as “buying insurance for Black Swans”. On the plus side, Trend Vigor at very high period settings (longer than 120) is able to capture some of the upside from being short in the depths of the financial crisis, but unfortunately gives most of it back.

To begin, here’s the code for this strategy, starting off at the previous settings of a period of 20 and delta 0 with ATR order sizing. The demo data has slightly changed in that the initialization, from, and to parameters are now found in the demo scripts, rather than the file itself, which, as a result, is no longer a standalone file.

require(DSTrading)
require(IKTrading)
require(quantstrat)

initDate="1990-01-01"
from="2003-01-01"
to="2010-12-31"

#to rerun the strategy, rerun everything below this line
source("demoData.R") #contains all of the data-related boilerplate.

#trade sizing and initial equity settings
tradeSize <- -10000
initEq <- -tradeSize*length(symbols)

strategy.st <- portfolio.st <- account.st <- "TVI_short"
rm.strat(portfolio.st)
rm.strat(strategy.st)
initPortf(portfolio.st, symbols=symbols, initDate=initDate, currency='USD')
initAcct(account.st, portfolios=portfolio.st, initDate=initDate, currency='USD',initEq=initEq)
initOrders(portfolio.st, initDate=initDate)
strategy(strategy.st, store=TRUE)

#parameters (trigger lag unchanged, defaulted at 1)
delta=0
period=20
pctATR=.02 #control risk with this parameter

#indicators
add.indicator(strategy.st, name="TVI", arguments=list(x=quote(Cl(mktdata)), period=period, delta=delta), label="TVI")
add.indicator(strategy.st, name="lagATR", arguments=list(HLC=quote(HLC(mktdata)), n=period), label="atrX")

#signals
add.signal(strategy.st, name="sigThreshold", 
           arguments=list(threshold=-1, column="vigor.TVI", relationship="lte", cross=FALSE),
           label="TVIltThresh")
add.signal(strategy.st, name="sigComparison",
           arguments=list(columns=c("vigor.TVI","trigger.TVI"), relationship="lt"),
           label="TVIltLag")
add.signal(strategy.st, name="sigAND",
           arguments=list(columns=c("TVIltThresh","TVIltLag"), cross=TRUE),
           label="shortEntry")
add.signal(strategy.st, name="sigCrossover",
           arguments=list(columns=c("vigor.TVI","trigger.TVI"), relationship="gt"),
           label="shortExit")

#rules
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortEntry", sigval=TRUE, ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open", osFUN=osDollarATR,
                        tradeSize=tradeSize, pctATR=pctATR, atrMod="X"), 
         type="enter", path.dep=TRUE)
add.rule(strategy.st, name="ruleSignal", 
         arguments=list(sigcol="shortExit", sigval=TRUE, orderqty="all", ordertype="market", 
                        orderside="short", replace=FALSE, prefer="Open"), 
         type="exit", path.dep=TRUE)


#apply strategy
t1 <- Sys.time()
out <- applyStrategy(strategy=strategy.st,portfolios=portfolio.st)
t2 <- Sys.time()
print(t2-t1)

And here is the output:

> (aggPF <- sum(tStats$Gross.Profits)/-sum(tStats$Gross.Losses))
[1] 0.7088293
> (numTrades <- sum(tStats$Num.Trades))
[1] 947
> (aggCorrect <- sum(tStats$Num.Trades*tStats$Percent.Positive/100)/numTrades)
[1] 0.2734925
> (meanAvgWLR <- mean(tStats$Avg.WinLoss.Ratio))
[1] 2.073667

So, already, we can see that it’s pretty much a bloodbath–namely because throughout 2003 through 2010, the general trend was upwards, and also, because of the use of constant ATR order sizing, when the moves are largest (during the heightened volatility), our position size is smallest, relative to it. Which isn’t to say that this is a particularly bad idea considering that a short position can get whipsawed badly, but that such a short-term detection system has no sense of the overall larger trend.

Here are some more portfolio statistics.

> SharpeRatio.annualized(portfRets)
                                      [,1]
Annualized Sharpe Ratio (Rf=0%) -0.3647753
> Return.annualized(portfRets)
                         [,1]
Annualized Return -0.04075671
> maxDrawdown(portfRets)
[1] 0.3464871
> 

In other words, this strategy simply costs you an annualized 4% a year, just to get the pop-up during the financial crisis, and then proceed to give that all back to the market anyway. In other words, it’s a really silly form of insurance, especially considering that due to the heightened volatility in times of extreme crisis, the ATR order sizing function *already* functions as a massive hedge. For the sake of completeness, here’s the equity curve of this strategy.

And here’s the usual equity curve of XLB.

Note that just when all the blood is in the water, the ATR order-sizing function actually works *against* the strategy. This is due to the fact that with equities, that are bought in the expectation of price appreciation as an investment (rather than, say, a commodity, whose prices need to fluctuate, and whose price appreciation perhaps means adverse consequences outside of the investment universe, or an exchange rate, which is by nature long in one instrument, short another, so may not be marked by severe volatility to the downside), and thus, trends to the upside are more sustained, while moves to the downside happen much more quickly, and by the time there is “sufficient evidence” (at any level of evidence) of a move to the downside, the largest part of the move already happened, and it’s much more likely that a short trade would get whipsawed for a loss.

If the other extreme is tried–that is, a more conservative delta parameter (.1), and a much larger period (greater than 120 days, to attempt to implement this more as a filter, in this case, 140), these are the results:

> (aggPF <- sum(tStats$Gross.Profits)/-sum(tStats$Gross.Losses))
[1] 1.157702
> (numTrades <- sum(tStats$Num.Trades))
[1] 77
> (aggCorrect <- sum(tStats$Num.Trades*tStats$Percent.Positive/100)/numTrades)
[1] 0.4155857
> (meanAvgWLR <- mean(tStats$Avg.WinLoss.Ratio))
[1] NaN

The NaN means that one or more of the instruments had so few trades that there were no losers (most likely 1 or 2 trades that just so happened to get lucky), E.G. XLU had 1 trade.

Again, nothing worth writing home over. Even after I tried several different settings (for instance, if the delta parameter is too high, most of the move to the downside in the crisis will be missed, and any profit will get consumed by the recovery, and then some), when the best result barely breaks even in a once-in-a-lifetime crisis, and so many other configurations either bite too easily on minor dips in an uptrend, or the converse, are too afraid to enter even in a once-in-a-lifetime opportunity, it’s best to not even try to fit this square peg into a round hole, and just not even think about trying Trend Vigor on the short end in equities.

For the record, here’s the equity curve.

So even when the indicator gets the once-in-a-lifetime black swan opportunity, it still manages to do little noteworthy. To put it into perspective, let’s once again look at XLB.

Basically, enter late, exit late (meaning there’s a lot of lag to this computation) on the filter end, and bite too easily on the short-term trading end.

In other words, as a standalone indicator, I’d be careful with it. Originally, this indicator was meant to be a predictor of trending vs. cycling. And essentially, at least when it comes to equities, it fails miserably, taking many trades it shouldn’t in an environment that steadily grinds upwards. This makes me believe that in a trend that grinds downwards, that a long strategy would be similarly disastrous. In short, in my opinion, the Trend Vigor indicator fails its original stated purpose, which is to partition markets into trending/cycling/trending downwards.

This all in mind, let’s see what happened to our holdout data–that is, from 2011 onwards using the long-only ATR position-sizing strategy through 2011 to present day (that is, the current date as of the time of this writing, which is June 9th, 2014, or “2014-06-09″).

Nothing spectacular, that’s for certain. Here are the results:

Trade stats:

                        EFA      EPP      EWA      EWC      EWG
Num.Txns              31.00    39.00    37.00    27.00    29.00
Num.Trades            16.00    20.00    19.00    14.00    15.00
Net.Trading.PL      1006.37 -1067.24  -777.68  -239.11  1820.57
Avg.Trade.PL          62.90   -53.36   -40.93   -17.08   121.37
Med.Trade.PL        -132.88   -71.38   -98.26  -332.33  -151.21
Largest.Winner      1434.98  1085.83  1678.21  1057.21  1517.68
Largest.Loser      -1380.12 -1025.44 -1268.16  -953.35  -834.48
Gross.Profits       4939.32  4273.32  4932.19  4821.37  5546.32
Gross.Losses       -3932.95 -5340.56 -5709.87 -5060.48 -3725.75
Std.Dev.Trade.PL     702.30   626.78   735.31   804.69   761.01
Percent.Positive      43.75    40.00    47.37    42.86    40.00
Percent.Negative      56.25    60.00    52.63    57.14    60.00
Profit.Factor          1.26     0.80     0.86     0.95     1.49
Avg.Win.Trade        705.62   534.16   548.02   803.56   924.39
Med.Win.Trade        720.56   533.59   363.94   874.10   889.67
Avg.Losing.Trade    -436.99  -445.05  -570.99  -632.56  -413.97
Med.Losing.Trade    -319.93  -297.21  -514.73  -625.85  -394.68
Avg.Daily.PL          13.16   -59.45   -50.63  -121.83    79.13
Med.Daily.PL        -140.36   -80.61  -131.59  -429.16  -187.01
Std.Dev.Daily.PL     697.17   643.35   755.38   731.48   771.27
Ann.Sharpe             0.30    -1.47    -1.06    -2.64     1.63
Max.Drawdown       -2826.18 -3230.34 -3731.81 -3230.98 -2594.95
Profit.To.Max.Draw     0.36    -0.33    -0.21    -0.07     0.70
Avg.WinLoss.Ratio      1.61     1.20     0.96     1.27     2.23
Med.WinLoss.Ratio      2.25     1.80     0.71     1.40     2.25
Max.Equity          2628.13   352.15   229.19  1555.99  3032.24
Min.Equity         -1639.66 -2878.19 -3507.75 -1674.99 -1430.39
End.Equity          1006.37 -1067.24  -777.68  -239.11  1820.57

                        EWH      EWJ      EWS      EWT      EWU
Num.Txns              31.00    33.00    33.00    31.00    33.00
Num.Trades            15.00    17.00    17.00    16.00    17.00
Net.Trading.PL      -230.79 -1209.81  -348.15 -2362.66 -2162.86
Avg.Trade.PL         -15.39   -71.17   -20.48  -147.67  -127.23
Med.Trade.PL        -178.21  -319.55  -199.30  -150.33   -76.03
Largest.Winner      2303.00  2887.37  1185.85  1179.33  1032.23
Largest.Loser      -1069.43 -2169.74 -1076.99 -1795.83 -1195.97
Gross.Profits       5306.60  5403.59  4539.11  3425.73  3320.74
Gross.Losses       -5537.39 -6613.40 -4887.26 -5788.39 -5483.60
Std.Dev.Trade.PL     963.23  1029.16   698.54   728.75   672.01
Percent.Positive      33.33    35.29    41.18    37.50    41.18
Percent.Negative      66.67    64.71    58.82    62.50    58.82
Profit.Factor          0.96     0.82     0.93     0.59     0.61
Avg.Win.Trade       1061.32   900.60   648.44   570.96   474.39
Med.Win.Trade        975.54   597.00   578.61   491.34   371.68
Avg.Losing.Trade    -553.74  -601.22  -488.73  -578.84  -548.36
Med.Losing.Trade    -491.03  -487.30  -489.20  -575.76  -426.36
Avg.Daily.PL         -23.37  -130.20   -89.64  -179.67  -199.37
Med.Daily.PL        -291.79  -321.44  -212.21  -153.16  -133.24
Std.Dev.Daily.PL     999.07  1032.75   658.59   742.60   622.35
Ann.Sharpe            -0.37    -2.00    -2.16    -3.84    -5.09
Max.Drawdown       -2594.56 -4926.69 -3641.30 -4719.71 -4105.55
Profit.To.Max.Draw    -0.09    -0.25    -0.10    -0.50    -0.53
Avg.WinLoss.Ratio      1.92     1.50     1.33     0.99     0.87
Med.WinLoss.Ratio      1.99     1.23     1.18     0.85     0.87
Max.Equity          2143.41  2447.92  1925.63   928.36   915.55
Min.Equity         -2540.25 -3809.54 -1715.67 -3791.36 -3190.00
End.Equity          -230.79 -1209.81  -348.15 -2362.66 -2162.86

                        EWY      EWZ      EZU      IEF      IGE
Num.Txns              35.00    38.00    41.00    31.00    33.00
Num.Trades            18.00    19.00    21.00    16.00    17.00
Net.Trading.PL     -2694.52 -2396.04   859.85  3933.39  1868.20
Avg.Trade.PL        -149.70  -126.11    40.95   245.84   109.89
Med.Trade.PL          12.78  -286.33    14.46    51.79    40.66
Largest.Winner       583.36   809.58  1157.57  2216.26  1422.14
Largest.Loser      -1506.45  -791.25  -658.35  -496.69 -1458.75
Gross.Profits       2579.07  2727.04  4061.44  6119.33  6139.07
Gross.Losses       -5273.59 -5123.08 -3201.60 -2185.94 -4270.87
Std.Dev.Trade.PL     562.04   467.07   465.97   740.00   814.68
Percent.Positive      50.00    31.58    52.38    50.00    52.94
Percent.Negative      50.00    68.42    47.62    50.00    47.06
Profit.Factor          0.49     0.53     1.27     2.80     1.44
Avg.Win.Trade        286.56   454.51   369.22   764.92   682.12
Med.Win.Trade        262.99   453.56   221.78   549.08   426.84
Avg.Losing.Trade    -585.95  -394.08  -320.16  -273.24  -533.86
Med.Losing.Trade    -466.95  -354.64  -304.80  -286.43  -399.31
Avg.Daily.PL        -164.86  -126.11    14.04   239.13     3.55
Med.Daily.PL         -45.85  -286.33   -17.84    -3.45   -36.71
Std.Dev.Daily.PL     575.53   467.07   461.04   765.47   709.12
Ann.Sharpe            -4.55    -4.29     0.48     4.96     0.08
Max.Drawdown       -3796.28 -3435.45 -2154.32 -2166.31 -3368.63
Profit.To.Max.Draw    -0.71    -0.70     0.40     1.82     0.55
Avg.WinLoss.Ratio      0.49     1.15     1.15     2.80     1.28
Med.WinLoss.Ratio      0.56     1.28     0.73     1.92     1.07
Max.Equity           738.72   180.61  1947.51  4512.77  1868.20
Min.Equity         -3057.56 -3254.84 -1321.26  -576.85 -1540.72
End.Equity         -2694.52 -2396.04   859.85  3933.39  1868.20

                        IYR      IYZ      LQD      RWR      SHY
Num.Txns              27.00    29.00    35.00    27.00    31.00
Num.Trades            14.00    15.00    17.00    14.00    16.00
Net.Trading.PL      3676.71  1141.84  3885.88  2503.47  2087.28
Avg.Trade.PL         262.62    76.12   228.58   178.82   130.46
Med.Trade.PL         216.71    59.28   140.49   167.95    83.51
Largest.Winner      1597.44  2165.96   813.01  1725.22  2018.03
Largest.Loser      -1205.43 -1087.93  -880.30 -1435.08  -564.72
Gross.Profits       6179.06  5208.19  7516.04  6097.92  4069.39
Gross.Losses       -2502.35 -4066.35 -3630.16 -3594.45 -1982.11
Std.Dev.Trade.PL     752.85   894.64   896.25   886.91   592.27
Percent.Positive      57.14    60.00    52.94    57.14    56.25
Percent.Negative      42.86    40.00    47.06    42.86    43.75
Profit.Factor          2.47     1.28     2.07     1.70     2.05
Avg.Win.Trade        772.38   578.69   835.12   762.24   452.15
Med.Win.Trade        694.95   319.46   673.49   454.00   281.30
Avg.Losing.Trade    -417.06  -677.72  -453.77  -599.08  -283.16
Med.Losing.Trade    -291.44  -694.92  -444.53  -435.46  -235.46
Avg.Daily.PL         198.73    77.33    59.12    96.11   111.87
Med.Daily.PL          94.41    32.47   -10.69    54.71    71.05
Std.Dev.Daily.PL     743.03   928.40   579.72   865.11   608.21
Ann.Sharpe             4.25     1.32     1.62     1.76     2.92
Max.Drawdown       -3147.23 -3389.11 -2718.68 -3029.80 -1495.18
Profit.To.Max.Draw     1.17     0.34     1.43     0.83     1.40
Avg.WinLoss.Ratio      1.85     0.85     1.84     1.27     1.60
Med.WinLoss.Ratio      2.38     0.46     1.52     1.04     1.19
Max.Equity          4203.56  2147.66  4370.31  2604.67  2311.64
Min.Equity          -651.36 -3389.11  -594.50 -1612.16  -776.36
End.Equity          3676.71  1141.84  3885.88  2503.47  2087.28

                        TLT      XLB      XLE      XLF      XLI
Num.Txns              27.00    35.00    25.00    27.00    31.00
Num.Trades            14.00    18.00    13.00    14.00    16.00
Net.Trading.PL      4188.91  1525.85  3015.76  3312.93  5243.37
Avg.Trade.PL         299.21    84.77   231.98   236.64   327.71
Med.Trade.PL         -29.23    99.39   -25.64    47.93   139.79
Largest.Winner      3310.84   909.91  2265.85  1907.25  2116.29
Largest.Loser       -829.51  -894.26 -1356.04  -652.95  -873.32
Gross.Profits       6548.35  4078.77  6369.44  5587.83  7236.98
Gross.Losses       -2359.44 -2552.93 -3353.68 -2274.90 -1993.61
Std.Dev.Trade.PL    1025.04   460.16  1021.63   735.76   767.98
Percent.Positive      50.00    55.56    46.15    57.14    62.50
Percent.Negative      50.00    44.44    53.85    42.86    37.50
Profit.Factor          2.78     1.60     1.90     2.46     3.63
Avg.Win.Trade        935.48   407.88  1061.57   698.48   723.70
Med.Win.Trade        436.88   334.09  1028.27   607.54   565.35
Avg.Losing.Trade    -337.06  -319.12  -479.10  -379.15  -332.27
Med.Losing.Trade    -296.04  -262.59  -335.76  -367.86  -203.93
Avg.Daily.PL         257.88    43.28   108.37   212.17   300.65
Med.Daily.PL         -77.71    94.92   -79.46     8.01    50.98
Std.Dev.Daily.PL    1054.69   438.26   960.17   759.85   787.00
Ann.Sharpe             3.88     1.57     1.79     4.43     6.06
Max.Drawdown       -3113.33 -2417.02 -3108.53 -2224.39 -2732.59
Profit.To.Max.Draw     1.35     0.63     0.97     1.49     1.92
Avg.WinLoss.Ratio      2.78     1.28     2.22     1.84     2.18
Med.WinLoss.Ratio      1.48     1.27     3.06     1.65     2.77
Max.Equity          5888.75  1525.85  3093.03  3738.75  5376.79
Min.Equity          -164.65 -1872.16  -225.30 -1541.00 -1030.57
End.Equity          4188.91  1525.85  3015.76  3312.93  5243.37

                        XLK      XLP      XLU      XLV      XLY
Num.Txns              23.00    35.00    28.00    29.00    29.00
Num.Trades            12.00    18.00    14.00    15.00    15.00
Net.Trading.PL      3958.91  4574.37  4589.84  9011.73  3926.53
Avg.Trade.PL         329.91   254.13   327.85   600.78   261.77
Med.Trade.PL         341.28   -96.61     6.57   292.17   100.86
Largest.Winner      1620.74  2992.30  2675.47  4335.47  1417.86
Largest.Loser      -1651.62  -940.12  -720.35  -886.02 -1211.34
Gross.Profits       6146.50  7850.27  7382.03 10689.31  7051.77
Gross.Losses       -2187.59 -3275.90 -2792.19 -1677.58 -3125.25
Std.Dev.Trade.PL     881.64   930.65  1015.70  1235.25   813.32
Percent.Positive      66.67    38.89    50.00    60.00    53.33
Percent.Negative      33.33    61.11    50.00    40.00    46.67
Profit.Factor          2.81     2.40     2.64     6.37     2.26
Avg.Win.Trade        768.31  1121.47  1054.58  1187.70   881.47
Med.Win.Trade        688.70   925.57   994.86  1188.08   980.24
Avg.Losing.Trade    -546.90  -297.81  -398.88  -279.60  -446.46
Med.Losing.Trade    -225.21  -263.58  -350.39  -232.60  -258.03
Avg.Daily.PL         272.88   172.49   327.85   615.92   221.10
Med.Daily.PL         226.83  -109.64     6.57   255.91    37.76
Std.Dev.Daily.PL     901.16   890.38  1015.70  1280.43   828.05
Ann.Sharpe             4.81     3.08     5.12     7.64     4.24
Max.Drawdown       -3054.65 -2491.74 -1541.47 -2349.89 -2867.34
Profit.To.Max.Draw     1.30     1.84     2.98     3.83     1.37
Avg.WinLoss.Ratio      1.40     3.77     2.64     4.25     1.97
Med.WinLoss.Ratio      3.06     3.51     2.84     5.11     3.80
Max.Equity          4217.59  5106.00  5446.02  9151.52  4598.69
Min.Equity         -1749.61 -1029.25  -898.16  -380.08 -1603.57
End.Equity          3958.91  4574.37  4589.84  9011.73  3926.53

> (aggPF <- sum(tStats$Gross.Profits)/-sum(tStats$Gross.Losses))
[1] 1.463801
> (aggCorrect <- mean(tStats$Percent.Positive))
[1] 48.769
> (numTrades <- sum(tStats$Num.Trades))
[1] 482
> (meanAvgWLR <- mean(tStats$Avg.WinLoss.Ratio))
[1] 1.749667

Overall, it still was profitable, but definitely not impressively so. For the first time, the 50% mark got broken, which essentially contradicted the uniqueness of the indicator to begin with.

Here are the daily stats:

                         EFA       EPP       EWA       EWC       EWG
Total.Net.Profit     1006.37  -1067.24   -777.68   -239.11   1820.57
Total.Days            552.00    543.00    541.00    506.00    547.00
Winning.Days          298.00    277.00    271.00    268.00    289.00
Losing.Days           254.00    266.00    270.00    238.00    258.00
Avg.Day.PL              1.82     -1.97     -1.44     -0.47      3.33
Med.Day.PL             17.00      2.90      3.39     10.01     17.65
Largest.Winner        529.45    471.21    468.52    368.67    484.27
Largest.Loser        -680.76   -725.06   -519.09   -545.42   -655.86
Gross.Profits       33513.80  30081.53  30541.36  24265.15  34491.17
Gross.Losses       -32507.43 -31148.77 -31319.04 -24504.26 -32670.61
Std.Dev.Daily.PL      158.32    146.60    146.24    126.51    161.06
Percent.Positive       53.99     51.01     50.09     52.96     52.83
Percent.Negative       46.01     48.99     49.91     47.04     47.17
Profit.Factor           1.03      0.97      0.98      0.99      1.06
Avg.Win.Day           112.46    108.60    112.70     90.54    119.35
Med.Win.Day            97.46     89.05     94.25     74.00     97.54
Avg.Losing.Day       -127.98   -117.10   -116.00   -102.96   -126.63
Med.Losing.Day        -93.07    -91.19    -93.91    -84.12    -90.41
Avg.Daily.PL            1.82     -1.97     -1.44     -0.47      3.33
Med.Daily.PL           17.00      2.90      3.39     10.01     17.65
Std.Dev.Daily.PL.1    158.32    146.60    146.24    126.51    161.06
Ann.Sharpe              0.18     -0.21     -0.16     -0.06      0.33
Max.Drawdown        -2826.18  -3230.34  -3731.81  -3230.98  -2594.95
Profit.To.Max.Draw      0.36     -0.33     -0.21     -0.07      0.70
Avg.WinLoss.Ratio       0.88      0.93      0.97      0.88      0.94
Med.WinLoss.Ratio       1.05      0.98      1.00      0.88      1.08
Max.Equity           2628.13    352.15    229.19   1555.99   3032.24
Min.Equity          -1639.66  -2878.19  -3507.75  -1674.99  -1430.39
End.Equity           1006.37  -1067.24   -777.68   -239.11   1820.57

                         EWH       EWJ       EWS       EWT       EWU
Total.Net.Profit     -230.79  -1209.81   -348.15  -2362.66  -2162.86
Total.Days            485.00    483.00    473.00    467.00    523.00
Winning.Days          250.00    257.00    241.00    230.00    267.00
Losing.Days           235.00    226.00    232.00    237.00    256.00
Avg.Day.PL             -0.48     -2.50     -0.74     -5.06     -4.14
Med.Day.PL              7.87     18.54     10.40     -7.66      8.92
Largest.Winner        442.74    856.67    728.55    509.94    419.63
Largest.Loser        -588.60  -1761.76  -1098.11   -612.79   -859.75
Gross.Profits       26844.49  34106.49  27148.71  25496.48  28167.12
Gross.Losses       -27075.28 -35316.31 -27496.86 -27859.13 -30329.98
Std.Dev.Daily.PL      144.50    205.32    156.16    147.47    148.73
Percent.Positive       51.55     53.21     50.95     49.25     51.05
Percent.Negative       48.45     46.79     49.05     50.75     48.95
Profit.Factor           0.99      0.97      0.99      0.92      0.93
Avg.Win.Day           107.38    132.71    112.65    110.85    105.49
Med.Win.Day            84.03    116.20     83.22     89.79     88.48
Avg.Losing.Day       -115.21   -156.27   -118.52   -117.55   -118.48
Med.Losing.Day        -87.60   -120.69   -102.84    -89.96    -87.51
Avg.Daily.PL           -0.48     -2.50     -0.74     -5.06     -4.14
Med.Daily.PL            7.87     18.54     10.40     -7.66      8.92
Std.Dev.Daily.PL.1    144.50    205.32    156.16    147.47    148.73
Ann.Sharpe             -0.05     -0.19     -0.07     -0.54     -0.44
Max.Drawdown        -2594.56  -4926.69  -3641.30  -4719.71  -4105.55
Profit.To.Max.Draw     -0.09     -0.25     -0.10     -0.50     -0.53
Avg.WinLoss.Ratio       0.93      0.85      0.95      0.94      0.89
Med.WinLoss.Ratio       0.96      0.96      0.81      1.00      1.01
Max.Equity           2143.41   2447.92   1925.63    928.36    915.55
Min.Equity          -2540.25  -3809.54  -1715.67  -3791.36  -3190.00
End.Equity           -230.79  -1209.81   -348.15  -2362.66  -2162.86

                         EWY       EWZ       EZU       IEF       IGE
Total.Net.Profit    -2694.52  -2396.04    859.85   3933.39   1868.20
Total.Days            462.00    414.00    522.00    550.00    511.00
Winning.Days          234.00    191.00    272.00    301.00    266.00
Losing.Days           228.00    223.00    250.00    249.00    245.00
Avg.Day.PL             -5.83     -5.79      1.65      7.15      3.66
Med.Day.PL              2.90    -12.33     13.44     17.64      8.26
Largest.Winner        623.44    473.66    535.69    557.51    498.52
Largest.Loser        -770.87   -395.63   -693.00   -532.96   -700.75
Gross.Profits       25858.43  18710.54  30720.38  34230.37  30004.54
Gross.Losses       -28552.95 -21106.58 -29860.53 -30296.98 -28136.35
Std.Dev.Daily.PL      154.74    123.77    154.44    150.09    148.66
Percent.Positive       50.65     46.14     52.11     54.73     52.05
Percent.Negative       49.35     53.86     47.89     45.27     47.95
Profit.Factor           0.91      0.89      1.03      1.13      1.07
Avg.Win.Day           110.51     97.96    112.94    113.72    112.80
Med.Win.Day            85.46     78.98     91.36     95.75     94.04
Avg.Losing.Day       -125.23    -94.65   -119.44   -121.67   -114.84
Med.Losing.Day        -99.45    -75.00    -85.26    -96.03    -93.28
Avg.Daily.PL           -5.83     -5.79      1.65      7.15      3.66
Med.Daily.PL            2.90    -12.33     13.44     17.64      8.26
Std.Dev.Daily.PL.1    154.74    123.77    154.44    150.09    148.66
Ann.Sharpe             -0.60     -0.74      0.17      0.76      0.39
Max.Drawdown        -3796.28  -3435.45  -2154.32  -2166.31  -3368.63
Profit.To.Max.Draw     -0.71     -0.70      0.40      1.82      0.55
Avg.WinLoss.Ratio       0.88      1.03      0.95      0.93      0.98
Med.WinLoss.Ratio       0.86      1.05      1.07      1.00      1.01
Max.Equity            738.72    180.61   1947.51   4512.77   1868.20
Min.Equity          -3057.56  -3254.84  -1321.26   -576.85  -1540.72
End.Equity          -2694.52  -2396.04    859.85   3933.39   1868.20

                         IYR       IYZ       LQD       RWR       SHY
Total.Net.Profit     3676.71   1141.84   3885.88   2503.47   2087.28
Total.Days            585.00    529.00    608.00    582.00    481.00
Winning.Days          318.00    280.00    330.00    317.00    268.00
Losing.Days           267.00    249.00    278.00    265.00    213.00
Avg.Day.PL              6.28      2.16      6.39      4.30      4.34
Med.Day.PL             13.80     11.00     13.47     15.00     32.73
Largest.Winner        337.12    656.22    500.32    373.09    317.45
Largest.Loser        -553.69   -486.69   -917.90   -653.56   -379.80
Gross.Profits       29882.84  30424.77  34069.25  30740.26  24931.27
Gross.Losses       -26206.13 -29282.93 -30183.37 -28236.79 -22843.99
Std.Dev.Daily.PL      126.57    148.05    141.44    133.93    118.12
Percent.Positive       54.36     52.93     54.28     54.47     55.72
Percent.Negative       45.64     47.07     45.72     45.53     44.28
Profit.Factor           1.14      1.04      1.13      1.09      1.09
Avg.Win.Day            93.97    108.66    103.24     96.97     93.03
Med.Win.Day            75.05     86.40     88.16     80.63     76.66
Avg.Losing.Day        -98.15   -117.60   -108.57   -106.55   -107.25
Med.Losing.Day        -76.33    -91.42    -79.49    -79.00    -84.65
Avg.Daily.PL            6.28      2.16      6.39      4.30      4.34
Med.Daily.PL           13.80     11.00     13.47     15.00     32.73
Std.Dev.Daily.PL.1    126.57    148.05    141.44    133.93    118.12
Ann.Sharpe              0.79      0.23      0.72      0.51      0.58
Max.Drawdown        -3147.23  -3389.11  -2718.68  -3029.80  -1495.18
Profit.To.Max.Draw      1.17      0.34      1.43      0.83      1.40
Avg.WinLoss.Ratio       0.96      0.92      0.95      0.91      0.87
Med.WinLoss.Ratio       0.98      0.95      1.11      1.02      0.91
Max.Equity           4203.56   2147.66   4370.31   2604.67   2311.64
Min.Equity           -651.36  -3389.11   -594.50  -1612.16   -776.36
End.Equity           3676.71   1141.84   3885.88   2503.47   2087.28

                         TLT       XLB       XLE       XLF       XLI
Total.Net.Profit     4188.91   1525.85   3015.76   3312.93   5243.37
Total.Days            471.00    542.00    558.00    558.00    610.00
Winning.Days          249.00    284.00    287.00    296.00    340.00
Losing.Days           222.00    258.00    271.00    262.00    270.00
Avg.Day.PL              8.89      2.82      5.40      5.94      8.60
Med.Day.PL             11.18      8.22      6.80      9.76     17.38
Largest.Winner        862.40    403.44    588.27    479.24    546.63
Largest.Loser       -1060.30   -512.20   -714.31   -517.42   -683.29
Gross.Profits       35487.37  29115.38  32217.78  30912.49  35259.17
Gross.Losses       -31298.46 -27589.53 -29202.02 -27599.56 -30015.80
Std.Dev.Daily.PL      196.23    133.68    149.57    138.38    140.46
Percent.Positive       52.87     52.40     51.43     53.05     55.74
Percent.Negative       47.13     47.60     48.57     46.95     44.26
Profit.Factor           1.13      1.06      1.10      1.12      1.17
Avg.Win.Day           142.52    102.52    112.26    104.43    103.70
Med.Win.Day           102.88     87.66     92.71     78.10     83.42
Avg.Losing.Day       -140.98   -106.94   -107.76   -105.34   -111.17
Med.Losing.Day       -109.53    -80.39    -75.03    -79.98    -86.96
Avg.Daily.PL            8.89      2.82      5.40      5.94      8.60
Med.Daily.PL           11.18      8.22      6.80      9.76     17.38
Std.Dev.Daily.PL.1    196.23    133.68    149.57    138.38    140.46
Ann.Sharpe              0.72      0.33      0.57      0.68      0.97
Max.Drawdown        -3113.33  -2417.02  -3108.53  -2224.39  -2732.59
Profit.To.Max.Draw      1.35      0.63      0.97      1.49      1.92
Avg.WinLoss.Ratio       1.01      0.96      1.04      0.99      0.93
Med.WinLoss.Ratio       0.94      1.09      1.24      0.98      0.96
Max.Equity           5888.75   1525.85   3093.03   3738.75   5376.79
Min.Equity           -164.65  -1872.16   -225.30  -1541.00  -1030.57
End.Equity           4188.91   1525.85   3015.76   3312.93   5243.37

                         XLK       XLP       XLU       XLV       XLY
Total.Net.Profit     3958.91   4574.37   4589.84   9011.73   3926.53
Total.Days            602.00    626.00    601.00    654.00    630.00
Winning.Days          330.00    336.00    327.00    364.00    336.00
Losing.Days           272.00    290.00    274.00    290.00    294.00
Avg.Day.PL              6.58      7.31      7.64     13.78      6.23
Med.Day.PL             16.15     13.40     19.19     16.24     14.51
Largest.Winner        499.03    497.92    355.08    621.11    421.68
Largest.Loser        -683.59   -531.11   -428.09   -537.68   -741.65
Gross.Profits       34611.16  36209.36  33101.33  41438.23  34800.70
Gross.Losses       -30652.25 -31634.99 -28511.49 -32426.50 -30874.17
Std.Dev.Daily.PL      145.31    141.74    129.06    150.70    138.44
Percent.Positive       54.82     53.67     54.41     55.66     53.33
Percent.Negative       45.18     46.33     45.59     44.34     46.67
Profit.Factor           1.13      1.14      1.16      1.28      1.13
Avg.Win.Day           104.88    107.77    101.23    113.84    103.57
Med.Win.Day            83.12     85.88     81.77     88.52     82.08
Avg.Losing.Day       -112.69   -109.09   -104.06   -111.82   -105.01
Med.Losing.Day        -83.28    -79.67    -81.43    -78.85    -73.23
Avg.Daily.PL            6.58      7.31      7.64     13.78      6.23
Med.Daily.PL           16.15     13.40     19.19     16.24     14.51
Std.Dev.Daily.PL.1    145.31    141.74    129.06    150.70    138.44
Ann.Sharpe              0.72      0.82      0.94      1.45      0.71
Max.Drawdown        -3054.65  -2491.74  -1541.47  -2349.89  -2867.34
Profit.To.Max.Draw      1.30      1.84      2.98      3.83      1.37
Avg.WinLoss.Ratio       0.93      0.99      0.97      1.02      0.99
Med.WinLoss.Ratio       1.00      1.08      1.00      1.12      1.12
Max.Equity           4217.59   5106.00   5446.02   9151.52   4598.69
Min.Equity          -1749.61  -1029.25   -898.16   -380.08  -1603.57
End.Equity           3958.91   4574.37   4589.84   9011.73   3926.53

Basically, it seems that while the domestic side of equities seemed to do fairly well, the international side of the trade really hurt. For once, the perils of diversification are apparent. Here are the portfolio statistics:

> SharpeRatio.annualized(portfRets)
                                     [,1]
Annualized Sharpe Ratio (Rf=0%) 0.4074399
> Return.annualized(portfRets)
                        [,1]
Annualized Return 0.04448638
> maxDrawdown(portfRets)
[1] 0.1439702

So, ho-hum annualized returns, but the Sharpe Ratio at this point is far from stellar, and the drawdowns are definitely disappointing. Here is the resultant equity curve comparison.

In other words, it kept pace with the S&P 500 up until the beginning of 2013 (when in fact, their performance was just about equal), with less violent (but longer-lasting) drawdowns. Unfortunately, starting in mid-2013, the S&P 500 roared away, while the strategy just seemed to be flat, at the new equity high. This would probably anger quite a few investors. Let’s check out an equity curve from a losing security and see what happened.


#Individual instrument equity curve
chart.Posn(portfolio.st, "EWJ")
tmp <- TVI(Cl(EWJ), period=period, delta=delta, triggerLag=1)
add_TA(tmp$vigor, lwd=3)
add_TA(tmp$trigger, on=5, col="red", lwd=1.5)
tmp2 <- lagATR(HLC=HLC(EWJ), n=period)
add_TA(tmp2$atr, col="blue", lwd=2)

In short, Trend Vigor as an entry indicator seems to be like the rest of the usual trend following indicators. Susceptible to buying tops and getting caught in cycles, gives back open equity (see that long trade in 2012-2013), takes counter-trend trades, but essentially at the price of incorporating a bunch of mathematics far more complex than the usual SMAs and EMAs, and at best, to marginally better results.

So does this mean that there was absolutely nothing to take away from this?

Well, no. Trend Vigor is something that can be added to a repertoire of indicators. Unlike the usual SMA and EMA fare, the advantage that Trend Vigor has is that over longer time horizons, assuming gradual trends (as opposed to the steep drops in things such as equities), is that it still can get things right more often than not, and when it does, the average win to loss profile is usually impressive. However, a marginal improvement over the basics isn’t what trend vigor was originally advertised to be, so much as a reliable market mode indicator. And in a trending environment, even your basic SMA crossovers will make money. In an oscillating environment, even the most basic RSI plug-and-chug will make money. The key, of course, is to try and find an indicator that will tell you what to deploy when. And for that purpose, unlike what was advertised in the original John Ehlers presentation, Trend Vigor, as far as this investigation has led me, is *not* that.

Thanks for reading.


To leave a comment for the author, please follow the link and comment on their blog: QuantStrat TradeR » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.