AGAIG Modified Laguerre Indicator - Gamma Weighted
What it does:
A modified Laguerre RSI (based on John Ehlers' adaptive Laguerre filter, with the smoothing factor gamma driven by a Fractal Energy calculation instead of a fixed value) rebuilt as an upper-chart signal indicator. Instead of just plotting the oscillator, it identifies confirmed long/short reversal points and marks them with arrows, chart bubbles ("Laguerre-L" / "Laguerre-S"), and a persistent status label.
Core logic, in order of how a signal gets built:
This is an indicator I am using on my 5 minute charts for changes-in-direction. As always I never trade one indicator in isolation. Use more than one for confirmation before placing trades!
The chart look:
Inputs and what they trade off:
Indicator Link: http://tos.mx/!KR1VwSqn
What it does:
A modified Laguerre RSI (based on John Ehlers' adaptive Laguerre filter, with the smoothing factor gamma driven by a Fractal Energy calculation instead of a fixed value) rebuilt as an upper-chart signal indicator. Instead of just plotting the oscillator, it identifies confirmed long/short reversal points and marks them with arrows, chart bubbles ("Laguerre-L" / "Laguerre-S"), and a persistent status label.
Core logic, in order of how a signal gets built:
- Zone detection — RSI must actually reach oversold (≤0.2) or overbought (≥0.8), not just approach it.
- Confirmation buffer — after touching a zone, RSI must travel a small extra distance (confirmBuffer) back past the threshold before a reversal is taken seriously. This filters shallow wobbles right at the line.
- Strict alternation gate — once a long or short is confirmed, the opposite signal is the only thing that can ever fire next, no matter how many times price re-touches the same zone. This kills repeated same-direction signals from choppy retests.
- Gamma trend filter (minGamma) — the newest layer. Gamma is the script's own Fractal Energy readout (0 = choppy/random, 1 = strongly trending). A reversal is only confirmed if gamma is at or above minGamma at that moment, so signals are suppressed during genuinely random/non-trending price action.
This is an indicator I am using on my 5 minute charts for changes-in-direction. As always I never trade one indicator in isolation. Use more than one for confirmation before placing trades!
The chart look:
Inputs and what they trade off:
- nFE — lookback for the Fractal Energy/gamma calculation. Shorter = more reactive gamma, longer = smoother/slower gamma.
- longThreshold / shortThreshold — the oversold/overbought lines (default 0.2/0.8). Widening the gap (e.g., 0.15/0.85) = fewer, higher-conviction signals; narrowing it = more, earlier signals.
- confirmBuffer — extra distance past threshold required to confirm. Higher = fewer false triggers, but later signals.
- smoothLength — optional smoothing of the raw RSI before any threshold logic. Off by default; useful if noise is still bar-to-bar rather than zone-driven.
- minGamma — trend-quality floor. 0 = disabled (matches earlier, noisier behavior). Higher values increasingly restrict signals to trending conditions only.
- This is a reversal/turn indicator, not a trend-following one — it's telling you "momentum just reversed out of an extreme," not "this trend will continue." Short-lived turns are a structural risk with any threshold-based reversal method, not a bug — minGamma reduces them but can't eliminate them, since a market can trend just long enough to confirm a signal and then stall.
- Signals are inherently delayed relative to the actual RSI extreme, since they require the confirm buffer and the alternation/gamma gates to all be satisfied. This is a deliberate tradeoff for fewer false positives, made explicit through testing.
- minGamma filters on trend character but not on trend direction — it doesn't know if the current gamma-qualifying trend agrees with the direction of the new signal. If you want that later, that'd be a natural next add-on (e.g., only confirm long if a longer-term MA slope is also up).
Indicator Link: http://tos.mx/!KR1VwSqn
Code:
# AGAIG Modified Laguerre RSI - With Gamma Weighting - Upper Chart Signal Version
declare upper;
input nFE = 13;
input longThreshold = 0.2; # oversold zone entry
input shortThreshold = 0.8; # overbought zone entry
input confirmBuffer = 0.05; # extra RSI distance required to confirm reversal
input smoothLength = 1; # 1 = no smoothing; raise (e.g. 3-5) to reduce noise
input minGamma = 0.0; # 0 = off; raise (e.g. 0.3-0.5) to require trending conditions
input showArrows = yes;
input showBubbles = yes;
input showStatusLabel = yes;
input LabelSize = FontSize.Small;
input LabelLocation = Location.TOP_LEFT;
def o = (open + close[1]) / 2;
def h = Max(high, close[1]);
def l = Min(low, close[1]);
def c = (o + h + l + close) / 4;
def gamma = Log(Sum((Max(high, close[1]) - Min(low, close[1])), nFE) /
(Highest(high, nFE) - Lowest(low, nFE)))
/ Log(nFE);
def L0;
def L1;
def L2;
def L3;
def CU1;
def CU2;
def CU;
def CD1;
def CD2;
def CD;
L0 = (1 - gamma) * c + gamma * L0[1];
L1 = -gamma * L0 + L0[1] + gamma * L1[1];
L2 = -gamma * L1 + L1[1] + gamma * L2[1];
L3 = -gamma * L2 + L2[1] + gamma * L3[1];
if L0 >= L1 {
CU1 = L0 - L1;
CD1 = 0;
} else {
CD1 = L1 - L0;
CU1 = 0;
}
if L1 >= L2 {
CU2 = CU1 + L1 - L2;
CD2 = CD1;
} else {
CD2 = CD1 + L2 - L1;
CU2 = CU1;
}
if L2 >= L3 {
CU = CU2 + L2 - L3;
CD = CD2;
} else {
CU = CU2;
CD = CD2 + L3 - L2;
}
def rawRSI = if CU + CD <> 0 then CU / (CU + CD) else 0;
def RSI = if smoothLength <= 1 then rawRSI else Average(rawRSI, smoothLength);
# --- Zone tracking (which extreme are we near) ---
def zoneState =
if RSI <= longThreshold then 1
else if RSI >= shortThreshold then -1
else if zoneState[1] == 1 and RSI >= (longThreshold + confirmBuffer) then 2
else if zoneState[1] == -1 and RSI <= (shortThreshold - confirmBuffer) then -2
else zoneState[1];
def confirmLongRaw = zoneState == 2 and zoneState[1] != 2;
def confirmShortRaw = zoneState == -2 and zoneState[1] != -2;
# --- Trend-quality gate: only let a raw confirmation through if the market
# has enough fractal energy (gamma) to be considered trending, not choppy ---
def trendOK = gamma >= minGamma;
def confirmLongGated = confirmLongRaw and trendOK;
def confirmShortGated = confirmShortRaw and trendOK;
# --- Strict alternation gate: block same-direction repeats until the opposite
# direction has confirmed at least once in between ---
def confirmedState = if confirmLongGated and confirmedState[1] != 1 then 1
else if confirmShortGated and confirmedState[1] != -1 then -1
else confirmedState[1];
def confirmLong = confirmedState == 1 and confirmedState[1] != 1;
def confirmShort = confirmedState == -1 and confirmedState[1] != -1;
# --- Arrows on the bars (fire only on the confirmed flip bar) ---
plot LongArrow = if showArrows and confirmLong then low else Double.NaN;
LongArrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
LongArrow.SetDefaultColor(Color.GREEN);
LongArrow.SetLineWeight(3);
LongArrow.HideTitle();
LongArrow.HideBubble();
plot ShortArrow = if showArrows and confirmShort then high else Double.NaN;
ShortArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ShortArrow.SetDefaultColor(Color.RED);
ShortArrow.SetLineWeight(3);
ShortArrow.HideTitle();
ShortArrow.HideBubble();
# --- Signal chart bubbles (fire only on the confirmed flip bar) ---
AddChartBubble(showBubbles and confirmLong, low, "Laguerre-L", Color.GREEN, no);
AddChartBubble(showBubbles and confirmShort, high, "Laguerre-S", Color.RED, yes);
# --- Status label (persistent, reflects confirmed state) ---
AddLabel(showStatusLabel,
if RSI > shortThreshold then "LAGUERRE: OVERBOUGHT"
else if RSI < longThreshold then "LAGUERRE: OVERSOLD"
else if confirmedState == 1 then "Laguerre-L"
else if confirmedState == -1 then "Laguerre-S"
else "LAGUERRE: NEUTRAL",
if RSI > shortThreshold then Color.RED
else if RSI < longThreshold then Color.GREEN
else if confirmedState == 1 then Color.GREEN
else if confirmedState == -1 then Color.RED
else Color.GRAY);
Last edited by a moderator: