请高手修改保平止损和追踪止损EA代码

 
原本要求当开盘价与现价点值达到SlipStop1(较小值)与SlipStop(较大值)之间时,止损调到开仓价位,实现保平。当开盘价与现价点值达到SlipStop(较大值)时能实现追踪止损。期望能实现保平止损

加追踪止损。
但代码实际运行结果却表明,开盘价与现价点值达到SlipStop1(较小值)与SlipStop(较大值)之间时,止损调到开仓价位,实现保平。当开盘价与现价点值达到SlipStop(较大值)时能没能实现追踪止损

,要开盘价与现价点值达到SlipStop1(较小值)与SlipStop(较大值)之和时才能实现追踪止损。甚为不解,请高手看看代码哪里出问题了。

代码如下:

if(OrderType()==OP_BUY){
if(Bid-OrderOpenPrice()>=Point*SlipStop1 && Bid-OrderOpenPrice()<Point*SlipStop)
{
if(OrderStopLoss()<Bid-Point*SlipStop1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
return(0);
}
}
if(Bid-OrderOpenPrice()>=Point*SlipStop )
{
if(OrderStopLoss()<Bid-Point*SlipStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-oneSlipStop,OrderTakeProfit(),0,Blue);
return(0);
}
}

}

if(OrderType()==OP_SELL){
if(OrderOpenPrice()-Bid>=Point*SlipStop1 && OrderOpenPrice()-Bid<Point*SlipStop)
{
if(OrderStopLoss()>Bid+Point*SlipStop1)
{
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Blue);
return(0);
}
}
if(OrderOpenPrice()-Bid>=Point*SlipStop )
{
if(OrderStopLoss()>Bid+Point*SlipStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid+SlipStop,OrderTakeProfit(),0,Blue);
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()) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置
{
if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Green);
}
}
}
else if (OrderType() == OP_SELL)
{
if ((OrderOpenPrice() - Ask) > (TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT))) //开仓价格 当前止损和当前价格比较判断是否要修改跟踪止赢设置

{
if ((OrderStopLoss()) > (Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)))
{
bs = OrderModify(OrderTicket(), OrderOpenPrice(),
Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(),0, Tan);
}
}
}
}
}

https://www.mql5.com/zh/articles/1484

 
thx~