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

bugs in nth highest bar



PureBytes Links

Trading Reference Links

Has anybody noticed that there is a bug in the nthHighestBar function
(tradestation 2001). See change below.
John Holton
{*******************************************************************
Description: Nth Highest Bar
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************}
Inputs: Nth(NumericSimple), Price(NumericSeries), Length(NumericSimple);
Array: PriceArray[100](0), BarNumArray[100](0);
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];}
{the above line should read}
value3 = barNumArray[value1];
BarNumArray[value1] = BarNumArray[value2];
BarNumArray[value2] = Value3;
End;
End;
End;
NthHighestBar = BarNumArray[Nth - 1] + CurrentBar - BarNumber ;
End
Else
NthHighestBar = -1;