
多看看例子就行了。
如果修改不成功可以设置输出错误代码。
int modifyOrderSend(){
inttotal=OrdersTotal()
if(total <1) return (0)
double sl=0,pl=0
for(int i=0i<totali++)
{
OrderSelect(i, SELECT_BY_POS, MODE_TRADES)
if(OrderSymbol()==Symbol()) // check for symbol
{
if(OrderType()==OP_SELL) // long position is opened
{
sl= Bid+*Point*50
pl= Bid-*Point*50
if(OrderStopLoss()==0 || OrderStopLoss()>sl)
{
int o =OrderModify(OrderTicket(),OrderOpenPrice(),sl,pl,0,Green)
if(o<1)
{
Print("OrderModify sell error->",GetLastError())
return(0)
}
}
}
}
}
}
下面这段代码你应该看得懂,可以实现的功能是将所有同向订单的止损止盈设置为最后成交的那个单子的止损止盈if(use_sl_and_tp &&total()>1)
{
double s_l, t_p
for(i=0i<OrdersTotal()i++)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES)
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue
type=OrderType()
s_l=OrderStopLoss()
t_p=OrderTakeProfit()
}
for(i=OrdersTotal()-1i>=0i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_TRADES)
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=magic || OrderType()>1) continue
if(OrderType()==type)
{
if(OrderStopLoss()!=s_l || OrderTakeProfit()!=t_p)
{
OrderModify(OrderTicket(),OrderOpenPrice(),s_l,t_p,0,CLR_NONE)
}
}
}
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)