# 怎样实现定单的移动止损trailingstop ?请高 手指点下，谢谢！

10

void start() {

double lots, h, l;

bool close;

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

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 (!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;}

}

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) {

RefreshRates();

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

}

sells++;

if (TrailingStop>0)

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

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

}

}

if (DayOfWeek()==5) return;

if (Interval>0 && life>Interval) 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);

}

} 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);

}

81

if(TrailingStop>0)
{
{
{
return(0);
}
}
}
}就可以了

10

CFAACCP:

if(TrailingStop>0)
{