InstanceCntr = 0
InstanceTest = 0
Length = 2
Strength = 1
RightStrength = Strength
LeftStrength = Strength
Highpivotprice = high
Prijs = Highpivotprice
Instance = 1
HiLo = 1
LengthCntr = RightStrength
while LengthCntr < Length and InstanceTest = 0 do
CandidatePrijs = Prijs[LengthCntr]
PivotTest = 1
StrengthCntr = LengthCntr + 1
while PivotTest = 1 and (StrengthCntr - LengthCntr =< LeftStrength) do
if ( HiLo = 1 and CandidatePrijs < Prijs[StrengthCntr]) or ( HiLo = -1 and CandidatePrijs > Prijs[StrengthCntr] ) then
PivotTest = 0
else
StrengthCntr = StrengthCntr + 1
endif
wend
StrengthCntr = LengthCntr - 1
while PivotTest = 1 and (LengthCntr - StrengthCntr <= RightStrength) do
if ( HiLo = 1 and CandidatePrijs <= Prijs[StrengthCntr] ) or ( HiLo = -1 and CandidatePrijs => Prijs[StrengthCntr] ) then
PivotTest = 0
else
StrengthCntr = StrengthCntr - 1
endif
wend
if PivotTest = 1 then
InstanceCntr = InstanceCntr + 1
if InstanceCntr = Instance then
InstanceTest = 1
else
LengthCntr = LengthCntr + 1
endif
endif
wend
if InstanceTest = 1 then
oPivotPrijs = CandidatePrijs
oPivotBar = LengthCntr //+ ExecOffset
Pivot = 1
else
oPivotPrijs = -1
oPivotBar = -1
Pivot = -1
endif
return oPivotPrijs