Sub trig()
Dim rng As Range, cell As Range, h As Range, l As Range, nh As Range, c1 As Range, c2 As Range, bs As Integer, I As Integer, low As Currency, high As Currency, newlow As Currency, newhigh As Currency, flag As Integer, loop1 As Integer
Set rng = Range("L102:L662")
loop1 = 0
Set h = Range("A1")
For Each cell In rng
flag = 0
bs = cell.Value
If bs = 1 Then
loop1 = 0
high = cell.Offset(0, -7).Value
nh = cell.Offset(1, -7)
Set h = Range("nh:E662")
While loop1 = 0
For Each c1 In h
If c1.Offset(0, 7).Value = 0 Then
newhigh = c1.Value
If newhigh > high Then
cell.Value = 1
loop1 = 1
Exit For
End If
Else
cell.Value = 0
loop1 = 1
Exit For
End If
Next c1
Wend
Else
loop1 = 0
If bs = -1 Then
low = cell.Offset(0, -6).Value
nh = cell.Offset(1, -6)
Set l = Range("nh:F662")
While loop1 = 0
For Each c2 In l
If c1.Offset(0, 6).Value = 0 Then
newlow = c1.Value
If newlow < low Then
cell.Value = -1
loop1 = 1
Exit For
End If
Else
cell.Value = 0
loop1 = 1
Exit For
End If
Next c2
Wend
End If
End If
Next cell
End Sub
Dim rng As Range, cell As Range, h As Range, l As Range, nh As Range, c1 As Range, c2 As Range, bs As Integer, I As Integer, low As Currency, high As Currency, newlow As Currency, newhigh As Currency, flag As Integer, loop1 As Integer
Set rng = Range("L102:L662")
loop1 = 0
Set h = Range("A1")
For Each cell In rng
flag = 0
bs = cell.Value
If bs = 1 Then
loop1 = 0
high = cell.Offset(0, -7).Value
nh = cell.Offset(1, -7)
Set h = Range("nh:E662")
While loop1 = 0
For Each c1 In h
If c1.Offset(0, 7).Value = 0 Then
newhigh = c1.Value
If newhigh > high Then
cell.Value = 1
loop1 = 1
Exit For
End If
Else
cell.Value = 0
loop1 = 1
Exit For
End If
Next c1
Wend
Else
loop1 = 0
If bs = -1 Then
low = cell.Offset(0, -6).Value
nh = cell.Offset(1, -6)
Set l = Range("nh:F662")
While loop1 = 0
For Each c2 In l
If c1.Offset(0, 6).Value = 0 Then
newlow = c1.Value
If newlow < low Then
cell.Value = -1
loop1 = 1
Exit For
End If
Else
cell.Value = 0
loop1 = 1
Exit For
End If
Next c2
Wend
End If
End If
Next cell
End Sub