你这个再增加一个变量应该就可以了
//+------------------------------------------------------------------+
//| ff_EA.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
input double line_up=0.0012;
input double line_down=-0.0012;
input int MA1=60;
input int BOLL_period=25;
input int BOLL_dev=2;
input int InpFastEMA=12; // Fast EMA Period
input int InpSlowEMA=26; // Slow EMA Period
input int InpSignalSMA=9; // Signal SMA Period
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
bool mark1; bool mark2; bool mark3; bool mark4,markup,markdown;
double uper,downer;
datetime marktime,marktime1;
bool markinit;
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//iCustom()
double coral=iCustom(NULL,0,"THV3 Coral",0,1);
double ha_c=iCustom(NULL,0,"THV3 HA",3,1);
double week=iCustom(NULL,0,"THV Visual_BT_Pivots V1.3",0,0);
double ma=iMA(Symbol(),0,MA1,0,MODE_SMA,PRICE_CLOSE,1);
double trix1=iCustom(NULL,0,"THV3 Trix v4.01 Div",0,1);
double trix2=iCustom(NULL,0,"THV3 Trix v4.01 Div",2,1);
double trix3=iCustom(NULL,0,"THV3 Trix v4.01 Div",1,1);
double trix4=iCustom(NULL,0,"THV3 Trix v4.01 Div",3,1);
double ww[7];
ww[0]=ObjectGetDouble(0,"PivotLine",OBJPROP_PRICE1,0);
ww[1]=ObjectGetDouble(0,"R1Line",OBJPROP_PRICE1,0);
ww[2]=ObjectGetDouble(0,"R2Line",OBJPROP_PRICE1,0);
ww[3]=ObjectGetDouble(0,"R3Line",OBJPROP_PRICE1,0);
ww[4]=ObjectGetDouble(0,"S1Line",OBJPROP_PRICE1,0);
ww[5]=ObjectGetDouble(0,"S2Line",OBJPROP_PRICE1,0);
ww[6]=ObjectGetDouble(0,"S3Line",OBJPROP_PRICE1,0);
double tempup=uper;
double tempdown=downer;
double minabs1=999;
double minabs2=999;
for(int i=0;iAsk && minabs1>=ww-Ask)
{
minabs1=ww-Ask;
uper=ww;
}
if(ww[B]=Bid-ww)
{
minabs2=Bid-ww;
downer=ww;
}
}
if(tempup!=uper && tempup>0) markup=false;
if(tempdown!=downer && tempdown>0) markdown=false;
if(markup==false && Ask>uper-0.1*(uper-downer) && CurTime()-marktime>7200)
{
Alert("触上线: ", Ask, " 预警时间 :", TimeToString(CurTime()));
SendMail("触上线","价格: "+ DoubleToString(Ask,Digits)+ " 预警时间 :"+TimeToString(CurTime()));
markup=true;
marktime=CurTime();
}
if(markdown==false && Bid7200)
{
Alert("触下线: ", Bid, " 预警时间 :", TimeToString(CurTime()));
SendMail("触下线","价格: "+ DoubleToString(Bid,Digits)+ " 预警时间 :"+TimeToString(CurTime()));
markdown=true;
marktime=CurTime();
}
double macd1=iMACD(NULL,0,InpFastEMA,InpSlowEMA,InpSignalSMA,PRICE_CLOSE,MODE_MAIN,0);
double boolline=iBands(NULL,0,BOLL_period,BOLL_dev,0,PRICE_CLOSE,MODE_SMA,0);
//THV3 Coral
//THV3 HA
//THV3 Trix v4.01 Div
double xxx=0,yyy=0;
if(trix20) xxx=MathAbs(trix2-line_up);
if(trix40) yyy=MathAbs(trix4-line_up);
bool buytrend=false;
if(ha_c>coral && ha_c>ma && trix1-1 && trix2-1 && xxx>0 && xxx0) buytrend=true;
bool selltrend=false;
if(ha_c-1 && trix4-1 && yyy>0 && yyy60)
{
Alert("买开价格: ", Ask, " 预警时间 :", TimeToString(CurTime()));
SendMail("买开预警","买开价格: "+ DoubleToString(Ask,Digits)+ " 预警时间 :"+TimeToString(CurTime()));
mark1=true;mark3=false;
marktime1=CurTime();
}
if(selltrend==true && mark2==false && CurTime()-marktime1>60)
{
Alert("卖开价格: ", Bid, " 预警时间 :", TimeToString(CurTime()));
SendMail("卖开价格","卖开价格: "+ DoubleToString(Bid,Digits)+ " 预警时间 :"+ TimeToString(CurTime()));
mark2=true;mark4=false;
marktime1=CurTime();
}
if( (ha_cboolline || ha_c>coral || ha_c>ma)) sellclose=true;
if(buyclose==true && mark3==false && CurTime()-marktime1>60)
{
Alert("买平价格: ", Bid, " 预警时间 :", TimeToString(CurTime()));
SendMail("买平价格: ","买平价格: "+ DoubleToString(Bid, Digits)+" 预警时间 :"+ TimeToString(CurTime()));
mark3=true;
buytrend=false; mark1=false;
marktime1=CurTime();
}
if(sellclose==true && mark4==false && CurTime()-marktime1>60)
{
Alert("卖平价格: ", Ask, " 预警时间 :", TimeToString(CurTime()));
SendMail("卖平价格: ","卖平价格: "+ DoubleToString(Ask,Digits)+ " 预警时间 :"+TimeToString(CurTime()));
mark4=true;
selltrend=false; mark2=false;
marktime1=CurTime();
}
string trend1=""; string trend2="";
if(buytrend==true) trend1="买单开仓状态";
if(selltrend==true) trend2="卖单开仓状态";
Comment(trend1+trend2+"\n"+
DoubleToString(ha_c,Digits) + " " +DoubleToStr(boolline,Digits));
}
//+------------------------------------------------------------------+
应该就是因为紫色和蓝色的time都是一个time,所以影响到红色的阻力位预警了
|