一目均衡报警
//+------------------------------------------------------------------+//| 一目均衡报警.mq4 |
//| |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int Tenkan=9;
extern int Kijun=26;
extern int Senkou=52;
extern int AlertMode=0;
extern int AlertTimes=3;
extern int ReAlertSeconds=1;
//---- buffers
double Tenkan_Buffer[];
double Kijun_Buffer[];
double SpanA_Buffer[];
double SpanB_Buffer[];
double Chinkou_Buffer[];
double SpanA2_Buffer[];
double SpanB2_Buffer[];
int Flag=0,Flag1=0;
//----
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_begin<Tenkan) a_begin=Tenkan;
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(2,SpanA_Buffer);
SetIndexDrawBegin(2,Kijun+a_begin-1);
SetIndexShift(2,Kijun);
SetIndexLabel(2,NULL);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(5,SpanA2_Buffer);
SetIndexDrawBegin(5,Kijun+a_begin-1);
SetIndexShift(5,Kijun);
SetIndexLabel(5,"Senkou Span A");
//----
SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_DOT);
SetIndexBuffer(3,SpanB_Buffer);
SetIndexDrawBegin(3,Kijun+Senkou-1);
SetIndexShift(3,Kijun);
SetIndexLabel(3,NULL);
SetIndexStyle(6,DRAW_LINE,STYLE_DOT);
SetIndexBuffer(6,SpanB2_Buffer);
SetIndexDrawBegin(6,Kijun+Senkou-1);
SetIndexShift(6,Kijun);
SetIndexLabel(6,"Senkou Span B");
//----
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,Chinkou_Buffer);
SetIndexShift(4,-Kijun);
SetIndexLabel(4,"Chinkou Span");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Ichimoku Kinko Hyo |
//+------------------------------------------------------------------+
int start()
{
int i,k;
int counted_bars=IndicatorCounted();
double high,low,price;
//----
if(Bars<=Tenkan || Bars<=Kijun || Bars<=Senkou) return(0);
//---- initial zero
if(counted_bars<1)
{
for(i=1;i<=Tenkan;i++) Tenkan_Buffer=0;
for(i=1;i<=Kijun;i++) Kijun_Buffer=0;
for(i=1;i<=a_begin;i++) { SpanA_Buffer=0; SpanA2_Buffer=0; }
for(i=1;i<=Senkou;i++){ SpanB_Buffer=0; SpanB2_Buffer=0; }
}
//---- Tenkan Sen
i=Bars-Tenkan;
if(counted_bars>Tenkan) i=Bars-counted_bars-1;
while(i>=0)
{
high=High; low=Low; k=i-1+Tenkan;
while(k>=i)
{
price=High;
if(high<price) high=price;
price=Low;
if(low>price)low=price;
k--;
}
Tenkan_Buffer=(high+low)/2;
i--;
}
//---- Kijun Sen
i=Bars-Kijun;
if(counted_bars>Kijun) i=Bars-counted_bars-1;
while(i>=0)
{
high=High; low=Low; k=i-1+Kijun;
while(k>=i)
{
price=High;
if(high<price) high=price;
price=Low;
if(low>price)low=price;
k--;
}
Kijun_Buffer=(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+Tenkan_Buffer)/2;
SpanA_Buffer=price;
SpanA2_Buffer=price;
i--;
}
//---- Senkou Span B
i=Bars-Senkou;
if(counted_bars>Senkou) i=Bars-counted_bars-1;
while(i>=0)
{
high=High; low=Low; k=i-1+Senkou;
while(k>=i)
{
price=High;
if(high<price) high=price;
price=Low;
if(low>price)low=price;
k--;
}
price=(high+low)/2;
SpanB_Buffer=price;
SpanB2_Buffer=price;
i--;
}
//---- Chinkou Span
i=Bars-1;
if(counted_bars>1) i=Bars-counted_bars-1;
while(i>=0) { Chinkou_Buffer=Close; i--; }
//----
if (AlertMode == 1 || AlertMode == 3)
{
string Message1 = Symbol()+" M"+Period()+":Tenkan crosses Kijun";
if ( Tenkan_Buffer>Kijun_Buffer && Tenkan_Buffer<Kijun_Buffer)
PlaySound("alert.wav");
if ( Tenkan_Buffer<Kijun_Buffer && Tenkan_Buffer>Kijun_Buffer)
PlaySound("alert.wav");
if ( Tenkan_Buffer>Kijun_Buffer && Tenkan_Buffer<Kijun_Buffer && !UptrendAlert1)
{Alert(Message1+"Signal for BUY"); UptrendAlert1 = true; DntrendAlert1 = false;}
if ( Tenkan_Buffer<Kijun_Buffer && Tenkan_Buffer>Kijun_Buffer && !DntrendAlert1)
{Alert(Message1+"Signal for SELL"); UptrendAlert1 = false; DntrendAlert1 = true;}
}
if ( Tenkan_Buffer>=Kijun_Buffer )
{
if (Flag==0)
{
Flag=1;
Alert("--▲▲--",Symbol(),"--",Period());
}
}else Flag=0;
if ( Tenkan_Buffer<=Kijun_Buffer)
{
if (Flag1==0)
{
Flag1=1;
Alert("--▼▼--",Symbol(),"--",Period());
}
}else Flag1=0;
return(0);
}
//+------------------------------------------------------------------+
没看完~~~~~~ 先顶,好同志 路过,支持一下啦 帮你顶下哈!! 帮你顶下哈!! 学习了,不错 {:1_186:} {:1_181:} 支持下 支持下
页:
[1]