Pagina 1 van 1

TDI (Trend Detection Index) tka 4-2005 metastock code

BerichtGeplaatst: do 21 apr 2005, 13:09
door mvs
Hallo,

In tka 4-2005 staat de TDI indicator, met de bijhorende meta code,
in metastock ben ik niet zo thuis.

Kan iemand hem of heeft iemand hem al omgetoverd naar EL-code?

Metastock-formules: Trend Detection Index:
x: = Input("Tijdspanne",5,50,20);
am: = Abs(C-Ref(C,-(x-1)));
td: = Sum(C-Ref(C,-(x-1)),x);
tdi: = (Abs(td)+Sum(am,x))-Sum(am,(2*x));
status: = If(tdi>0, If(td>0,1,-1), PREV);
tdi;
td;
status*LastValue(Highest(Max(Abs(tdi),Abs(td))))


bvd,

Martin

BerichtGeplaatst: do 21 apr 2005, 13:23
door Dirk
Beste Martin,

Bij deze:

Dick.



inputs:
Price( Close ),
Length( 20 ) ;

variables:
Length2( 2 * Length ),
Mom( 0 ),
MomAbs( 0 ),
MomSum( 0 ),
MomSumAbs( 0 ),
MomAbsSum( 0 ) ,
MomAbsSum2( 0 ),
TDI( 0 ),
MktPos( 0 ) ;

Mom = Price - Price[Length] ;
MomAbs = AbsValue( Mom ) ;
MomSum = Summation( Mom, Length ) ;
MomSumAbs = AbsValue( MomSum ) ;
MomAbsSum = Summation( MomAbs, Length ) ;
MomAbsSum2 = Summation( MomAbs, Length2 ) ;

TDI = MomSumAbs - ( MomAbsSum2 - MomAbsSum ) ;
{Plot MktPos for outright buy and sell signals}
MktPos = Iff( TDI[1] > 0, Iff( MomSum[1] > 0, 1, -1 ), MktPos[1] );
Plot1( MktPos,"Position");
Plot2 (TDI, "TD Index") {for the index itself.};
Plot3 (MomSum, "Direction Indicator");

#BeginSystem('Trend Change');
if MktPos =1 then buy;
if MktPos =-1 then Sell;
#End;

BerichtGeplaatst: vr 22 apr 2005, 0:29
door mvs
Dirk,

Hartelijk dank voor je code, werkt prima, na een kleine aanpassing.

De trend is namelijk (bij mij) niet goed te zien. Soms is de TDI groter dan 1000 punten (bv nasdaq) dan word er een onzichterbare trend weer gegeven.

Dirk, bedankt.


Ik heb hem zo aangepast:

inputs:
Price( Close ),
Length( 20 ) ;

variables:
Length2( 2 * Length ),
Mom( 0 ),
MomAbs( 0 ),
MomSum( 0 ),
MomSumAbs( 0 ),
MomAbsSum( 0 ) ,
MomAbsSum2( 0 ),
TDI( 0 ),
MktPos( 0 ),
HH (0),
LL (0);

Mom = Price - Price[Length] ;
MomAbs = AbsValue( Mom ) ;
MomSum = Summation( Mom, Length ) ;
MomSumAbs = AbsValue( MomSum ) ;
MomAbsSum = Summation( MomAbs, Length ) ;
MomAbsSum2 = Summation( MomAbs, Length2 ) ;
HH = Highest(TDI,10000);
LL = Lowest (TDI,10000);
TDI = MomSumAbs - ( MomAbsSum2 - MomAbsSum ) ;
{Plot MktPos for outright buy and sell signals}
MktPos = Iff( TDI[1] > 0, Iff( MomSum[1] > 0, HH, LL ), MktPos[1] );
Plot1( MktPos,"Position");
Plot2 (TDI, "TD Index") {for the index itself.};
Plot3 (MomSum, "Direction Indicator");

#BeginSystem('Trend Change');
if MktPos >0 then buy;
if MktPos <0 then Sell;
#End;