Divergent Bars Alligator Filter

The Divergent Bars Alligator Filter is a combination of the Divergent Bars and Alligator studies, authored by Bill Williams. The user may change the input (midpoint), method (SMMA), period lengths, shift lengths and percent factor. This indicator’s definition is further expressed in the condensed code given in the calculation below.
See Divergent Bars.
See Alligator.

Divergent Bars Alligator Filter1

How To Trade Using Divergent Bars Alligator Filter

If the current low is less than the previous low and the close is more than the current average and the current low is less than the minimum low a buy signal will be generated. Conversely, if the current high is more than the previous high and the current close is less than the current average and the current high is more than the maximum high a sell signal will be given.

Divergent Bars Alligator Filter2

How To Access in MotiveWave

Go to the top menu, choose Study -> Add Study, start typing in this study name until you see it appear in the list, click on the study name, click OK.

Important Disclaimer: The information provided on this page is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security. Please see our Risk Disclosure and Performance Disclaimer Statement.


//input = price, user defined, default is midpoint
//method = moving average (ma), user defined, default is SMMA
//jaw period = jawP = user defined, default is 13
//jaw shift = jawS = user defined, default is 8
//teeth period = teethP = user defined, default is 8
//teeth shift = teethS = user defined, default is 5
//lips period = lipsP = user defined, default is 5
//lips shift = lipsS = user defined, default is 3
//percent factor = fac = user defined, default is 1
//index = current bar number

prevLow = getLow(index - 1);
prevHigh = getHigh(index - 1);
currentAverage = (high + low) / 2;
jaw = ma(method, index, jawP, input);
Plot1: cJaw = jaw[index];
teeth = ma(method, index, teethP, input);
teeth[index+teethS] = teeth;
Plot2: cTeeth = teeth[index];
lips = ma(method, index, lipsP, input);
lips[index+lipsS] = lips;
Plot3: cLips = lips[index];
min = Math.min(Math.min(cJaw, cTeeth),cLips);
max = Math.max(Math.max(cJaw, cTeeth),cLips);
mid = (max + min) * .5;
minL = min - (fac * min/100);
if (minL moreThan mid) minL = mid;
maxH = max + (fac * max/100);
if (maxH lessThan mid) maxH = mid;
Plot4: maxH;;
Plot5: minL;
boolean buy = (low lessThan prevLow AND close moreThan currentAverage AND low lessThan minL);
boolean sell = (high moreThan prevHigh AND close lessThan currentAverage AND high moreThan maxH);