跪求高手修改EA

 

我的策略要求是

当日做单以前一日的固定时间段内的高位突破做多。

当日做单以前一日的固定时间段内的低位跌破做空。

形成循环。
止盈参数可调。不设置止损。当30分钟图中的3线RSI聚合(3线RSI参数为7.14.21),无论盈亏全部离场。前一日的固定时间段范围参数可调。
每天最多允许一单多单和一单空单。

做单仓位参数可调。使用货币:黄金

现在写出的不能开单,请帮忙修改,谢谢,

//+------------------------------------------------------------------+
//| point.mq4 |
//| Copyright ?2011, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2011, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+.
extern string 开始时间 = "2011.11.06.23:00";
extern string 结束时间 = "2011.11.07.00:50";
extern string 选择方向 ="想突破做多请在楼下填入 1 ,做空填入 2 ,双向填入 3 。";
extern int 方向 = 3 ;
extern int RSI参数1 = 7 ;
extern int RSI参数2 = 14 ;
extern int RSI参数3 = 21 ;
extern double RSI聚合参数 = 3 ;
extern int 单方向下单次数 = 1 ;
extern double 手数 = 0.1 ;
extern double 止盈点数 = 1000 ;
extern double 止损点数 = 1000 ;
extern int magic = 5201314 ;
extern int 每日多单最多做单量 = 1;
extern int 每日空单最多做单量 = 1;
double RSIBuffer1[];
double RSIBuffer2[];
double RSIBuffer3[];
double price_high=0,price_low=10000;
string 开启ea时间;
double RSIBufferMA;



int init()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();

//----
//--------------计算区间最高价与最低价部分

int i,j,k;
if(Time[0]>=StrToTime(开始时间)&&Time[0]<=StrToTime(结束时间))
{
for(i=0;(Time[i]>=StrToTime(开始时间)&&Time[i]<=StrToTime(结束时间));i++)
{
if(price_high<High[0])
price_high=High[0];
if(price_low>Low[0])
price_low=Low[0];
}
}
if((Time[0]>StrToTime(结束时间))&&(price_high==0)&&(price_low==10000))
{
for(i=0;i>=0;i++)
{
if(Time[i]>StrToTime(结束时间))
continue;
else
break;
}
for(k=0;k>=0;k++)
{
if(Time[k]>StrToTime(开始时间))
continue;
else
break;
}
for(j=i;(j>=i&&j<=k);j++)
{
if(price_high<High[j])
price_high=High[j];
if(price_low>Low[j])
price_low=Low[j];
}
}

//-----------------------开仓部分
//-----------------------开多单部分

if (Bid>price_high)
if ((方向==1)||(方向==3))
if (每日多单最多做单量>0)
{
OrderSend(Symbol(), OP_BUY,手数,0, 100,0,0,"我们必胜!",magic, 0,CLR_NONE);
每日多单最多做单量--;
}
//-----------------------开空单部分
if (Ask<price_low)
{
if ((方向==2)||(方向==3))
if (每日空单最多做单量>0)
{
OrderSend(Symbol(),OP_SELL,手数,0, 100,0,0,"我们必胜!",magic, 0,CLR_NONE);
每日空单最多做单量--;
}
}
//------------------------------------------------------增加止盈部分
//----
bool result;
double take_profit,point;
int cmd,total,error;
string comment;
//----
total=OrdersTotal();

