Defining stopmode based on array


I have to applyStop selectively based on the stochastic Over-Bought value. ApplyStop takes a number/constant value for mode. If IsOverBoughtAttained is 0 then i don’t want to applystop (or deactivate it) by setting stopmode to 0. How do I convert the arrayValue to a number.

stopmode1=IIf(HighestSince(Buy, IsOverBoughtAttained), 2, 0);

//I tried this but it is not working value (BarCount-1) changes when i scroll the chart

ApplyStop(stopTypeLoss, stopMode1Num, 0, 1);


I don’t want to use LastValue(array) because it looks into future.