Candlestick Identification_MT4_In

Download script
Candlestick Identification_MT4_In

This script is an automated technical analysis tool designed to scan price charts and identify specific candlestick patterns. It acts as a visual assistant for traders by automatically recognizing complex price behaviors that typically require manual inspection to detect.

How the Logic Works

The script processes the historical data of the market (the "bars" or "candles" on your chart) by examining the relationship between three consecutive candles at a time. It evaluates several key metrics for each candle, including:

  • Body Size: The difference between the opening and closing prices.
  • Wicks/Shadows: The distance between the highest and lowest points relative to the body.
  • Relative Positioning: How the current candle compares to the sizes and directions of the candles immediately preceding it.

Pattern Recognition

The logic is programmed to look for a wide variety of specific market behaviors, categorized by different trading methodologies. When the script detects a price movement that matches these predefined rules, it identifies the pattern by name. These include:

  • Reversal Patterns: Such as "Hammers," "Inverted Hammers," and "Shooting Stars," which indicate potential changes in trend direction.
  • Continuation Patterns: Such as "Three White Soldiers," which suggest a strong ongoing move in a specific direction.
  • Momentum & Exhaustion: Patterns like "Marubozu" (showing decisive movement), "Engulfing" candles (where one candle completely covers the previous one), and "Piercing" patterns.
  • Neutrality Indicators: Recognition of "Dojis," which represent periods of market indecision.

Visual Output

Instead of just calculating these values in the background, the script provides immediate visual feedback. Whenever a recognized pattern is detected on the chart, the script automatically creates a text label above that specific candle.

The labels are displayed in Red Arial font, identifying the specific name of the pattern (e.g., "Engulf," "Hammer," or "Doji"). This allows you to quickly scroll through historical data to see where significant price actions occurred without having to manually interpret every individual candle.

Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each barSeries array that contains the highest prices of each barSeries array that contains the lowest prices of each bar
Miscellaneous
It issuies visual alerts to the screen
9 Views
0 Downloads
0 Favorites
Candlestick Identification_MT4_In
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

#property  copyright "VMesquita"
#property  indicator_chart_window	  // an indicator is drawn in the main chart window
#property  indicator_buffers 1
int limit;
int init ()
  {
//----
   return(0);
  }
int deinit()
  {
   return(0);
  }
int start()
	{
   double O,C,H,L,O1,C1,H1,L1,O2,C2,H2,L2;
   string text;
   int counted_bars=IndicatorCounted();
   limit=Bars-counted_bars;
   //---- check for possible errors
   if(counted_bars<0) {
	  Alert("No Bars..");
	  return(-1);
   }
   //---- last counted bar will be recounted
   for(int i=1; i<limit; i++) {
	  O=iOpen(NULL,0,i);
	  C=iClose(NULL,0,i);
	  H=iHigh(NULL,0,i);
	  L=iLow(NULL,0,i);
	  
	  O1=iOpen(NULL,0,i-1);
	  C1=iClose(NULL,0,i-1);
	  H1=iHigh(NULL,0,i-1);
	  L1=iLow(NULL,0,i-1);
	  O2=iOpen(NULL,0,i+1);
	  C2=iClose(NULL,0,i+1);
	  H2=iHigh(NULL,0,i+1);
	  L2=iLow(NULL,0,i+1);

	  
	  
	  text="";	 
	 if(((H-L)>4*(O-C))&&((C-L)/(0.001+H-L)>=0.75)&&((O-L)/(0.001+H-L)>=0.75)) text="Hang";
	 if(((H-L)>3*(O-C))&&((C-L)/(0.001+H-L)>0.6)&&((O-L)/(0.001+H-L)>0.6)) text="Hammer";
	 if(((H-L)>3*(O-C))&&((H-C)/(0.001+H-L)>0.6)&&((H-O)/(0.001+H-L)>0.6)) text="IHammer";
	 if((O2>C2)&&((O2-C2)/(0.001+H2-L2)>0.6)&&(C2>O1)&&(O1>C1)&&((H1-L1)>(3*(C1-O1)))&&(C>O)&&(O>O1)) text="MStar";
	  if((O>C)&&(H==O)&&(C==L)) text="LMarubozu";
	  if((C>O)&&(H==C)&&(O==L)) text="HMarubozu";
	 if((C1==O1)&&(C2>O2)&&(O>C)&&(L1>H2)&&(L1>H)) text="ABaby";
	 if((C1==O1)&&(O2>C2)&&(C>O)&&(L2>H1)&&(L>H1)) text="ABaby";
	 if((C2>O2)&&((C2-O2)/(0.001+H2-L2)>0.6)&&(C2<O1)&&(C1>O1)&&((H1-L1)>(3*(C1-O1)))&&(O>C)&&(O<O1)) text="EStar";
	 if((C1>O1)&&(((C1+O1)/2)>C)&&(O>C)&&(O>C1)&&(C>O1)&&((O-C)/(0.001+(H-L))>0.6)) text="DCloud";
	 if((C1>O1)&&(O>C)&&(O>=C1)&&(O1>=C)&&((O-C)>(C1-O1))) text="Engulf";
	 if((O1>C1)&&(C>O)&&(C>=O1)&&(C1>=O)&&((C-O)>(O1-C1))) text="Engulf";
	 if((O1>C1)&&(C>O)&&(C<=O1)&&(C1<=O)&&((C-O)<(O1-C1))) text="Harami";
	 if((C1>O1)&&(O>C)&&(O<=C1)&&(O1<=C)&&((O-C)<(C1-O1))) text="Harami";
	 if((C1<O1)&&(((O1+C1)/2)<C)&&(O<C)&&(O<C1)&&(C<O1)&&((C-O)/(.001+(H-L))>0.6)) text="Piercing";
	 if((C>O*1.01)&&(C1>O1*1.01) &&(C2>O2*1.01) &&(C>C1) &&(C1>C2) &&(O<C1&&O>O1) &&(O1<C2&&O1>O2) &&(((H-C)/(H-L))<0.2) &&(((H1-C1)/(H1-L1))<0.2)&&(((H2-C2)/(H2-L2))<0.2)) text="Three White Soldiers";
	 if(((H-L)>4*(O-C))&&((H-C)/(0.001+H-L)>= 0.75)&&((H-O)/(0.001+H-L)>=0.75)) text="SStar";
	  if(C==O) text="Doji";
	  //If we found a special candlem write in the Chart
	  if(text!="")
	  {
	  ObjectCreate(DoubleToStr(i,0)+" label", OBJ_TEXT, 0, Time[i], H);
	  ObjectSetText(DoubleToStr(i,0)+" label", text, 8, "Arial", Red);
	  }
	}
}

Comments