Source: https://fxcodebase.com/code/viewtopic.php?f=17&t=15
Forum: 17 · Topic 15 · 5 post(s)
admin · Tue Oct 20, 2009 11:02 am
DESCRIPTION:
Alligator Indicator is the indicator which displays 3 lines which represent three moving averages. They are Moving Averages with various parameters:

HOW TO USE/INTERPRETATION:
When all of the lines are intertwined in the same place, it shows that the “Alligator” is in sleeping “mode” so to say. Then Alligator wakes up for a hunt, and once again when lines meet together Alligator’s hunt is over. This is the place where you should fix your profit. Close all your position on this instrument and wait till Alligator starts waking up again.
The indicator was revised and updated
DOWNLOAD:
See also: The SMMA/median (MT4-like) version of the indicator is here
Tags: Allgator, indicator, Marketscope, Trading Station, FXCM, dbFX
gg_frx · Thu Dec 17, 2009 9:09 am
hi all and thanks for your grat job helping us to create indicators
but …. …. i compared this indicator with same indicator but in other trading platforms and noticed that something is .. wrong
i know that prices can be different in forex platforms but in this case the curves are too different
i try to take a look to the code but i am not so familiar with it (for now ….. ) but i think that possible reasons are two:
Can you verify ?
Thank you
Nikolay.Gekht · Tue Dec 22, 2009 3:26 pm
Generally speaking, there is no indicator except the simplest one, such as MVA, which has “right” or “correct” formula. . This is why an ability to modify an indicator as you wish is very important.
As I can see this is MT4 implementation which uses SMMA and median prices.
Here is a modification of the Alligator indicator which uses the same formula as MT4’s implementation:

Download the indicator:
Note1: This indicator requires SMMA indicator. Please do not forget to download and install it before using this version of the alligator indicator.
Code:
Code: Select all `– initializes the indicator function Init() indicator:name(“Alligator1”); indicator:description(“Median and SMMA-based version of the alligator”) indicator:requiredSource(core.Bar); indicator:type(core.Indicator);
indicator.parameters:addInteger(“JawN”, “Number of periods for smoothing the alligator jaw”, “”, 13); indicator.parameters:addInteger(“JawS”, “Number of periods for shifting the alligator jaw”, “”, 8); indicator.parameters:addColor(“JawC”, “Color of the the alligator jaw”, “”, core.rgb(0, 0, 255)); indicator.parameters:addInteger(“TeethN”, “Number of periods for smoothing the alligator teeth”, “”, 8); indicator.parameters:addInteger(“TeethS”, “Number of periods for shifting the alligator teeth”, “”, 5); indicator.parameters:addColor(“TeethC”, “Color of the the alligator teeth”, “”, core.rgb(255, 0, 0)); indicator.parameters:addInteger(“LipsN”, “Number of periods for smoothing the alligator lips”, “”, 5); indicator.parameters:addInteger(“LipsS”, “Number of periods for shifting the alligator lips”, “”, 3); indicator.parameters:addColor(“LipsC”, “Color of the the alligator lips”, “”, core.rgb(0, 255, 0)); indicator.parameters:addString(“MTH”, “Smoothing method”, “”, “SMMA”); indicator.parameters:addStringAlternative(“MTH”, “MVA”, “”, “MVA”); indicator.parameters:addStringAlternative(“MTH”, “EMA”, “”, “EMA”); indicator.parameters:addStringAlternative(“MTH”, “LWMA”, “”, “LWMA”); indicator.parameters:addStringAlternative(“MTH”, “SMMA”, “”, “SMMA”); end
– lines parameters local JawN, JawS; local TeethN, TeethS; local LipsN, LipsC;
– indicator source local source; local median;
– lines local Jaw, Teeth, Lips; – lines sources local JawSrc, TeethSrc, LipsSrc;
– process parameters and prepare for calculations function Prepare() JawN = instance.parameters.JawN; JawS = instance.parameters.JawS; TeethN = instance.parameters.TeethN; TeethS = instance.parameters.TeethS; LipsN = instance.parameters.LipsN; LipsS = instance.parameters.LipsS;
source = instance.source; median = instance:addInternalStream(source:first(), 0);
JawSrc = core.indicators:create(instance.parameters.MTH, median, JawN, core.rgb(0, 0, 0)); TeethSrc = core.indicators:create(instance.parameters.MTH, median, TeethN, core.rgb(0, 0, 0)); LipsSrc = core.indicators:create(instance.parameters.MTH, median, LipsN, core.rgb(0, 0, 0));
local name = profile:id() .. “(“ .. source:name() .. “, “ .. JawN .. “(“ .. JawS .. “),” .. TeethN .. “(“ .. TeethS .. “),” .. LipsN .. “(“ .. LipsS .. “))”; instance:name(name); Jaw = instance:addStream(“Jaw”, core.Line, name .. “.Jaw”, “Jaw”, instance.parameters.JawC, JawSrc.DATA:first() + JawS, JawS); Teeth = instance:addStream(“Teeth”, core.Line, name .. “.Teeth”, “Teeth”, instance.parameters.TeethC, TeethSrc.DATA:first() + TeethS, TeethS); Lips = instance:addStream(“Lips”, core.Line, name .. “.Lips”, “Lips”, instance.parameters.LipsC, LipsSrc.DATA:first() + LipsS, LipsS); end
– Indicator calculation routine function Update(period, mode) median[period] = (source.high[period] + source.low[period]) / 2; JawSrc:update(mode); TeethSrc:update(mode); LipsSrc:update(mode);
if (period + JawS >= 0 and period >= JawSrc.DATA:first()) then Jaw[period + JawS] = JawSrc.DATA[period]; end
if (period + TeethS >= 0 and period >= TeethSrc.DATA:first()) then Teeth[period + TeethS] = TeethSrc.DATA[period]; end
if (period + LipsS >= 0 and period >= LipsSrc.DATA:first()) then Lips[period + LipsS] = LipsSrc.DATA[period]; end end`
Changes:
gg_frx · Tue Dec 22, 2009 4:22 pm
wow … great ! I’ll try all new indicators!
yes, correct, his an .MT4 implementation but SMMA is anyway required to calculate alligator and gator, following the guidelines of the bill williams book “new trading dimensions” .
thank you again
Apprentice · Mon Dec 26, 2016 6:49 am
Indicator was revised and updated.