Alligator

View as Markdown

Indicator Tutorial 12

The Alligator is a classic indicator based on the idea that markets spend most of their time in a horizontal motion and about 15-30% of the time trending. Different interactions of its three SMA plots are said to help identify a coming trend and predict its direction. Here’s the basic definition:

  • The Jaws are a 13 period SMA shifted into the future by 8 bars.
  • The Lips are an 8 period SMA shifted into the future by 5 bars.
  • The Teeth are a 5 period SMA shifted into the future by 3 bars.

Using the Indicator’s shifts property, and the builtin SMA tool, we can easily accomplish the Alligator. shifts allow us to define bar-offsets on the X axis into the past or future on a plot-by-plot basis.

1const predef = require("./tools/predef");
2const SMA = require("./tools/SMA");
3
4class Alligator {
5 init() {
6 this.jaws = SMA(this.props.jaws)
7 this.lips = SMA(this.props.lips)
8 this.teeth = SMA(this.props.teeth)
9 }
10
11 map(d) {
12 const jaws = this.jaws(d.value())
13 const lips = this.lips(d.value())
14 const teeth = this.teeth(d.value())
15 return {
16 jaws, lips, teeth
17 }
18 }
19}
20
21module.exports = {
22 name: "Alligator",
23 description: "Alligator",
24 calculator: Alligator,
25 params: {
26 jaws: predef.paramSpecs.period(13),
27 lips: predef.paramSpecs.period(5),
28 teeth: predef.paramSpecs.period(8)
29 },
30 plots: {
31 jaws: { title: 'Jaws' },
32 lips: { title: 'Lips' },
33 teeth: { title: 'Teeth' }
34 },
35 tags: [predef.tags.MovingAverage],
36 schemeStyles: {
37 dark: {
38 jaws: { color: 'blue' },
39 lips: { color: 'green' },
40 teeth: { color: 'red' }
41 }
42 },
43 //we can use shifts to offset our bars. Negative values would be into the past.
44 shifts: {
45 jaws: 8,
46 lips: 5,
47 teeth: 3
48 }
49};

The Alligator indicator in action.