Navigation:Home > Content >

Pattern_Indicator.mq4

Time: 2013-02-10 | Download file:Pattern_Indicator.mq4

//+------------------------------------------------------------------+
//|                                            Bheurekso_pattern.mq4 |
//|                                                   Nikelodeon     |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Nikelodeon"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
//---- input parameters
extern bool       lines=true;
extern int       step=500;
extern bool       Dell=true;

//----buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,108);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,108);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
//----
	ObjectsDeleteAll(0,OBJ_TEXT);
	ObjectsDeleteAll(0,OBJ_ARROW);
	ObjectsDeleteAll(0,OBJ_TREND);
	//DelArrow(0,0); 
   return(0);

  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
 ObjectsDeleteAll(0,OBJ_TEXT);
ObjectsDeleteAll(0,OBJ_ARROW);  
ObjectsDeleteAll(0,OBJ_TREND);  
//----
   return(0);
  }

//+------------------------------------------------------------------+
//SetArrow(t[shift1],l[shift1]-15*Point,241,LIME);
void SetArrow(int sh, datetime tm, double pr, int cod,color clr)
{
	ObjectCreate("Arrow-"+sh,OBJ_ARROW,0,tm,pr);
	ObjectSet("Arrow-"+sh,OBJPROP_ARROWCODE,cod);
	ObjectSet("Arrow-"+sh,OBJPROP_COLOR,clr);
}
void SetArrow1(int sh, datetime tm, double pr, int cod,color clr)
{
	ObjectCreate("Arrow+"+sh,OBJ_ARROW,0,tm,pr);
	ObjectSet("Arrow+"+sh,OBJPROP_ARROWCODE,cod);
	ObjectSet("Arrow+"+sh,OBJPROP_COLOR,clr);
}

//SetText(t[shift1],l[shift1]-28*Point,"Engulfing",LIME);
void SetText(int sh,datetime tm,double pr,string text,color clr)
{
	ObjectCreate("x"+sh,OBJ_TEXT,0,tm,pr);
	ObjectSetText("x"+sh,text);
	ObjectSet("x"+sh,OBJPROP_COLOR,clr);
}
void SetText1(int sh,datetime tm,double pr,string text,color clr)
{
	ObjectCreate("y"+sh,OBJ_TEXT,0,tm,pr);
	ObjectSetText("y"+sh,text);
	ObjectSet("y"+sh,OBJPROP_COLOR,clr);
}

void Setline(int sh,datetime tm,double pr,datetime tm1,double pr1, color clr)
{
	ObjectCreate("-"+sh,OBJ_TREND,0,tm,pr,tm1,pr1,clr);
	ObjectSet("-"+sh,7,STYLE_SOLID);
	ObjectSet("-"+sh,10,false);
	ObjectSet("-"+sh,6,Yellow);
}
void Setline1(int sh,datetime tm,double pr,datetime tm1,double pr1, color clr)
{
	ObjectCreate("+"+sh,OBJ_TREND,0,tm,pr,tm1,pr1,clr);
	ObjectSet("+"+sh,7,STYLE_SOLID);
	ObjectSet("+"+sh,10,false);
	ObjectSet("+"+sh,6,LightBlue);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
	int    counted_bars=IndicatorCounted();
//---- 
	int myBars=0, StartBar=0;//, Kedip(false);
	int shift=0, shift1=0, shift2=0, shift3=0;
	bool BullEngulf=False, MorningStar=False, BullPierce=False, Hammer=False,Name=false,Arrow=false;
	bool BearEngulf=False, EveningStar=False, DarkCloud=False, Shooter=False,Name1=false,Arrow1=false;
	bool BullHarami=False, BearHarami=false, BullCross=false, BearCross=false,up=false,down=false; 
	int limit,n,a,b,x,k, doji=false; 
  	double  l[1000] ,h[1000];

	int p3[100],x1[100];
p3[1]=0;	
	if(myBars!=Bars) 
	{ 
		myBars=Bars; 
	}
   limit=step;//Bars-counted_bars;
	for(shift=limit;shift>=0;shift--) 
	{
		// Manjakan MT
		shift1=shift+1;
		shift2=shift+2;
		shift3=shift+3;

		//*** periksa pola bullish***
		//***************************
		//Определение рыночной тенденции
		//В НШ можно отфильтровать для прогноза будущеё на время
		if ((iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift)>iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift1)) &&
		(iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift1)>iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift2)) &&
		(iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift2)>iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift3))) up=true;
		else up=false;
		if ((iMA(NULL,0,5,0,MODE_EMA,PRICE_CLOSE,shift)Close[shift2]) && (Open[shift1]>Close[shift2]) && (Close[shift1]Open[shift1]))
		      BullHarami=true;
		  else BullHarami=false;
		
		//Проникающие линии бычков
		   
		if ((Open[shift2]>Close[shift2]) && (Open[shift1]>Close[shift2])&& (Open[shift1]Open[shift2]))
		   BullCross=true;
		   else BullCross=false;
		   
		//--- Bullish Engulfing (2 bars)
		if((Close[shift2]Open[shift2])) 
			BullEngulf=True;
		else 
			BullEngulf=False;
		
		//--- Bullish Piercing (2 bars) cuma cari kalo ga ada BullEngulf
		if(!BullEngulf)
		{
			if((Close[shift2]Open[shift1]) && 
					((Open[shift1]Close[shift2]+((Open[shift2]-Close[shift2])/2))) 
				BullPierce=True;
			else 
				BullPierce=False;
		}
		else 
		{
			BullPierce=False;
		}
		
		// Morning Star (3 bars)
		if((Close[shift3]Close[shift2]) && (Open[shift1]>Open[shift2])) && (Close[shift1]>=Close[shift3]))
			MorningStar=True;
		else
			MorningStar=False;
		
		// Hammer
		if((Open[shift1]-Low[shift1]>MathMax(High[shift1]-Close[shift1],Close[shift1]-Open[shift1])*3) &&
		   (Close[shift1]-Low[shift1]>MathMax(High[shift1]-Close[shift1],Close[shift1]-Open[shift1])*3))
			Hammer=True;
		else 
		 	Hammer=False;
		
		//*** periksa pola bearish***
		//***************************
		//Харами Вниз		
		if ((up)&&(Open[shift2]Open[shift2]) &&
		      (Close[shift1]Open[shift2])&& (Close[shift1]Open[shift2]) && (Close[shift1]Close[shift2]) &&
				((Close[shift1]Open[shift2]) && ((Open[shift1]>Close[shift2]) /*|| (High[shift1]>High[shift2]*/) &&
					(Close[shift1]Open[shift3]) && (Open[shift2]>Close[shift3]) && (Close[shift2]>Close[shift3]) && 
				((Open[shift1]MathMax(Close[shift1]-Low[shift1],Open[shift1]-Close[shift1])*3)&&
		   (High[shift1]-Close[shift1]>MathMax(Close[shift1]-Low[shift1],Open[shift1]-Close[shift1])*3)) 
			Shooter=True;
		else
			Shooter=False;
			
	//подтверждение		
			if( (BullEngulf || BullPierce || MorningStar || BullHarami || BullCross ) && 
				(Close[shift]>Close[shift1])&& Close[shift]>Open[shift1]){
//			ExtMapBuffer1[shift] = Low[shift]-7*Point;
			Name=true;
			Arrow=true;
			}
		else 
			{ExtMapBuffer1[shift] = 0.0; Name=false; Arrow=false; }

		if( (BearEngulf || DarkCloud || EveningStar || Shooter || BearHarami || BearCross) && 
				(Close[shift]h[q]){ObjectSet("+"+q,6,Black); ObjectSet("+"+q,7,STYLE_DASHDOT);
                ObjectSet("y"+q,OBJPROP_COLOR,Black);ObjectSet("Arrow+"+q,OBJPROP_COLOR,Black);
              if (Dell) {ObjectDelete("+"+q);ObjectDelete("y"+q);ObjectDelete("Arrow+"+q);}
               }
             

}

	}	// Tampilkan disaat ada konfirmasi.
		
		StartBar-=1;
	}
	
//Comment(p3[1],p3[2],p3[3],p3[4],p3[5],p3[6],p3[7],)	;
//Comment(x1[1],x1[2],x1[3],x1[4],x1[5],x1[6],x1[7],)	;
	
//----
   return(0);
}
//+------------------------------------------------------------------+

Recommend