[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

TS Pro code not compatible with TS 2000i?!



PureBytes Links

Trading Reference Links

When I try to compile the DirMovement function in
TS2000i, I get an error.   The function is the same as
that from TS PRO.  The error is, "This word cannot
start a statement."   Line 92.  What obvious thing am
I missing?  I do not have a function called oADXR, so
that is not the problem.  Function type is series. 
Anyone know what is wrong?  If not, anyone mind
posting the DirMovement code that does compile in
TS2000i?  

Jack

The bad (TS PRO only) code follows:

{ Directional Movement multiple-output function }

inputs: 
	PriceH( numericseries ), 
	PriceL( numericseries ), 
	PriceC( numericseries ), 
	Length( numericsimple ), 
	oDMIPlus( numericref ), 
	oDMIMinus( numericref ), 
	oDMI( numericref ), 
	oADX( numericref ), 
	oADXR( numericref ),
	oVolatility( numericref ) ;

variables:
	PlusDM( 0 ), 
	MinusDM( 0 ), 
	UpperMove( 0 ), 
	LowerMove( 0 ),
	SumPlusDM( 0 ), 
	SumMinusDM( 0 ), 
	SumTR( 0 ), 
	AvgPlusDM( 0 ), 
	AvgMinusDM( 0 ), 
	SF( 1 / Length ), { smoothing factor }
	Divisor( 0 ) ;

if CurrentBar = 1 then
	begin
	for Value1 = 0 to Length - 1 
		begin
		PlusDM = 0 ;
		MinusDM = 0 ;
		UpperMove = PriceH[Value1] - PriceH[ Value1 + 1 ] ;
		LowerMove = PriceL[ Value1 + 1 ] - PriceL[Value1] ;
		if UpperMove > LowerMove and UpperMove > 0 then
			PlusDM = UpperMove
		else if LowerMove > UpperMove and LowerMove > 0 then
			MinusDM = LowerMove ;
		SumPlusDM = SumPlusDM + PlusDM ;
		SumMinusDM = SumMinusDM + MinusDM ;
		SumTR = SumTR + TrueRangeCustom( PriceH, PriceL,
PriceC )[Value1] ;
		end ;
	AvgPlusDM = SumPlusDM / Length ;
	AvgMinusDM = SumMinusDM / Length ;
	oVolatility = SumTR / Length ;
	end 
else
	begin
	PlusDM = 0 ;
	MinusDM = 0 ;
	UpperMove = PriceH - PriceH[1] ;
	LowerMove = PriceL[1] - PriceL ;
	if UpperMove > LowerMove and UpperMove > 0 then
		PlusDM = UpperMove
	else if LowerMove > UpperMove and LowerMove > 0 then
		MinusDM = LowerMove ;
	AvgPlusDM = AvgPlusDM[1] + SF * ( PlusDM -
AvgPlusDM[1] ) ;
	AvgMinusDM = AvgMinusDM[1] + SF * ( MinusDM -
AvgMinusDM[1] ) ;
	oVolatility = oVolatility[1] + SF * (
TrueRangeCustom( PriceH, PriceL, PriceC ) 
	 - oVolatility[1] ) ;
	end ;

if oVolatility = 0 then
	begin
	oDMIPlus = 0 ;
	oDMIMinus = 0 ;
	end
else
	begin
	oDMIPlus = 100 * AvgPlusDM / oVolatility ;
	oDMIMinus = 100 * AvgMinusDM / oVolatility ;
	end ;

Divisor = oDMIPlus + oDMIMinus ;
if Divisor <> 0 then
	oDMI = 100 * AbsValue( oDMIPlus - oDMIMinus ) /
Divisor 
else
	oDMI = 0 ;

if CurrentBar <= Length then
	begin
	oADX = Cum( oDMI ) / CurrentBar ;
	oADXR = ( oADX + oADX[ CurrentBar - 1 ] ) / 2 ;
	{ these approximate "length build-up" calculations
are used until we have enough 
	  data; such approximations work well for averaging
type calculations, but not 
	  summation type calculations; approximations using
"backpropagation", on the 
	  other hand, as in the MassIndex and Stochastic
functions, always work well }
	end
else
	begin
{LINE 92 (the one with the error)}	oADX = oADX[1] + SF
* ( oDMI - oADX[1] ) ;
	oADXR = ( oADX + oADX[ Length - 1 ] ) / 2 ;
	end ;

DirMovement = 1 ; { function return always 1, not
used; only outputs used }


{ *** Copyright (c) 1991-2000 TradeStation. All rights
reserved. *** }