You are on page 1of 1

_SECTION_BEGIN( "Gator Oscillator" );

Lips_Period = 5;
Teeth_Period = 8;
Jaw_Period = 13;
MidPrice = ( H + L ) / 2;

Lips = MA( MidPrice, Lips_Period );


Teeth = MA( MidPrice, Teeth_Period );
Jaw = MA( MidPrice, Jaw_Period );

for ( i = Lips_Period + 1; i < BarCount; i++ )


{
iSum = ( Lips[i-1] * ( Lips_Period - 1 ) ) + MidPrice[i];
Lips[i] = iSum / Lips_Period;
}

for ( j = Teeth_Period + 1; j < BarCount; j++ )


{
jSum = ( Teeth[j-1] * ( Teeth_Period - 1 ) ) + MidPrice[j];
Teeth[j] = jSum / Teeth_Period;
}

for ( k = Jaw_Period + 1; k < BarCount; k++ )


{
kSum = ( Jaw[k-1] * ( Jaw_Period - 1 ) ) + MidPrice[k];
Jaw[k] = kSum / Jaw_Period;
}

GatorAbove0 = abs( Jaw - Teeth );


GatorBelow0 = -( abs( Teeth - Lips ) );

BarColorAbove = IIf( GatorAbove0 < Ref( GatorAbove0, -1 ), colorRed, IIf( GatorAbove0 > Ref( GatorAbove0, -1 ), colorGreen, colorGrey40 ) );
BarColorBelow = IIf( GatorBelow0 > Ref( GatorBelow0, -1 ), colorRed, IIf( GatorBelow0 < Ref( GatorBelow0, -1 ), colorGreen, colorGrey40 ) );

SetBarFillColor( IIf( GatorAbove0 < Ref( GatorAbove0, -1 ), colorRed, IIf( GatorAbove0 > Ref( GatorAbove0, -1 ), colorGreen, colorGrey40 ) ) );
PlotOHLC( 0, GatorAbove0, 0, GatorAbove0, _DEFAULT_NAME(), BarColorAbove, styleCandle | styleNoLabel | stylenotitle );

SetBarFillColor( IIf( GatorBelow0 > Ref( GatorBelow0, -1 ), colorRed, IIf( GatorBelow0 < Ref( GatorBelow0, -1 ), colorGreen, colorGrey40 ) ) );
PlotOHLC( 0, GatorBelow0, 0, GatorBelow0, _DEFAULT_NAME(), BarColorBelow, styleCandle | styleNoLabel | stylenotitle );
_SECTION_END();

You might also like