alligator_v1
Download scriptThis tool is a technical analysis indicator designed to help traders visualize market trends by using a specialized moving average system. It creates three distinct visual lines on your chart, which collectively form what is known as the "Alligator" indicator. Each line represents a different layer of price momentum, calculated based on specific timeframes and smoothing methods.
How the Logic Works
The script analyzes price data to generate three unique components:
- The Jaws (Blue Line): This is the broadest component of the indicator. It looks at a larger window of historical price data to determine the long-term trend. Because it uses a longer period, it moves more slowly and provides a "big picture" view of where the market is heading.
- The Teeth (Red Line): This represents the medium-term momentum. It processes a shorter timeframe of data than the Jaws, allowing it to react faster to price changes while still maintaining a smooth path.
- The Lips (Lime Line): This is the most sensitive component. It uses the shortest timeframe of data to track immediate price action. It reacts quickly to fluctuations, showing the most recent "mood" of the market.
Key Technical Characteristics
To ensure the data is readable and useful for human eyes, the script applies several specific behaviors:
- Smoothing: Instead of reacting erratically to every tiny price tick, the indicator uses a "Smoothed Moving Average" (SMMA) calculation. This filters out market "noise," making it easier for traders to identify clear trends rather than getting distracted by insignificant fluctuations.
- Median Pricing: The logic calculates these averages based on the median price (the midpoint between the high and low prices of a candle). This provides a balanced view of the market's value, rather than relying solely on opening or closing prices.
- Visual Offsetting (Shifts): Each of the three lines is intentionally "shifted" forward in time on your chart. This creates a visual gap between the lines, mimicking the physical appearance of an alligator’s head. By shifting the data, it allows traders to see the relationship between different trend speeds more clearly without the lines overlapping into a messy bundle.
- Dynamic Drawing: The script is designed to automatically calculate these positions across your entire price history, ensuring that as new candles form in real-time, the Jaws, Teeth, and Lips update instantly to reflect current market conditions.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Alligator.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Lime
//---- input parameters
extern int JawsPeriod=13;
extern int JawsShift=8;
extern int TeethPeriod=8;
extern int TeethShift=5;
extern int LipsPeriod=5;
extern int LipsShift=3;
//---- indicator buffers
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- line shifts when drawing
SetIndexShift(0,JawsShift);
SetIndexShift(1,TeethShift);
SetIndexShift(2,LipsShift);
//---- first positions skipped when drawing
SetIndexDrawBegin(0,JawsShift+JawsPeriod);
SetIndexDrawBegin(1,TeethShift+TeethPeriod);
SetIndexDrawBegin(2,LipsShift+LipsPeriod);
//---- 3 indicator buffers mapping
SetIndexBuffer(0,ExtBlueBuffer);
SetIndexBuffer(1,ExtRedBuffer);
SetIndexBuffer(2,ExtLimeBuffer);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
//---- index labels
SetIndexLabel(0,"Gator Jaws");
SetIndexLabel(1,"Gator Teeth");
SetIndexLabel(2,"Gator Lips");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Bill Williams' Alligator |
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(int i=0; i<limit; i++)
{
//---- ma_shift set to 0 because SetIndexShift called abowe
ExtBlueBuffer[i]=iMA(NULL,0,JawsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtRedBuffer[i]=iMA(NULL,0,TeethPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
ExtLimeBuffer[i]=iMA(NULL,0,LipsPeriod,0,MODE_SMMA,PRICE_MEDIAN,i);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments