//+------------------------------------------------------------------+ //| IchimokuAlert_v1.mq4 | //| Copyright © 2006, Forex-TSD.com | //| Written by IgorAD,igorad2003@yahoo.co.uk | //| http://finance.groups.yahoo.com/group/TrendLaboratory | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, Forex-TSD.com " #property link "http://www.forex-tsd.com/" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 SandyBrown #property indicator_color4 Thistle #property indicator_color5 Lime #property indicator_color6 SandyBrown #property indicator_color7 Thistle //---- input parameters extern int Tenkan=9; extern int Kijun=26; extern int Senkou=52; extern int AlertMode=0; //---- buffers double Tenkan_Buffer[]; double Kijun_Buffer[]; double SpanA_Buffer[]; double SpanB_Buffer[]; double Chinkou_Buffer[]; double SpanA2_Buffer[]; double SpanB2_Buffer[]; //---- int a_begin; bool UptrendAlert1,DntrendAlert1,UptrendAlert2,DntrendAlert2; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,Tenkan_Buffer); SetIndexDrawBegin(0,Tenkan-1); SetIndexLabel(0,"Tenkan Sen"); //---- SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Kijun_Buffer); SetIndexDrawBegin(1,Kijun-1); SetIndexLabel(1,"Kijun Sen"); //---- a_begin=Kijun; if(a_beginTenkan) i=Bars-counted_bars-1; while(i>=0) { high=High[i]; low=Low[i]; k=i-1+Tenkan; while(k>=i) { price=High[k]; if(highprice) low=price; k--; } Tenkan_Buffer[i]=(high+low)/2; i--; } //---- Kijun Sen i=Bars-Kijun; if(counted_bars>Kijun) i=Bars-counted_bars-1; while(i>=0) { high=High[i]; low=Low[i]; k=i-1+Kijun; while(k>=i) { price=High[k]; if(highprice) low=price; k--; } Kijun_Buffer[i]=(high+low)/2; i--; } //---- Senkou Span A i=Bars-a_begin+1; if(counted_bars>a_begin-1) i=Bars-counted_bars-1; while(i>=0) { price=(Kijun_Buffer[i]+Tenkan_Buffer[i])/2; SpanA_Buffer[i]=price; SpanA2_Buffer[i]=price; i--; } //---- Senkou Span B i=Bars-Senkou; if(counted_bars>Senkou) i=Bars-counted_bars-1; while(i>=0) { high=High[i]; low=Low[i]; k=i-1+Senkou; while(k>=i) { price=High[k]; if(highprice) low=price; k--; } price=(high+low)/2; SpanB_Buffer[i]=price; SpanB2_Buffer[i]=price; i--; } //---- Chinkou Span i=Bars-1; if(counted_bars>1) i=Bars-counted_bars-1; while(i>=0) { Chinkou_Buffer[i]=Close[i]; i--; } //---- if (AlertMode == 1 || AlertMode == 3) { string Message1 = Symbol()+" M"+Period()+":Tenkan crosses Kijun"; if ( Tenkan_Buffer[0]>Kijun_Buffer[0] && Tenkan_Buffer[1]Kijun_Buffer[1]) PlaySound("alert.wav"); if ( Tenkan_Buffer[1]>Kijun_Buffer[1] && Tenkan_Buffer[2]Kijun_Buffer[2] && !DntrendAlert1) {Alert(Message1+"Signal for SELL"); UptrendAlert1 = false; DntrendAlert1 = true;} } if (AlertMode == 2 || AlertMode == 3) { string Message2 = Symbol()+" M"+Period()+":Chinkou crosses Price"; if ( Close[0]>Close[0+Kijun] && Close[1]Close[1+Kijun]) PlaySound("alert2.wav"); if ( Close[1]>Close[1+Kijun] && Close[2]Close[2+Kijun] && !DntrendAlert2) {Alert(Message2+":Signal for SELL"); DntrendAlert2 = true; UptrendAlert2 = false;} } return(0); } //+------------------------------------------------------------------+