After getting some clarifications in the comment section of the question I can provide a solution.
input percentThreshold = -20.0;
input volumeThreshold = 100000;
def gapDownPercent = 100 * (open / close[1] - 1);
def qualifiedGap = gapDownPercent < percentThreshold and volume > volumeThreshold;
rec trackGapHigh = if qualifiedGap[-1] then close else trackGapHigh[1];
rec trackGapLow = if qualifiedGap then open else trackGapLow[1];
plot gapHigh = trackGapHigh;
gapHigh.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gapHigh.SetDefaultColor(Color.DARK_GREEN);
plot gapLow = trackGapLow;
gapLow.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
gapLow.SetDefaultColor(Color.DARK_RED);