您需要 登录 才可以下载或查看,没有帐号?注册
函数执行持仓订单的移动止损功能。
extern int Magic = 20080829;
extern color clModify = Silver;
extern int TrailingStart = 30;
extern int TrailingSize = 30;
void TrailPositions()
{
int cnt = OrdersTotal();
for (int i=0; i i++)
{
if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
int type = OrderType();
if (type == OP_BUY)
{
if (Bid-OrderOpenPrice() TrailingStart*Point)
{
if (OrderStopLoss() Bid - (TrailingSize+1)*Point)
{
OrderModify(OrderTicket(),
OrderOpenPrice(),
Bid-TrailingSize*Point,
OrderTakeProfit(), 0, clModify);
}
}
}
if (type == OP_SELL)
{
if (OrderOpenPrice()-Ask TrailingStart*Point)
{
if (OrderStopLoss() Ask + (TrailingSize+1)*Point || OrderStopLoss() == 0)
{
OrderModify(OrderTicket(),
OrderOpenPrice(),
Ask+TrailingSize*Point,
OrderTakeProfit(), 0, clModify);
}
}
}
}
}复制代码
外汇交易有很大的风险性,本站所有资源均来自网络,请选择使用,如若出现亏损,本站不承担任何责任!