Skip to content

Gator Oscillator ​

Created by Bill Williams, the Gator Oscillator is an expanded oscillator view of Williams Alligator's three moving averages. [Discuss] 💬

Indicator style
Loading chart data...

csharp
// C# usage syntax
IReadOnlyList<GatorResult> results =
  bars.ToGator();

// with custom Alligator configuration
IReadOnlyList<GatorResult> results = bars
  .ToAlligator([see Alligator docs])
  .ToGator();

Create a buffer list and add each bar as it arrives:

csharp
GatorList gatorList = new();

// call from your WebSocket or SSE message handler
void OnBarReceived(IBar bar) => gatorList.Add(bar);

// the list itself holds the results; fills as the handler runs
IReadOnlyList<GatorResult> results = gatorList;

See Buffer lists for the full usage guide.

Subscribe to a BarHub and add each bar as it arrives:

csharp
BarHub barHub = new();
GatorHub observer = barHub.ToGatorHub();

// call from your WebSocket or SSE message handler
void OnBarReceived(IBar bar) => barHub.Add(bar);

// results fill as the handler runs
IReadOnlyList<GatorResult> results = observer.Results;

Compound hub

The Gator hub is based on the Alligator indicator. When the Gator hub is chained from an existing AlligatorHub instance it will reuse the existing Alligator hub values rather than creating its own internal Alligator calculations. This is not a normal chaining model.

csharp
// creates an internal Alligator hub
var gatorHub = bars
  .ToGatorHub();

// this is helpful in cases where you have an independent 
// Alligator hub and do not want to create duplicate copies

var alligatorHub = bars
  .ToAlligatorHub();

// does not create 2nd internal huba separate internal Alligator hub
var gatorHub = alligatorHub
  .ToGatorHub();  // does not create 2nd internal hub

// ❌ Alligator → [ Alligator ] → Gator
// ✅ Alligator → Gator

See Stream hubs for the full usage guide.

Historical price bars requirements ​

If using default settings, you must have at least 121 periods of bars to cover the warmup and convergence periods. Since this uses a smoothing technique, we recommend you use at least 271 data points prior to the intended usage date for better precision. If using a custom Alligator configuration, see Alligator documentation for Historical price bars requirements.

bars is a collection of generic TBar historical price bars. It should have a consistent frequency (day, hour, minute, etc). See the Guide for more information.

Response ​

csharp
IReadOnlyList<GatorResult>
  • This method returns a time series of all available indicator values for the bars provided.
  • It always returns the same number of elements as there are in the historical price bars.
  • It does not return a single incremental indicator value.
  • The first 10-20 periods will have null values since there's not enough data to calculate.
csharp
GatorList : IReadOnlyList<GatorResult>
  • The list itself holds the results, one for each bar or value added, in timestamp order.
  • It keeps up to 100,000 results by default and drops the oldest beyond that; set MaxListSize to keep fewer.
  • The first 10-20 periods will have null values since there's not enough data to calculate.
csharp
IReadOnlyList<GatorResult> results = observer.Results;
  • observer.Results holds the results, one for each bar in the BarHub cache, in timestamp order.
  • Results update as bars arrive, including bars that arrive late or are revised.
  • The cache keeps up to 100,000 results by default; set maxCacheSize on the BarHub to keep fewer.
  • The first 10-20 periods will have null values since there's not enough data to calculate.

🚩 ⚞ Convergence warning

The first 150 periods will have decreasing magnitude, convergence-related precision errors that can be as high as ~5% deviation in indicator values for earlier periods.

GatorResult ​

propertydescription
Timestamp
DateTime
Date from evaluated TBar
Upper
double?
Absolute value of Alligator Jaw-Teeth
Lower
double?
Absolute value of Alligator Lips-Teeth
UpperIsExpanding
bool?
Upper value is growing
LowerIsExpanding
bool?
Lower value is growing

Chaining ​

Results cannot be further chained with additional transforms.

This indicator may be generated from any chain-enabled indicator or method.

csharp
// example
var results = bars
    .Use(CandlePart.HLC3)
    .ToGator();

See Chaining indicators for more.

This indicator may be generated from results of another chain-enabled buffer list. Add each new result to it yourself.

csharp
// example
SmaList smaList = new(..);
GatorList gatorList = new();

void OnBarReceived(IBar bar)
{
    smaList.Add(bar);
    gatorList.Add(smaList[^1]);
}

See Chaining buffer lists for more.

This indicator may be subscribed to any chain-enabled hub.

csharp
// example
GatorHub observer = barHub
    .ToBarPartHub(CandlePart.HLC3)
    .ToGatorHub();

See Chaining stream hubs for more.

Utilities ​

Call these on the list itself, as in gatorList.Find(lookupDate). .Condense() returns a new list and leaves gatorList unchanged.

Warmup removal is left out. Once the list is full it drops its oldest results, so trimming by position would remove valid values.

Call these on observer.Results, as in observer.Results.Find(lookupDate). .Condense() returns a new list and leaves the hub's results unchanged.

Warmup removal is left out. Once the cache is full the hub drops its oldest results, so trimming by position would remove valid values.

See Utilities and helpers for more information.