double 手数=0.1;
int 止损点数=200;
int 止盈点数=400;
int 追踪止损=30;
int magic=888;
//------------------------------------------------------------
int start()
{int SlipPoints=3;
int Ticket;
//----
Ticket=OrderSend(Symbol(),OP_SELL,手数,Bid,SlipPoints,Ask+止损点数*Point,Bid-止盈点数*Point,"1",magic,0);
if(Ticket<0)
{
Alert(Symbol()+" 空单开仓失败");
}
else
{
Alert(Symbol()+" 空【0.1手】开仓成功");
}
//----
return(0);
}
void CTP() //跟踪止赢
{
bool bs = false;
for (int i = 0; i < OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if (OrderType() == OP_BUY)
{
if ((Bid - OrderOpenPrice()) > (追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置
{
if (OrderStopLoss() < Bid - 追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - 追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Green);
}
}
}
else if (OrderType() == OP_SELL)
{
if ((OrderOpenPrice() - Ask) > (追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置
{
if ((OrderStopLoss()) > (Ask + 追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT)))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + 追踪止损 * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Tan);
}
}
}
}
}
|