麻烦能具体点吗?怎么改呀?新手有些地方不是很懂
源码如下
for(i=0; i<=OrdersTotal()-1; i++)
{
result=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
buys++;
LastBuyPrice=OrderOpenPrice();
tol=tol+OrderLots();
top=top+OrderLots()*OrderOpenPrice();
if(SLp==0 && SL>0) SLp=OrderOpenPrice()-SL*db*Point;
}
if(OrderType()==OP_SELL)
{
sells++;
LastSellPrice=OrderOpenPrice();
tol=tol+OrderLots();
top=top+OrderLots()*OrderOpenPrice();
if(SLp==0 && SL>0) SLp=OrderOpenPrice()+SL*db*Point;
}
}
}
//---------------------------------------------------------------------------------------------
//----修改订单
for(i=0; i<=OrdersTotal()-1; i++)
{
result=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()!=Symbol() || OrderMagicNumber()!=MagicNumber) continue;
if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
{
if(OrderType()==OP_BUY)
{
if(SLp>0 && DoubleToStr(OrderStopLoss(),Digits)!=DoubleToStr(SLp,Digits))
{
result=OrderModify(OrderTicket(),OrderOpenPrice(),SLp,OrderTakeProfit(),0,Green);
if(result<0) Print("BUY 止损修改出错"+DoubleToStr(OrderStopLoss(),Digits)+"-->"+DoubleToStr(SLp,Digits));
}
}
if(OrderType()==OP_SELL)
{
if(SLp>0 && DoubleToStr(OrderStopLoss(),Digits)!=DoubleToStr(SLp,Digits))
{
result=OrderModify(OrderTicket(),OrderOpenPrice(),SLp,OrderTakeProfit(),0,Red);
if(result<0) Print("SELL 止损修改出错"+DoubleToStr(OrderStopLoss(),Digits)+"-->"+DoubleToStr(SLp,Digits));
}
}
}
} |