修改止损价为入场价
[C] 纯文本查看 复制代码extern double 下单量=0.1;
extern double 止损=30;
extern double 止盈=90;
extern double 滑点=3;
extern doubleTrailingStop=20; //盈利的点数,你这里是 20
int start()
{ int i;int ticket1;
//+---------- 自定义做多条件 --------------------------------------------------------+
if( OrdersT otal()==0
&& Close[1]-Open[1]>1*Point
//+------------------------------------------------------------------+
)
{ticket1=OrderSend(Symbol(),OP_BUY, 下单量 ,Ask, 滑 点 ,Ask- 止损
*Point,Ask+止盈*Point,"",20101018,0,0);
}
if( OrdersT otal()==0
&& Open[1]-Close[1]>1*Point
//+------------------------------------------------------------------+
){ticket1=OrderSend(Symbol(),OP_SELL, 下单量 ,Bid, 滑 点 ,Bid+ 止损
*Point,Bid-止盈*Point,"",20101018,0,0);
}
//+---------以下为当有利润 20 点时,调整止损位到入场价-----------------+
int total=OrdersT otal();
for(int cnt=0;cnt0)
{
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderT akeProfit(),0,Green);
return(0);
}
}
}
}
else // go to short position
{
// should it be closed?
if(TrailingStop>0)
{
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderT akeProfit(),0,Red);
return(0);
}
}
}
}
}
}
//+------------------------------------------------------------------+
return(0);}
|