Paste this complete educational indicator into Pine Editor, save it and add it to a standard candlestick chart. It uses ta.rma for the stated smoothing, exposes aligned line values in the Data Window and alerts only when both distances begin growing on a confirmed chart bar. It does not assign the four phase labels or place trades.
Pine v6 syntax checked on 2026-10-17. Gray is an explicit tie or unavailable-comparison rule. Syntax success does not verify chart parity or trading performance.pine
//@version=6
indicator("Gator: aligned line distances", overlay = false)
jawLength = input.int(13, "Jaw length", minval = 1)
teethLength = input.int(8, "Teeth length", minval = 1)
lipsLength = input.int(5, "Lips length", minval = 1)
jawShift = input.int(8, "Jaw forward shift", minval = 0, maxval = 100)
teethShift = input.int(5, "Teeth forward shift", minval = 0, maxval = 100)
lipsShift = input.int(3, "Lips forward shift", minval = 0, maxval = 100)
// Read the line values drawn at the current chart coordinate.
jawRaw = ta.rma(hl2, jawLength)
teethRaw = ta.rma(hl2, teethLength)
lipsRaw = ta.rma(hl2, lipsLength)
jaw = jawRaw[jawShift]
teeth = teethRaw[teethShift]
lips = lipsRaw[lipsShift]
upper = math.abs(jaw - teeth)
lowerMagnitude = math.abs(teeth - lips)
ready = not na(upper[1]) and not na(lowerMagnitude[1])
upperGrowing = ready and upper > upper[1]
lowerGrowing = ready and lowerMagnitude > lowerMagnitude[1]
upperColor = not ready ? color.gray : upperGrowing ? color.green : upper < upper[1] ? color.red : color.gray
lowerColor = not ready ? color.gray : lowerGrowing ? color.green : lowerMagnitude < lowerMagnitude[1] ? color.red : color.gray
bothGrowing = upperGrowing and lowerGrowing
plot(upper, "Upper distance", color = upperColor, style = plot.style_histogram, linewidth = 3)
plot(-lowerMagnitude, "Lower negative distance", color = lowerColor, style = plot.style_histogram, linewidth = 3)
hline(0, "Zero", color.gray)
plot(jaw, "Aligned Jaw", display = display.data_window)
plot(teeth, "Aligned Teeth", display = display.data_window)
plot(lips, "Aligned Lips", display = display.data_window)
plot(lowerMagnitude, "Lower magnitude", display = display.data_window)
expansionStarts = ready and ready[1] and bothGrowing and not bothGrowing[1]
alertcondition(barstate.isconfirmed and expansionStarts, "Both distances start growing", "Both Gator distances started growing at chart bar close. Direction is not specified.")