Bruce
Wow. Impressive.
Regarding the unused variables  they are referenced in some code I did not provide in my initial post. Here is the entire indicator code that includes use of "Retrace" and other output variables.
Thanks.... Dan
+++++++++++
'# Cumulative
'# OutputType = UserInput.Integer = 2
' Type 1 = gap size and percent of closure / Type 2 = bars since gap and % HoD close
'# MinGapPerc = UserInput.Single = 2
' Default setting for watchlist is currently 1%
'# GapType = UserInput.Integer = 2
' Type 1 = up gap / Type 2 = down gap
Dim gap(50) As Single
Dim sinceGap(50) As Integer
Dim gapclosed(50) As Integer
Static sign As Integer
Static gapnumber As Integer
Dim Gapretrace(50) As Single
Dim PrMnLowSncGap(50) As Single
Static PrMxHighSncGap(50) As Single
Dim outputgapnumber As Integer
' New Gap occurred (logic only handles recent gaps)
' NEW LOGIC RQRD: Dim(20), gap(i), sincegap(i), sincegapclosed(i), PrMxHighSncGgap(i), PRMxLowSncGap(i)
If isFirstBar Then
gap(1) = Single.NaN
gapretrace(1) = Single.NaN
' sinceGap(1) = 0
gapnumber = 0
gapclosed(1) = 1
PrMxHighSncGap(1) = 0
PrMnLowSncGap(1) = 0
Else If (1  Price.High / Price.Low(1)) >= MinGapPerc / 100 And Price.High < Price.Low(1) Then
gapnumber = gapnumber + 1
gap(gapnumber) = 100 * (1  Price.High / Price.Low(1)) ' new gap down logic
sinceGap(gapnumber) = 0 ' Revision 1
gapclosed(gapnumber) = 0
Else If (Price.Low / Price.High(1)  1) >= MinGapPerc / 100 And Price.High(1) < Price.Low Then
gapnumber = gapnumber + 1
gap(gapnumber) = 100 * (Price.Low / Price.High(1)  1) ' new gap up logic
sinceGap(gapnumber) = 0 ' Revision 1
gapclosed(gapnumber) = 0
End If
'Label = sincegap(1)
'Label = Sincegap(1)=0
'Label = gapclosed(1)=0
'Label = gapnumber '= 1 continuously
'Label = price.low
For i As Integer = 1 To System.Math.Max(gapnumber, 1) 'NOT INCREMENTING SinceGAp ???? WHY NOT ?????????? GAPCLOSED(i) = 0 ???? GAP(i) RESET TO ZERO AFTER FIRST BAR?????
If Gapnumber = 0 Then
Exit For
Else If Gapclosed(i) = 0 Then
'sinceGap(i) += 1
'Label = sincegap(1)=0
'label = gapclosed(1)=0
sincegap(i) = sincegap(i) + 1
'Label = Sincegap(1) = 1
End If
Next
'Label = sincegap(1)=1
' Code Speedup stuff to replace Price.MaxHigh(sincegap)and Price.MinLow(sincegap)
For i As Integer = 1 To System.Math.Max(gapnumber, 1)
If Gapnumber = 0 Then Exit For
If gapclosed(i) = 0 Then
If sincegap(i) = 0 Then
PrMxHighSncGap(i) = Price.High
PrMnLowSncGap(i) = Price.Low
Else If sincegap(i) = 1 Then
PrMxHighSncGap(i) = Price.High
PrMnLowSncGap(i) = Price.Low
Else If sincegap(i) > 1 Then
If Price.High > PRMxHighSncGap(i) Then PrMxHighSncGap(i) = Price.High
If Price.Low < PrMnLowSncGap(i) Then PrMnLowSncGap(i) = Price.low
End If
End If
Next
' Current Gap Closed / sincegap reset to zero
For i As Integer = 1 To System.Math.Max(gapnumber, 1)
If gapnumber = 0 Then Exit For
If gap(i) < 0 And PrMxHighSncGap(i) > Price.Low(sincegap(i) + 1  1) Then
sincegap(i) = 0 ' gap down closed
gap(i) = 0
gapclosed(i) = 1
Else If gap(i) > 0 And PrMnLowSncGap(i) < Price.High(sincegap(i) + 1  1) Then
sincegap(i) = 0 ' gap up closed
gap(i) = 0
gapclosed(i) = 1
End If
Next
'Label = PrMnLowSncGap(1)
'Label = Price.High(sincegap(1))
'Label = gapclosed(1)=0
'Label = sincegap(1)=1
' Calculate Gap retracement
For i As Integer = 1 To System.Math.Max(gapnumber, 1)
If gapnumber = 0 Then Exit For
If sincegap(i) > 0 AndAlso gapclosed(i) = 0 Then
If gap(i) < 0 And PrMxHighSncGap(i) < Price.Low(sincegap(i) + 1  1)Then ' gap down logic
If sincegap(i) = 1 Then
Gapretrace(i) = (price.Last  price.low) / (price.Low(sincegap(i))  price.high) 'Gap Day >> Use Open instead of high ??
Else
Gapretrace(i) = (Price.Last  Price.High(sinceGap(i)  1)) / _
(Price.Low(sinceGap(i) + 1  1)  Price.High(sinceGap(i)  1)) ' Note: *** Might want to use Price.high instead of price.last
End If
Else If gap(i) > 0 And PrMnLowSncGap(i) > Price.High(sincegap(i) + 1  1)Then ' gap up logic
If sincegap(i) = 1 Then
Gapretrace(i) = (price.Last  price.high) / (price.High(sincegap(i))  price.Low) 'Gap Day >> Use Open instead of Low??
Else
Gapretrace(i) = (Price.Last  Price.Low(sinceGap(i)  1)) / _
(Price.High(sinceGap(i) + 1  1)  Price.Low(sinceGap(i)  1)) ' Note: *** Might want to use Price.low instead of price.last
End If
Else
Gapretrace(i) = 0 ' Put Continuation logic here >> do I want Abs% from gap or relative% from gap (based on gap size)??? Want consistency for easy analysis.
End If
End If
Next
' Find most recent unclosed gap
Outputgapnumber = 0
For i As Integer = 1 To System.Math.Max(gapnumber, 1)
If Gapnumber = 0 Then Exit For
If Gapclosed(Gapnumber + 1  i) = 0 Then
Outputgapnumber = Gapnumber + 1  i
Exit For
End If
Next
'Label = sincegap(1)=1
'Label = outputgapnumber = 1
' Output Plot logic during period Gap is still Open / plot gap size and percent of current gap closure
If outputgapnumber > 0 Then
If GapType = 2 And sincegap(outputgapnumber) > 0 Then 'Gap Down
If gap(outputgapnumber) < 0 And (gapretrace(outputgapnumber) > 0 Or sincegap(outputgapnumber) = 1) Then
If PrMxHighSncGap(outputgapnumber) = Price.High Then
Sign = 1 ' Todays high is new high since gap
Else
Sign = 1 'Todays high is not a new high since gap
End If
If outputtype = 1 Then ' 1st day retracement issue
If sincegap(outputgapnumber) = 1 Then
'Plot = System.Math.Round(sign * gap, 0) + sign * system.math.abs(gapretrace)
Plot = System.Math.Round(gap(outputgapnumber), 0)  System.Math.Abs(gapretrace(outputgapnumber))
Else
Plot = System.Math.Round(Sign * gap(outputgapnumber), 0) + Sign * Gapretrace(outputgapnumber)
End If
Else If outputtype = 2 Then
Plot = (sincegap(outputgapnumber) + ((Price.Close  Price.Low) / (Price.High  Price.Low)) / 10) * System.Math.Sign(price.NetChange)
End If
End If
Else If GapType = 1 And sincegap(outputgapnumber) > 0 Then ' Gap Up
If gap(outputgapnumber) > 0 And (gapretrace(outputgapnumber) < 0 Or sincegap(outputgapnumber) = 1) Then
If PrMnLowSncGap(outputgapnumber) = Price.Low Then ' Todays low is new low since gap
Sign = 1
Else
Sign = 1 'Todays low is not a new low since gap
End If
If outputtype = 1 Then ' 1st day retracement issue
If sincegap(outputgapnumber) = 1 Then
'Plot = System.Math.Round(sign * gap, 0) + sign * system.math.abs(gapretrace)
Plot = System.Math.Round(gap(outputgapnumber), 0) + System.Math.Abs(gapretrace(outputgapnumber)) 'Plot = 2.5
Else
Plot = System.Math.Round(Sign * gap(outputgapnumber), 0)  Sign * Gapretrace(outputgapnumber)
End If
Else If outputtype = 2 Then
Plot = (sincegap(outputgapnumber) + ((Price.Close  Price.Low) / (Price.High  Price.Low)) / 10) * System.Math.Sign(price.NetChange)
End If
End If
Else Plot = 0
End If
Else Plot = 0
End If
