Author: Copyright � 2004, MetaQuotes Software Corp.
Alligator3

This script is designed to function as a visual trading tool, specifically an indicator for the MetaTrader platform. Its primary purpose is to analyze market momentum by calculating and displaying three distinct components that represent different "powers" within the price action, combined with an overall trend line.

How the Logic Works

The indicator operates by scanning historical price data to identify the strength of buying and selling pressures. It processes this information through the following steps:

1. Identifying Market Forces The script looks at specific price types (the typical price) over a set period of time to calculate two primary forces:

  • Bullish Power: This measures the upward momentum or the strength of the "buyers" in the market.
  • Bearish Power: This measures the downward momentum or the strength of the "sellers" in the market.

2. Synthesizing the Components The indicator then organizes these forces into three visual elements, often referred to as the "Alligator" components:

  • Gator Jaws: Represents the calculated Bullish Power.
  • Gator Teeth: Represents the calculated Bearish Power.
  • Gator Lips: This is a synthesized value created by adding the Bullish and Bearish powers together. This provides a combined view of total market activity.

3. Visual Representation To make this data easy for a user to read on a chart, the script handles the visual styling automatically:

  • The Jaws, Teeth, and Lips are displayed as histograms (vertical bars), which allow you to see the magnitude of market pressure at specific moments in time.
  • A separate Trend line is also included to provide a continuous view of the overall direction of the market.

Key Features for the User

  • Customizable Offsets: You can adjust the "Shift" and "Period" for each component. This allows you to decide how far back in time the indicator should look to determine its calculations, helping you smooth out noise or react more quickly to sudden price changes.
  • Dynamic Recalculation: The script is designed to automatically update as new candles form on your chart, ensuring that the momentum data remains current with live market movements.
  • Visual Clarity: By separating the "power" of buyers and sellers into distinct visual bars, the tool helps traders see whether the market is being driven more by aggressive buying, aggressive selling, or a balance of both.
Indicators Used
Bulls Power indicator Bears Power indicator
Miscellaneous
Implements a curve of type %1
17 Views
0 Downloads
0 Favorites
Alligator3
//+------------------------------------------------------------------+
//|                                                    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_separate_window
#property indicator_buffers 4
//#property indicator_color1 Blue
#property indicator_color2 Red
//#property indicator_color3 Lime
//---- input parameters
extern int JawsPeriod=5;
extern int JawsShift=0;
extern int TeethPeriod=8;
extern int TeethShift=0;
extern int LipsPeriod=5;
extern int LipsShift=0;
extern int trend=0;
extern int trendShift=0;
//---- indicator buffers
double ExtBlueBuffer[];
double ExtRedBuffer[];
double ExtLimeBuffer[];
double TrendBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- line shifts when drawing
   SetIndexShift(0,JawsShift);
   SetIndexShift(1,TeethShift);
   SetIndexShift(2,LipsShift);
   SetIndexShift(3,trendShift);
//---- first positions skipped when drawing
   SetIndexDrawBegin(0,JawsShift+JawsPeriod);
   SetIndexDrawBegin(1,TeethShift+TeethPeriod);
   SetIndexDrawBegin(2,LipsShift+LipsPeriod);
   SetIndexDrawBegin(3,trend);
//---- 3 indicator buffers mapping
   SetIndexBuffer(0,ExtBlueBuffer);
   SetIndexBuffer(1,ExtRedBuffer);
   SetIndexBuffer(2,ExtLimeBuffer);
   SetIndexBuffer(3,TrendBuffer);
//---- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexStyle(2,DRAW_HISTOGRAM);
   SetIndexStyle(3,DRAW_LINE);
//---- index labels
   SetIndexLabel(0,"Gator Jaws");
   SetIndexLabel(1,"Gator Teeth");
   SetIndexLabel(2,"Gator Lips");
   SetIndexLabel(3,"trend");
//---- 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]=iBullsPower(NULL, 0, 6,PRICE_TYPICAL,i);
      ExtRedBuffer[i]=iBearsPower(NULL, 0, 6,PRICE_TYPICAL,i);//iBearsPower(NULL, 0, 11,PRICE_CLOSE,i)+;iBullsPower(NULL, 0, 11,PRICE_CLOSE,i);




ExtLimeBuffer[i]=ExtRedBuffer[i]+ExtBlueBuffer[i];


    }
//---- done
   return(0);
  }
//+------------------------------------------------------------------+

Comments