Introduction

If we put our eyes in the code of some of the strategies in Dukascopy Strategy Contest this month (May 2012), we can see that the winning one along the month (don't is the one who gets the best performance) and the strategy with best performance, we will see that both of them use Time Segmented Volume (TSV for acronim) to trigger their entries on market. In this article we talk about this indicator.

What is Time Segmented Volume (TSV) ?

Time Segmented Volume (TSV) is a technical indicator developed by Worden Brothers Inc. TSV is a oscilator indicator that bounces arround a zero line (thats why this is a oscilator type indicator). With this indicator we can get the comparison of defined time periods and the relation between price and volume. When the TSV crosses up above the zero line it signals a positive accumulation or buying pressure showing the possibility of a bullish state. On the other hand, if TSV crosses below the zero line it indicates a distribution or selling pressure where we can enter in a bearish market.
Also we can look for divergences as stated on the site of the creator of this indicator: "Another important thing to look for when interpreting TSV is a contradiction of trends between price and TSV. Look for positive or negative divergences between price and TSV in order to determine potential tops and bottoms. Several consecutive divergences increase the reliability factor in trying to pinpoint price reversals. For instance, if price has been making successively higher highs while TSV has been making successively lower highs, this would constitute a series of negative divergences. This would be an indication of a possible top.".
Also, is indicated on this site diferent intervals depending on the timeframe or trading style used: 

  • Short Term Trading:  TSV period between 9 and 12 
  • Intermediate Term Trading: TSV period between 18 and 25 
  • Long Term Trading:  TSV period between 35 and 45 
The default value for this indicator is usualy 18 for interval setting.



TSV formula ?

As a proprietary indicator, the real formula where this indicator is based don't is available. But if we search on the net for the formula we can get some implementations for some programming languages if we want but we don't know if they match the real formula, but they appears to get similar results. As we use JForex and JForex have the source code for all indicators in JForex API and in open source TA library we have access to the implementation of this indicator. The "base" calculations of this indicator are present on the function calculate() as we can see bellow:

[CODE]
......
public IndicatorResult calculate(int startIndex, int endIndex) {
        //calculating startIndex taking into account lookback value
        if (startIndex - getLookback() < 0) {
            startIndex -= startIndex - getLookback();
        }
        if (startIndex > endIndex) {
            return new IndicatorResult(0, 0);
        }

        //multPrice
        int resIndex = 0;

        for (int z = startIndex; z <= endIndex; z++, resIndex++) {
            double sum = 0;
            for (int i = resIndex; i < (resIndex + getLookback()); i++) {
                double tmp = 0;
                if (i != resIndex) {
                    //Inputs: 0 open, 1 close, 2 high, 3 low, 4 volume
                    if  (inputs[0][1][i] > inputs[0][1][i - 1]) {
                        tmp = inputs[0][4][i] * (inputs[0][1][i] - inputs[0][1][i - 1]);
                    } else if (inputs[0][1][i] < inputs[0][1][i - 1]) {
                        tmp = (-1) * inputs[0][4][i] * (-inputs[0][1][i] + inputs[0][1][i - 1]);
                    }   else {
                        tmp = 0;
                    }
                }
                sum = sum + tmp;
            }
            outputs[0][resIndex] = sum;
        }
        return new IndicatorResult(startIndex, resIndex);
    }
......
[END CODE]

As we can see, we get a interval of time in the loops and calculate the values for "sum" based on price flow values (close price) and volume values. If actual price is greater than previous price ((inputs[0][1][i] > inputs[0][1][i - 1])) we have a positive "tmp" as the volume (inputs[0][4][i])  is always positive. On the other hand, if actual price is lesser than previous price (inputs[0][1][i] < inputs[0][1][i - 1]) we have a negative "tmp" ( tmp = (-1) * inputs[0][4][i] * (-inputs[0][1][i] + inputs[0][1][i - 1]) ). If the actual price match previous price we have "tmp = 0". After are simple aditions of values to get the final "sum" value (sum = sum + tmp).




The use of TSV on Strategy Contest

The strategy on first place (at the moment of writting this article) use two indicators to trigger entries as we can see on the following code extracted from it:

[CODE]
.....
if (positionsTotal(instrument) == 0) {
            if (bidPrice > sma14  && tvs > 0 &&  tvs1 > 0 && tvs > tvs1 ) {
                 marketorder = buy(instrument, engine, profitLimit, lossLimit, volume);                 
             }
             else  if (bidPrice < sma14  && tvs < 0 &&  tvs1 < 0 && tvs < tvs1 ) {  
                 marketorder = sell(instrument, engine, profitLimit, lossLimit, volume);   
             }   
  }
......
[END CODE]

As we can see, this strategy use sma14 (actual value of SMA(14)), tvs (for actual value of TSV(18)) and tvs1 (for previous value of TSV(18)). An entry  for buy is triggered when the price is greater than sma14, tvs and tvs1 is greater than 0 and tvs is greater than tvs1 (previous value of TSV). On the other hand a sell entry is triggered when price is bellow sma14, tvs and tvs1 is lesser than 0 and tvs lesser than tvs1. This is the base for this strategy, the rest is only configuration values as position, TP, SL, time ranges for trade, etc.

The strategy with greater performance at the moment of writing this article still uses a simpler approach with only TSV indicator as we can see in the following code excerpt:

[CODE]
.....
if (positionsTotal(instrument) == 0) {
         if (tvs>0 &&  tvs1>0) {
                 sell(instrument, engine, profitLimit, lossLimit, volume);
         }
         else  if (tvs>0 &&  0>tvs1) { 
                buy(instrument, engine, profitLimit, lossLimit, volume);   
         }   
......
[END CODE]

As we can see in this strategy, when both tvs and tvs1 are greater than 0 triggers a sell entry, and when tvs greater than 0 and tvs lesser than zero triggers a buy entry and that's all. Also this strategy have some configurations, you can see them on the complete code if you want (i say bellow where you can get it).

Final Words

If you want to go deeper on the code in this strategies, you can find them on the user profiles on Dukascopy Strategy Contest with the usernames "men79" and "radjaforex". Also you can analyse all entries. If you want to see the code for TSV indicator, you can see it in source code of JForex API. Sometimes "simpler is better" and this is the case at the moment (but not always).

I hope you like this article and as always feel free to comment or send me a private message.

Trade well and good luck!

JL 


Translate to English Show original