下载MetaTrader 5
要添加评论,请登录注册
手边没有电脑?用移动电话与好友沟通吧!
lijun
10
lijun 2010.09.03 14:14 

void start() {

int i,buys=0,sells=0,life=0;

double lots, h, l;

bool close;

if(Bars<cciPeriod || !IsTradeAllowed()) return;

for(i=OrdersTotal()-1;i>=0;i--) {

if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;

if (OrderMagicNumber()!=magic) continue;

if (OrderSymbol()!=Symbol()) continue;

life=(TimeCurrent()-OrderOpenTime())/60;

if (Live>0) close=life>Live; else close=false;

if (!close && FridayClose>0) close=DayOfWeek()==5 && Hour()>FridayClose;

if (OrderType()==OP_BUY) {

if (!close && Reduce>0) close=Bid>OrderTakeProfit()-pip*(life/Reduce)*Point;

if (close) {

close=OrderClose(OrderTicket(),OrderLots(),Bid,slippage,Aqua);

RefreshRates();

if (close) {life=0;continue;}

}

buys++;

if (TrailingStop>0)

if (Bid-OrderOpenPrice() > Point*TrailingStop)

if (NormalizeDouble(OrderStopLoss() - Bid+Point*TrailingStop,dig)<0)

OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Bid-Point*TrailingStop,Digits), OrderTakeProfit(), 0, Blue);

} else {

if (!close && Reduce>0) close=Ask<OrderTakeProfit()+pip*(life/Reduce)*Point;

if (close) {

close=OrderClose(OrderTicket(),OrderLots(),Ask,slippage,Pink);

RefreshRates();

if (close) {life=0;continue;}

}

sells++;

if (TrailingStop>0)

if (OrderOpenPrice()-Ask > Point * TrailingStop)

if (OrderStopLoss()==0 || NormalizeDouble(OrderStopLoss()- Ask-Point*TrailingStop,dig)>0)

OrderModify(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask+Point*TrailingStop,Digits), OrderTakeProfit(), 0, Red);

}

}

if (MathAbs(buys-sells)>=MaxPos) return;

if (DayOfWeek()==5) return;

if (Interval>0 && life>Interval) return;

if (spreadlimit>0 && Ask-Bid>spreadlimit) return;

if (tim!=Time[0]) { //红色部分应该为下单条件,但是改了就不下单了

cci=iCCI(0,0,cciPeriod,PRICE_MEDIAN,1);

if (cciLimit>0)

………………

else

vol0u=0;

vol0d=vol0u;

}

if (ccib) {

if(low4>low4s && low1>low1s && low30>low30s && Ask >High[1] && vol0u>vol1u && vol1u>0 && High[2]>High[1] && High[3]>High[2]) {

lots=UseLots();

if (lots==0) return(0);

i=OrderSend(Symbol(),OP_BUY,UseLots(),Ask,slippage,Ask-StopLoss*Point,Ask+TakeProfit*Point,EA,magic,0,Blue);

}

} else

if(high4<high4s && high1<high1s && high30<high30s && Ask <Low[1] && vol0d>vol1d && vol1d>0 && Low[2]<Low[1] && Low[3]<Low[2] && ((cciLimit>0 && cci<0 && cci>-cciLimit) || (cciLimit<0 && cci<cciLimit))) {

lots=UseLots();

if (lots==0) return(0);

i=OrderSend(Symbol(),OP_SELL,UseLots(),Bid,slippage,Bid+StopLoss*Point,Bid-TakeProfit*Point,EA,magic,0,Red);

}

return(0);

}

附加的文件:
WANGGUANG
81
WANGGUANG 2010.09.04 06:30  

if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}就可以了

lijun
10
lijun 2010.09.04 06:42  
CFAACCP:

if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red);
return(0);
}
}
}
}就可以了

谢谢,我试一下,这个程序很不错,只是下单太少,但是移动止损做得不错,我想用在我的其他EA上。
/
要添加评论,请登录注册