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

Function NTHighestBar in Tradestation has a bug



PureBytes Links

Trading Reference Links

At least in SP2 for TS2K, is this corrected in SP3?

(NTHHighestBar code is below, with line pointing to error):


If Nth <= Length  AND Nth <= 100 Then Begin
	For value1 = 0 To Length - 1 Begin
		PriceArray[value1] = Price[value1];
		BarNumArray[value1] = value1;
	End;
	For value1 = 0 To Nth - 1 Begin
		For value2 =  value1 + 1 To Length - 1 Begin
			If PriceArray[value2] > PriceArray[value1] Then
Begin
				Value3 = PriceArray[value1];
				PriceArray[value1] = PriceArray[value2];
				PriceArray[value2] = Value3;
				Value1 = BarNumArray[value1];
***************************************^^^^^^^ Error, should read Value3
***************
				BarNumArray[value1] = BarNumArray[value2];
				BarNumArray[value2] = Value3;
			End;
		End;
	End;
	NthHighestBar = BarNumArray[Nth - 1];
End
Else
	NthHighestBar = -1;

--- Mats ---