extern int 均价保本启动点数=300;
extern int 均价保本点数=50;
===========================================
if(是否开启均价止损==true)
{
on_off=false;
move_sl();
for(i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==识别码3)
{
if(OrderType()==OP_BUY)
{
if(OrderStopLoss()==0 && 最后的多单价格>Ask-均价止损点数*Point)
{
double slp=Ask-均价止损点数*Point;
if(!OrderModify(OrderTicket(),OrderOpenPrice(),slp,OrderTakeProfit(),0))
Print(" 修改多均价止损");
}
if(NormalizeDouble(OrderTakeProfit()-btpp,8)!=0)
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),bslpp,btpp,0))
Print(" 修改多均价止盈成功");
}
if(OrderStopLoss()<最后的多单价格 && (Ask-多第一单开单价格>均价保本点数*Point) && 均价保本点数>0 && (OrderTakeProfit()-(均价止盈点数-均价保本启动点数)*Point)<Ask)
{
slp=多第一单开单价格+均价保本点数*Point;
if(!OrderModify(OrderTicket(),OrderOpenPrice(),slp,OrderTakeProfit(),0))
Print(" 修改多均价保本止损成功");
}
}
if(OrderType()==OP_SELL)
{
if(OrderStopLoss()==0 && 最后的空单价格<Bid+均价止损点数*Point)
{
slp=Bid+均价止损点数*Point;
if(!OrderModify(OrderTicket(),OrderOpenPrice(),slp,OrderTakeProfit(),0))
Print(" 修改空均价止损成功");
}
if(NormalizeDouble(OrderTakeProfit()-stpp,8)!=0)
{
if(!OrderModify(OrderTicket(),OrderOpenPrice(),sslpp,stpp,0))
Print(" 修改空均价止盈成功");
}
if(OrderStopLoss()> 最后的空单价格 && 空第一单开单价格-Bid>均价保本点数*Point && 均价保本点数>0 && (OrderTakeProfit()+(均价止盈点数-均价保本启动点数)*Point)>Bid)
{
slp=空第一单开单价格-均价保本点数*Point;
if(!OrderModify(OrderTicket(),OrderOpenPrice(),slp,OrderTakeProfit(),0))
Print(" 修改空均价保本止损成功");
}
}
}
}
}
}
|