比葫芦画瓢自制双线MACD带箭头邮件声音通知大全,太闹求解
按站里MT4入门教程,比葫芦画瓢,自学的双线MACD,有交叉箭头提示,有邮件声音手机通知提醒。但是,为何各种提示总是提示个不停。要是在日线上叫一天,发一天,我了个去。没法用呀。哎。对比了十几个其它带报警的指标的代码,一个一个样,真没头绪呀,可怜我这小白呀,眼都快累瞎啦。本帖最后由 sdjndhls 于 2017-10-24 15:56 编辑
//+------------------------------------------------------------------+
//| macd vs macd _ X+ |
//+------------------------------------------------------------------+
#property indicator_buffers 5
#property indicator_separate_window
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Silver
#property indicator_color4 Yellow
#property indicator_color5 Blue
extern int Fast = 10;
extern int Slow = 22;
extern int Signal = 7;
extern bool AlertsMessage = true;//
extern bool AlertsSound = true;//
extern bool AlertsEmail = true;//
extern bool AlertsNotification = true;//
extern int K=1;//
//---- buffers
double Buffer1[];
double Buffer2[];
double Buffer3[];
double UP[];
double DO[];
string gs_92 = "";
string gs_100 = "YK_MACD_X+Alart";
int ba=0,sa=0;//
int t=0;//
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//IndicatorBuffers(3);
SetIndexStyle(0,DRAW_LINE,0,1);
SetIndexStyle(1,DRAW_LINE,0,1);
SetIndexStyle(2,DRAW_HISTOGRAM,0,1);
IndicatorDigits(Digits+2);
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
SetIndexBuffer(2,Buffer3);
IndicatorShortName("YK_MACD_X+("+Fast+","+Slow+","+Signal+")");
SetIndexLabel(0,"MACD_MAIN");
SetIndexLabel(1,"MACD_SIGNAL");
SetIndexLabel(2,"MAIN-SIGNAL");
SetIndexStyle(3,DRAW_ARROW);
SetIndexStyle(4,DRAW_ARROW);
SetIndexArrow(3,233);
SetIndexArrow(4,234);
SetIndexBuffer(3,UP);
SetIndexBuffer(4,DO);
SetIndexLabel(3,"BUY_SIGNAL");
SetIndexLabel(4,"SELL-SIGNAL");
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,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++)
{
Buffer1=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_MAIN,i);
Buffer2=iMACD(NULL,0,Fast,Slow,Signal,PRICE_CLOSE,MODE_SIGNAL,i);
Buffer3=Buffer1 - Buffer2;
}
for(i=0; i<limit; i++)
{
UP=EMPTY_VALUE;
DO=EMPTY_VALUE;
if (Buffer1>Buffer2&&Buffer1<Buffer2) {UP=Buffer2;}
if (Buffer1<Buffer2&&Buffer1>Buffer2) {DO=Buffer2;}
if (Buffer1>Buffer2&&Buffer1==Buffer2&&Buffer1<Buffer2) {UP=Buffer2;}
if (Buffer1<Buffer2&&Buffer1==Buffer2&&Buffer1>Buffer2) {DO=Buffer2;}
}
if(t!=Time){ba=0;sa=0;t=Time;}
string message1 = ("MACD金叉"+Symbol()+" TF("+Period()+")");
string message2 = ("MACD死叉"+Symbol()+" TF("+Period()+")");
if (Buffer1>Buffer2&&Buffer1<Buffer2 &&ba<3)
{
if (AlertsMessage) Alert(message1);
if (AlertsEmail) SendMail(message1,message1);
if (AlertsNotification) SendNotification(message1);
if (AlertsSound) PlaySound("alert2.wav");
ba++;
}
if (Buffer1<Buffer2&&Buffer1>Buffer2 &&sa<3) //就是错在这里了,SA都复制成了BA。经测试,这次是真好了。哈哈。用着自己写的指标,真是开森呀呀呀呀。
{
if (AlertsMessage) Alert(message2);
if (AlertsEmail) SendMail(message2,message2);
if (AlertsNotification) SendNotification(message2);
if (AlertsSound) PlaySound("alert2.wav");
sa++;
}
if (Buffer1>Buffer2&&Buffer1==Buffer2&&Buffer1<Buffer2 &&ba<3)
{
if (AlertsMessage) Alert(message1);
if (AlertsEmail) SendMail(message1,message1);
if (AlertsNotification) SendNotification(message1);
if (AlertsSound) PlaySound("alert2.wav");
ba++;
}
if (Buffer1<Buffer2&&Buffer1>Buffer2 &&sa<3)
{
if (AlertsMessage) Alert(message2);
if (AlertsEmail) SendMail(message2,message2);
if (AlertsNotification) SendNotification(message2);
if (AlertsSound) PlaySound("alert2.wav");
sa++;
}
return(0);
}
//+------------------------------------------------------------------+
想在提示里加个服务器时间,怎么回呢,只查到了个“TimeHour(CurTime())“,好像只有小时,而想要日期时分秒,怎么弄呢?
我又胡乱弄了一下,好像给好了, 没好,还是老样子,叫个不停。苦恼呀。 本帖最后由 sdjndhls 于 2017-10-24 15:57 编辑
f (Buffer1<Buffer2&&Buffer1>Buffer2 &&sa<3) //就是错在这里了,SA都复制成了BA。经测试,这次是真好了。
哈哈。用着自己写的指标,真是开森呀呀呀呀。
谁帮我点一下,已解决呀,我自己不能点哎。谢谢啦。
=========================================
return(0);
}
//+------------------------------------------------------------------+
想在提示里加个服务器时间,怎么回呢,只查到了个“TimeHour(CurTime())“,好像只有小时,而想要日期时分秒,怎么弄呢?
TimeMinute()
TimeSeconds() 自定义警报时间....搞定
页:
[1]