//----
for(int cnt=0; cnt<total; cnt++)
{
if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES))
{
point=MarketInfo(OrderSymbol(),MODE_POINT);
//------------------ print modified order (it still selected after modify)
if((OrderComment() == "我们必胜!")&&(OrderTakeProfit( )==0 ))
{
cmd=OrderType();
//---- buy or sell orders are considered
if(cmd==OP_BUY || cmd==OP_SELL)
{
while(true)
{
if(cmd==OP_BUY) take_profit = OrderOpenPrice()+止盈点数*point;
else take_profit = OrderOpenPrice()-止盈点数*point;
result=OrderModify(OrderTicket(),0,0,take_profit,CLR_NONE);
if(result!=TRUE) { error=GetLastError(); Print("LastError = ",error); }
else error=0;
if(error==135) RefreshRates();
else break;
}
}
}
}
}
//--------------------------计算rsi指标部分----RSI部分未完成
int rsi_i1,rsi_i2,rsi_i3;
double rel1,negative1,positive1;
double rel2,negative2,positive2;
double rel3,negative3,positive3;
double PosBuffer1[],PosBuffer2[],PosBuffer3[];
double NegBuffer1[],NegBuffer2[],NegBuffer3[];
//---- initial zero
if(counted_bars<1)
for(rsi_i1=1;rsi_i1<=RSI参数1;rsi_i1++) RSIBuffer1[Bars-rsi_i1]=0.0;
//----
rsi_i1=Bars-RSI参数1-1;
if(counted_bars>=RSI参数1) rsi_i1=Bars-counted_bars-1;
while(rsi_i1>=0)
{
double sumn1=0.0,sump1=0.0;
if(rsi_i1==Bars-RSI参数1-1)
{
int rsi_k1=Bars-2;
//---- initial accumulation
while(rsi_k1>=rsi_i1)
{
rel1=Close[rsi_k1]-Close[rsi_k1+1];
if(rel1>0) sump1+=rel1;
else sumn1-=rel1;
rsi_k1--;
}
positive1=sump1/RSI参数1;
negative1=sumn1/RSI参数1;
}
else
{
//---- smoothed moving average
rel1=Close[rsi_i1]-Close[rsi_i1+1];
if(rel1>0) sump1=rel1;
else sumn1=-rel1;
positive1=(PosBuffer1[rsi_i1+1]*(RSI参数1-1)+sump1)/RSI参数1;
negative1=(NegBuffer1[rsi_i1+1]*(RSI参数1-1)+sumn1)/RSI参数1;
}
PosBuffer1[rsi_i1]=positive1;
NegBuffer1[rsi_i1]=negative1;
if(negative1==0.0) RSIBuffer1[rsi_i1]=0.0;
else RSIBuffer1[rsi_i1]=100.0-100.0/(1+positive1/negative1);
rsi_i1--;
}
//------------------------------------------------------------------------------ initial zero
if(counted_bars<1)
for(rsi_i2=1;rsi_i2<=RSI参数2;rsi_i2++) RSIBuffer2[Bars-rsi_i2]=0.0;
//----
rsi_i2=Bars-RSI参数2-1;
if(counted_bars>=RSI参数2) rsi_i2=Bars-counted_bars-1;
while(rsi_i2>=0)
{
double sumn2=0.0,sump2=0.0;
if(rsi_i2==Bars-RSI参数2-1)
{
int rsi_k2=Bars-2;
//---- initial accumulation
while(rsi_k2>=rsi_i2)
{
rel2=Close[rsi_k2]-Close[rsi_k2+1];
if(rel2>0) sump2+=rel1;
else sumn2-=rel1;
rsi_k2--;
}
positive2=sump2/RSI参数2;
negative2=sumn2/RSI参数2;
}
else
{
//---- smoothed moving average
rel2=Close[rsi_i2]-Close[rsi_i2+1];
if(rel2>0) sump2=rel2;
else sumn2=-rel2;
positive2=(PosBuffer2[rsi_i2+1]*(RSI参数2-1)+sump2)/RSI参数2;
negative2=(NegBuffer2[rsi_i2+1]*(RSI参数2-1)+sumn2)/RSI参数2;
}
PosBuffer2[rsi_i2]=positive2;
NegBuffer2[rsi_i2]=negative2;
if(negative2==0.0) RSIBuffer2[rsi_i2]=0.0;
else RSIBuffer2[rsi_i2]=100.0-100.0/(1+positive2/negative2);
rsi_i2--;
}
//------------------------------------------------------------------------- initial zero
if(counted_bars<1)
for(rsi_i3=1;rsi_i3<=RSI参数3;i++) RSIBuffer3[Bars-rsi_i3]=0.0;
//----
rsi_i3=Bars-RSI参数3-1;
if(counted_bars>=RSI参数3) rsi_i3=Bars-counted_bars-1;
while(rsi_i3>=0)
{
double sumn3=0.0,sump3=0.0;
if(rsi_i3==Bars-RSI参数3-1)
{
int rsi_k3=Bars-2;
//---- initial accumulation
while(rsi_k3>=rsi_i3)
{
rel3=Close[rsi_k3]-Close[rsi_k3+1];
if(rel3>0) sump3+=rel3;
else sumn3-=rel3;
rsi_k3--;
}
positive3=sump3/RSI参数3;
negative3=sumn3/RSI参数3;
}
else
{
//---- smoothed moving average
rel3=Close[rsi_i3]-Close[rsi_i3+1];
if(rel3>0) sump3=rel3;
else sumn3=-rel3;
positive3=(PosBuffer3[rsi_i3+1]*(RSI参数3-1)+sump3)/RSI参数3;
negative3=(NegBuffer3[rsi_i3+1]*(RSI参数3-1)+sumn3)/RSI参数3;
}
PosBuffer3[rsi_i3]=positive3;
NegBuffer3[rsi_i3]=negative3;
if(negative3==0.0) RSIBuffer3[rsi_i3]=0.0;
else RSIBuffer3[rsi_i3]=100.0-100.0/(1+positive3/negative3);
rsi_i3--;
}
//-----------------------RSI聚合平仓部分------
RSIBufferMA = (RSIBuffer1[0]+RSIBuffer2[0]+RSIBuffer3[0])/3;
if((MathAbs(RSIBuffer1[0]-RSIBufferMA)<=RSI聚合参数)&&MathAbs((RSIBuffer2[0]-RSIBufferMA)<=RSI聚合参数)&&(MathAbs (RSIBuffer3[0]-RSIBufferMA)<=RSI聚合参数))
for (i=0;i<total;i++)
{
OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES) ;
if (magic==OrderMagicNumber())
OrderClose(i,手数,0,100,CLR_NONE);
}
return(0);

}
//+------------------------------------------------------------------+

 

ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-25*Point,Ask+25*Point,"My order #2",16384,0,Green);


你的OrderSend中 0, 100,0,0 都是什么, 你能用0做价格来买卖???

OrderSend(Symbol(), OP_BUY,手数,0, 100,0,0,"我们必胜!",magic, 0,CLR_NONE);
OrderSend(Symbol(),OP_SELL,手数,0, 100,0,0,"我们必胜!",magic, 0,CLR_NONE);

 
我是写ea的,找我吧 qq: 357435993
原因: