Saturday, October 3, 2009

regression weighted count on trend


Method
1. look back previous X number of price movements
2. if the latest price shows an upward move, add +1 and weighted it ( X - 1 )
3. like wise if the 2nd price goes downward, add -1 and weighted it ( X - 2 )
4. At the end, if you have a positive sum, generally it is an up trend
5. If the sum is negative, it is a down trend

Parameters
1. Number of previous data to analyse
2. Percentage of occurance to determine it is considered a trend


Reason
You are taking previous data to decide the trend. By the time you have enough data to prove the trend, the trend may already be ended. The only time this will work is a very pro-long trend like this.

Most of the other time, it may become like this :


Hence there will never be a single set of parameters that can cater for all situations.

Codes
extern int TRACEBACK = 100 ; // trace back to 100 points
extern double TRENDCUTOFF = 0.6 ; // if occur more than 60% of the time

for(i=0 ; i <>
o=Open[i];
oprev=Open[i+1];

// weigthed up or down count, open to open, close to close
if(o > oprev) {
regoCount = regoCount + (TRACEBACK-i);
}else if(o <>
regoCount = regoCount - (TRACEBACK-i);
}
int tb = TRACEBACK ;
double tbsum = (tb / 2 - 1) * tb + tb + tb/2 ;
regoCount = regoCount / tbsum ; // make it into a percentage

if(upCount > (TRACEBACK * TRENDCUTOFF)) upCountTrend = true;
if(downCount > (TRACEBACK * TRENDCUTOFF)) downCountTrend = true;
if((upTrend==false) && (downTrend==false)) sideCountTrend = true;

No comments:

Post a Comment