TradingView indicator guide

Gator Oscillator on TradingView: formula and limits

The Gator Oscillator measures the separation of the three Alligator moving averages. Its upper histogram is the absolute Jaw minus Teeth distance; its lower histogram is the negative absolute Teeth minus Lips distance. Green means a distance increased from the preceding bar, while red means it decreased. Neither color identifies a long or short trade. To reproduce the indicator on TradingView, specify smoothing, line displacement, equal-value colors and confirmation timing before comparing bars.

Draft a Gator indicator

Calculate two distances from three smoothed averages

The standard input is median price, (high + low) / 2. Each Alligator line uses a smoothed moving average (SMMA). With an N-observation simple-average seed, the subsequent update is (previous SMMA × (N − 1) + current median price) / N. The two distances are measured in the same price units as those lines; they are not percentages or bounded overbought levels.

  • Compare each distance with its own preceding magnitude. Never compare the upper bar with the lower bar to assign its color.
  • The example uses gray for an unchanged distance or an unavailable comparison. Check another implementation before assuming it uses the same tie rule.
  • The Alligator overlay preserves line order and position relative to price. Absolute distances discard that order, so Gator cannot recover direction by itself.
LineLengthForward shiftUsed in
Jaw138 barsUpper distance
Teeth85 barsBoth distances
Lips53 barsLower distance

Align the lines before subtracting them

This page uses values drawn at the same chart coordinate. At bar t, a Jaw computed eight bars earlier is the Jaw value displayed at t. The example therefore reads JawRaw[t − 8], TeethRaw[t − 5] and LipsRaw[t − 3], then plots their distances at t with no extra histogram offset. These are historical observations, not future prices.

  • Use the same symbol, session, chart timeframe, median-price source and smoothing history when comparing implementations.
  • MetaTrader documents separate raw-buffer and display-shift behavior for iGator. This example states its chart-coordinate convention; do not compare a raw MT5 buffer index directly with a TradingView bar without mapping the timestamps.
  • On a 15-minute chart these lengths count 15-minute bars. No daily or higher-timeframe data is requested by this example.
OperationEffectVerification
History referenceSelects the earlier line value used in arithmetic.At bar t, compare Jaw with the raw average at t − 8.
Positive plot offsetMoves a drawing to the right.It does not change the series used by subtraction or alerts.
One offset applied after subtractionMoves both distances together.It cannot reproduce three different input shifts.

Check the signs with a hypothetical sequence

These supplied, already aligned line values are an arithmetic fixture, not observed prices or an SMMA initialization example. Compare B with A, C with B, and D with C. The final column reports upper color first, lower color second.

  • B upper = |100 − 104| = 4. Its lower magnitude is |104 − 107| = 3, plotted at −3. Both distances widened.
  • C has a green lower bar even though its plotted value fell from −3 to −4. Testing lower > lower[1] would invert the intended growth color.
  • Mirror A to 110 / 107 / 105 and B to 110 / 106 / 103: the outputs are still 3 / −2 and 4 / −3. Opposite line ordering produces the same green pair.
  • If D repeats unchanged, both bars are gray under this page's explicit tie policy. No new expansion event occurs.
BarJaw / Teeth / LipsUpperLowerColors
A100 / 103 / 1053−2No prior comparison
B100 / 104 / 1074−3Green / green
C101 / 104 / 1083−4Red / green
D102 / 104 / 1072−3Red / red

Use four phase names with their preceding state

Sleeping and eating describe a color pair. Awakening and sated also depend on what happened before the mixed pair. A single red/green snapshot cannot distinguish them. The phase names summarize line separation; they do not establish a market forecast or an executable order.

  • The fixture shows eating at B, sated at C and sleeping at D. It makes no claim about the next price move.
  • For repeated mixed bars, specify whether the last unambiguous phase persists. For gray ties or missing history, define a separate neutral or unavailable state before coding a phase machine.
  • Phase sequences can skip states or reverse quickly. Both green can occur during either upward or downward line ordering, including a temporary expansion inside a range.
PhaseColor sequenceMeaning
SleepingBoth redBoth distances contracted relative to the prior bar.
AwakeningMixed after sleepingOne distance began expanding while the other contracted.
EatingBoth greenBoth distances expanded relative to the prior bar.
SatedMixed after eatingOne expanding distance began contracting.

Inspect the distances in Pine Script v6

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.

  • The first comparison needs current and previous valid distances. The alert also requires a valid previous comparison, so initial warm-up is not reported as an expansion event.
  • At default positive shifts, the selected line values come from completed earlier bars. If a shift is set to zero, that line and its color can develop during the open bar.
  • The alert is gated by barstate.isconfirmed regardless of shift settings. Select Once Per Bar Close when creating it; recreate the alert after changing the script or its inputs.
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.")

Verify chart values before defining a strategy

Choose a completed bar in TradingView and record the aligned Jaw, Teeth and Lips from the Data Window. Recalculate both absolute distances and compare their magnitudes with the preceding bar. Check one expanding lower bar, one contraction, a tie and the first available values. Keep the selected timestamp visible while comparing with an Alligator overlay.

  • If values disagree, inspect smoothing, seed history and displacement before changing periods. Matching 13/8/5 alone is insufficient.
  • Record whether an alert means a condition remains true or first becomes true. This script alerts on the transition into both growing, not on every green pair.
  • Ask the Pine Script AI Coding Agent to preserve this alignment and tie policy when adding phase labels or confirmation rules. Supply the four-row fixture as an acceptance check.
  • Define direction, entry, exit, position size and costs separately before testing trades. Compare values first, then test the trading rules on observations not used to choose their parameters.
Where Pineify fits

Pine Script AI Coding Agent

Draft or revise a Gator indicator with explicit smoothing, displacement, color and confirmation rules. Inspect intermediate values before adding trading rules.

Draft a Gator indicator

Frequently asked questions

Educational information, not investment advice. The arithmetic fixture is hypothetical. The script measures line distances and does not establish profitable entries, exits or future price direction.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.