In this series of posts I share my exploration of the use of the DVI indicator in a strategy be applied to a broader set of ETF’s. The strategy will use the DVI indicator complemented with a long term filter and short term timing mechanism. Applying of the strategy to a portfolio of ETF’s will allow’s to assess its robustness. It will also provide the basis for further analysis on portfolio’s of strategies in the next post.

### DVI 50/50 Strategy

In the analysis over at MarketSci it was shown that the DVI acts as a mid-term contrarian indicator with a tendency to favour long markets. The analysis applied a simple DVI 50/50 strategy to the S&P500 index to the period 1970 to Present. In the table below I have reconstructed the DVI 50/50 strategy and applied it to a broad portfolio of 26 ETF’s. The period covered is 1-1-2003 to Present. Starting Equity was 25.000$ and Interactive Broker commission’s schedule was used. Rf was set at 4%. The table shows that the DVI indicator does a good job for the SPY, however for 6 other ETF’s it fails to reach a positive DVR.

### DVI 50/50 Strategy with Filter for Shorts

From adding a long-term filter for the shorts side we expect to see some improvements. The filter is based on the percentile(array, period, percentile) function in Amibroker. This function returns the array value that is ranked at the percentile level. The filter that will be applied is C<Percentile (c,200,40) which forces today’s close to be below the close price at 40th percentile of last 200 closes.

The table shows that the performance indicators have improved in all areas (Profit, DD) and that the number of ETF’s with negative DVR has reduced to 2.

### DVI 50/50 + LT filter shorts + Timing

In the last modicfication for this post, we will add a short-term timing mechanism. This mechanism uses the DV2 indicator as invented by David Varadi. The DV2 indicator has been widely reviewed and considered to be a better & more robust alternative for the RSI2. We will modify the sDVI 50/50 strategy by including DV2 oversold (<50) condition for buys and overbought (>50)conditions for shorts. The table below provides the summary for this strategy.

Adding the timing component clearly further improved the strategy. What I like about it is the fact that it works for most of 26 – diverse asset category – ETF’s.

#### The Amibroker code for the System:

#include <Boiler plate.afl>#include <Additional functions.afl>

SystemName=”sDD_ETF_DVI”;

pos=1;

SetPositionSize(25000/pos,spsValue);

SetOption(“MaxOpenPositions”, pos );

xDV2=DV2(252);

xDVI=DVI(252);

Buy=xDVI<50 AND xDV2<50;

Sell=xDV2>50;

Short=xDVI>50 AND C<Percentile(C,200,40) AND xDV2>50;

Cover=xDV2<50;

#include <OutputStatistics.afl>

This concludes this post. The 2nd post of this series will focus on some portfolio considerations.

Happy trading!

Could you explain the theory behind the C<percentile (c,200,40)?

Thanks,

Hi Aristotle,

I find it hard to explain further as the concept may be difficult to grasp. First, let me copy the Amibroker help file on Percentile() function:

SYNTAX Percentile( array, period, rank )

RETURNS ARRAY

FUNCTION The Percentile function gives rank percentile value of the array over last period bars.

rank is 0..100 – defines percentile rank in the array

EXAMPLE // Example 1:

// show bars when ‘current’ Day Volume ranks within

// TOP 30% of volumes of last 100 bars (is above 70th Percentile)

Filter = Volume > Percentile( Volume, 100, 70 );

The filter c<percentile(c,200,40) looks for the past 200 close prices, and will look at the value of close that marks the 40th percentile. So if all 200 values would be sorted, the 40th percentile close would have 40%*200 is 79 close prices below it's value and 120 close prices above it's value. The filter then compares that 40th percentile close price with current price. If current price is below (so it ranks in the bottom 40% of last 200 prices) the filter is true.

You can view this type of filter as a more adaptive filter compared to traditional filters like c<ma(c,200).

Regards, Michel

Did you set it below X(40th percentile) to target stocks in a downward trend? As a CSS subscriber, I’m just trying to understand the thought process to improve the baseline strategies.

Thanks

Yes you got it, I have set it below x(40th) to ensure stocks are trading in bottom 40% of prices i.e. in a downward trend.

Michel

hi

congrats on the MEOM positions. have u closed them? great work.

I have a question about the afl code. The 2 includes (#include ,#include ). What do they have? I am guess the Dv implementation.

Hi Trading4p,

Yes I did close the MEOM positions, one at +3.26% and one at +3.51%. I like it when a plan comes together…

As to the include statements, one #include statement (the boilerplate) contains all kind of default settings in Amibroker. This is to avoid that I mix up settings and confuse myself. This way settings are always the same (e.g. commissions, risk free returns, etc). The second #include (additional functions) contains the implementaition of several non-standard Amibroker functions, including the DV calculations.

Regards, Michel

Hello Michel,

Nice performance results on different ETFs. Would you mind sharing the Amibroker code for DV2?

Keep posting!

Brian

Hi Brian, thanks for your response. I have added a post with the Amibroker code for the DV2.

Regards,

Michel

For some reason I can’t replicate the results of even the simple DVI 50/50. I used your Amibroker code for DVI; same start date, Rf, initial equity, and I assume no commissions. My entries/exits are “Buy = Cover = xDVI 50;” Your table says that the CAR% on SPY was 19.9% and a Max DD of 22.6%; however in my Amibroker I am getting a CAR% of 17.67% and Max DD of 25.84%. I have a feeling it’s because of the settings… do you think that’s the reason? What are your exact settings (in Boiler plate.afl)?

Great blog by the way (I am a reader of CSS, MarketSci, and Quantum Financier), keep up the good work.

Hi Troy, mmm, I will post my boilerplate file. Also do check the end-date! You should be working with history until 1 Aug 2010 as I posted on 2 Aug.

QD

Hello Quanting Dutchman ,

superb / fantastic / excellent /… marvelous work on DV.

i request you to please throw some light on PAIR trading also..

how to find good pair based on DV1 OR DV2 ??!!!

Thank you

Hi Darshan,

Thanks for your kinds words. It is good that you bring up pairs trading as this is a type of strategy that is still lacking in my stable.

I’m doing some rough first sketc research on it at the moment and I guess it will take some weeks before I will post my results. I have too many other stuff to finish first.

Let me know if you have any interesting thoughts that you want me to look into to.

QD

Ich merke gerade das ich diesen Blog deutlich ofter lesen sollte- da kommt man echt auf Ideen.

Danke!

QD