- UID
- 20622
- 积分
- 400
- 威望
- 205 布
- 龙e币
- 195 刀
- 在线时间
- 15 小时
- 注册时间
- 2019-11-11
- 最后登录
- 2019-12-13
|
MT4的版本有二个,一个是SuperLadder,代码是
#property indicator_chart_window
#property indicator_buffers 3
enum ChineseBoolean
{
A=0, // 开
B=1, // 关
};
//+------------------------------------------------------------------+
input ChineseBoolean 窗口提示 = B;
input ChineseBoolean 声音提示 = B;
input ChineseBoolean 电邮通知 = B;
input ChineseBoolean 手机MT4通知 = B;
input color 上涨颜色 = Blue;
input color 下跌颜色 = Red;
input color 阶梯颜色 = Aqua;
input double ATR_Factor = 1.5;
input int MA_Period = 20;
int ATR = 14;
string IndicatorName = "SuperLadder";
//+------------------------------------------------------------------+
double bufferLadder[], bufferUp[], bufferDn[];
double bufferDirection[];
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(4);
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,3,阶梯颜色);
SetIndexBuffer(0, bufferLadder);
SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,2,上涨颜色);
SetIndexBuffer(1, bufferUp);
SetIndexStyle(2, DRAW_LINE,STYLE_SOLID,2,下跌颜色);
SetIndexBuffer(2, bufferDn);
SetIndexBuffer(3, bufferDirection);
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
datetime dtLastTime = 0;
int start()
{
double thisCCI;
double dAtr=0.0;
int limit, shift;
int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for (shift=limit-1; shift >= 0; shift--)
{
thisCCI = iCCI(NULL, 0, MA_Period, PRICE_TYPICAL, shift);
dAtr = iATR(NULL, 0, ATR, shift);
bufferDirection[shift]=0.0;
if (thisCCI >= 0)
{
bufferLadder[shift] = Low[shift] - dAtr * ATR_Factor;
if (bufferLadder[shift] < bufferLadder[shift + 1])
bufferLadder[shift] = bufferLadder[shift + 1];
}
else
{
bufferLadder[shift] = High[shift] + dAtr * ATR_Factor;
if (bufferLadder[shift] > bufferLadder[shift + 1])
bufferLadder[shift] = bufferLadder[shift + 1];
}
if (bufferLadder[shift]>bufferLadder[shift+1]) bufferDirection[shift] = 1.0;
if (bufferLadder[shift]<bufferLadder[shift+1]) bufferDirection[shift] = -1.0;
if (bufferLadder[shift]==bufferLadder[shift+1]) bufferDirection[shift] = bufferDirection[shift+1];
if (bufferDirection[shift]>0.0) bufferUp[shift]=bufferLadder[shift]-Point*2;
if (bufferDirection[shift]<0.0) bufferDn[shift]=bufferLadder[shift]+Point*2;
}
/// Alert Process
if (bufferDirection[1]!=bufferDirection[2] && dtLastTime!=Time[0])
{
dtLastTime = Time[0];
double dLastDayClose = iClose(Symbol(),PERIOD_D1,1);
double dUpDnPercent = NormalizeDouble( (Close[0] - dLastDayClose)/dLastDayClose * 100.0, 2);
string strAlertMessage;
if (bufferDirection[1] > 0.0)
{
strAlertMessage = StringConcatenate(IndicatorName," Alert: ",Symbol(),"_",PeriodToString(Period())," UP");
if (窗口提示==A)
Alert(strAlertMessage);
if (声音提示==A)
PlaySound("alert.wav");
if (电邮通知==A)
SendMail(strAlertMessage,
"Current Price "+DoubleToStr(Close[0],Digits)+
"\nTime: " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)
+ "\nLast Day Close: " + DoubleToStr(dLastDayClose,Digits)
+ "\nChange: " + DoubleToStr(dUpDnPercent,2) + "%");
if (手机MT4通知==A)
SendNotification(strAlertMessage);
}
if (bufferDirection[1] < 0.0)
{
strAlertMessage = StringConcatenate(IndicatorName," Alert: ",Symbol(),"_",PeriodToString(Period())," DOWN");
if (窗口提示==A)
Alert(strAlertMessage);
if (声音提示==A)
PlaySound("alert.wav");
if (电邮通知==A)
SendMail(strAlertMessage,
"Current Price "+DoubleToStr(Close[0],Digits)+
"\nTime: " + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS)
+ "\nLast Day Close: " + DoubleToStr(dLastDayClose,Digits)
+ "\nChange: " + DoubleToStr(dUpDnPercent,2) + "%");
if (手机MT4通知==A)
SendNotification(strAlertMessage);
}
}
return(0);
}
string PeriodToString (int imin)
{
string strprd;
switch (imin)
{
case (1):
strprd="M1";
break;
case (2):
strprd="M2";
break;
case (3):
strprd="M3";
break;
case (5):
strprd="M5";
break;
case (15):
strprd="M15";
break;
case (30):
strprd="M30";
break;
case (60):
strprd="H1";
break;
case (60*4):
strprd="H4";
break;
case (60*24):
strprd="D1";
break;
case (60*24*7):
strprd="W1";
break;
}
return (strprd);
} |
|