AntiAlligator
Download scriptThis script is a specialized technical analysis tool designed to identify specific price momentum shifts by analyzing the relationship between market trends and price action. It functions by interpreting "Alligator" indicator data—a common trading concept that uses three moving averages (the Jaws, Teeth, and Lips)—and layering on additional logic to filter out false signals.
Core Logic Overview
The tool works by comparing the relative positions of two specific components: the Jaws and the Lips. By tracking which one is higher or lower, the script determines the underlying market trend. However, rather than just following the trend blindly, the script looks for "reversals" or "exhaustion" points.
How the Signals Are Generated
The tool monitors three specific conditions simultaneously to decide when to provide a visual signal on your chart:
- Trend Direction: It establishes whether the market is currently moving in an upward or downward direction based on the spacing between the Jaws and the Lips.
- Price Positioning (Rotation): It looks at where the previous candle closed relative to its own midline. This helps the script understand if the price is attempting to "turn around" compared to its recent movement.
- Breach Detection: The script identifies a signal when the price pushes past specific boundaries (the high or low of the previous candle) while simultaneously contradicting the current trend or showing significant momentum.
Visual Output
The tool provides three types of visual feedback to help a trader make decisions:
- Histogram Bars: These appear in a separate window and represent the "delta" (the distance between the price and the indicator line). This helps visualize the strength of the move.
- Buy Signals (Red Arrows): These appear when the script detects a specific bullish momentum shift where the trend is down, but the price shows signs of rebounding upward with enough force to break previous resistance.
- Sell Signals (Blue Arrows): These appear when the script detects a bearish momentum shift where the trend is up, but the price shows signs of dropping downward with enough force to break previous support.
Summary for the User
Essentially, this tool acts as a "filter." It doesn't just tell you what the market is doing right now; it waits for the market to show a specific type of exhaustion or momentum shift. When the price action "conflicts" with the established trend in a significant way, the script flags those moments with arrows, signaling potential opportunities where the market might be changing direction.
//+------------------------------------------------------------------+
//| AntiAlligator.mq4 |
//| vasbsm@mail.ru |
//+------------------------------------------------------------------+
#property copyright "@"
#property link "zfs"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_width1 3
#property indicator_width2 3
#property indicator_level1 20 //áàé
#property indicator_level2 20 //ñåëë
#property indicator_levelcolor Yellow
extern int JawsPeriod=13;
extern int JawsShift=8;
extern int TeethPeriod=8;
extern int TeethShift=5;
extern int LipsPeriod=5;
extern int LipsShift=3;
extern int TypeMA=MODE_SMMA;
extern int TypePrice=PRICE_MEDIAN;
//---- buffers
double OscBufferBuy[];
double OscBufferSell[];
//------------
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,OscBufferBuy);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,OscBufferSell);
SetIndexDrawBegin(0,10);
SetIndexDrawBegin(1,10);
IndicatorShortName("ANTIALLIGATOR");
return(0);
}
int deinit()
{
ObjectsDeleteAll(0,OBJ_ARROW);
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
int limit;
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
int trend=0;
int razvorot=0;
double delta=0;
string name_buy,name_sell;
for(int i=0; i<limit; i++)
{
OscBufferBuy[i]=0;
OscBufferSell[i]=0;
}
for(i=0; i<limit; i++)
{
double jaw=iAlligator(NULL,0,JawsPeriod,JawsShift,TeethPeriod,TeethShift,LipsPeriod,LipsShift,TypeMA,TypePrice,MODE_GATORJAW,i);
double lips=iAlligator(NULL,0,JawsPeriod,JawsShift,TeethPeriod,TeethShift,LipsPeriod,LipsShift,TypeMA,TypePrice,MODE_GATORLIPS,i);
double high1=iHigh(NULL,0,i+1);
double low1=iLow(NULL,0,i+1);
double close1=iClose(NULL,0,i+1);
double close0=iClose(NULL,0,i);
if (lips>jaw)trend=1;
if (lips<jaw)trend=-1;
if (close1>(high1+low1)/2.0)razvorot=1;
if (close1<(high1+low1)/2.0)razvorot=-1;
if (trend==1)delta=close0-lips;
if (trend==-1)delta=lips-close0;
if (close0<lips&&trend==-1&&razvorot==1&&close0>high1)OscBufferBuy[i]=delta;
if (close0>lips&&trend==1&&razvorot==-1&&close0<low1)OscBufferSell[i]=delta;
name_buy="buy"+DoubleToStr(i,0);
name_sell="sell"+DoubleToStr(i,0);
if (OscBufferSell[i]>indicator_level2*Point)SetArrow(SYMBOL_ARROWDOWN,Blue,name_sell,Time[i],High[i]+3*Point,3);
if (OscBufferBuy[i]>indicator_level1*Point)SetArrow(SYMBOL_ARROWUP,Red,name_buy,Time[i],Low[i]-3*Point,3);
}
return(0);
}
//+----------------------------------------------------------------------------+
//| Àâòîð : Êèì Èãîðü Â. aka KimIV, http://www.kimiv.ru |
//+----------------------------------------------------------------------------+
//| Âåðñèÿ : 12.10.2007 |
//| Îïèñàíèå : Óñòàíîâêà çíà÷êà íà ãðàôèêå, îáúåêòà OBJ_ARROW. |
//+----------------------------------------------------------------------------+
//| Ïàðàìåòðû: |
//| cd - êîä çíà÷êà |
//| cl - öâåò çíà÷êà |
//| nm - íàèìåíîâàíèå ("" - âðåìÿ îòêðûòèÿ òåêóùåãî áàðà) |
//| t1 - âðåìÿ îòêðûòèÿ áàðà (0 - òåêóùèé áàð) |
//| p1 - öåíîâîé óðîâåíü (0 - Bid) |
//| sz - ðàçìåð çíà÷êà (0 - ïî óìîë÷àíèþ) |
//+----------------------------------------------------------------------------+
void SetArrow(int cd, color cl,
string nm="", datetime t1=0, double p1=0, int sz=0) {
if (nm=="") nm=DoubleToStr(Time[0], 0);
if (t1<=0) t1=Time[0];
if (p1<=0) p1=Bid;
if (ObjectFind(nm)<0) ObjectCreate(nm, OBJ_ARROW, 0, 0,0);
ObjectSet(nm, OBJPROP_TIME1 , t1);
ObjectSet(nm, OBJPROP_PRICE1 , p1);
ObjectSet(nm, OBJPROP_ARROWCODE, cd);
ObjectSet(nm, OBJPROP_COLOR , cl);
ObjectSet(nm, OBJPROP_WIDTH , sz);
}
Comments