Any reason why this Trailing Stop doesn't work?

 

This is the code in the EA but it doesn't seem to work or modify any orders.

Anything wrong with it?

Thanks

//=============== TRAILING STOP ROUTINE

int cnt, total;

total=OrdersTotal();

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if ( (OrderSymbol()==Symbol()) && (OrderMagicNumber()==MagicNumber) && (OrderComment()==GetCommentForOrder()) )

{

if(OrderType() == OP_BUY)

{

if(TrailingStop > 0)

{

if((Bid-OrderOpenPrice()) > (Point*TrailingStop))

{

if((OrderStopLoss()) < (Bid-Point*TrailingStop))

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-(Point*5),OrderTakeProfit(),0,GreenYellow);

return(0);

}

}

}

}

if(OrderType() == OP_SELL)

{

if(TrailingStop > 0)

{

if(OrderOpenPrice()-Ask>Point*TrailingStop)

{

if(OrderStopLoss()>Ask+Point*TrailingStop)

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+(Point*5),OrderTakeProfit(),0,Red);

return(0);

}

}

}

}

}

}

return(ret);

}

 

I guess it doesn't matter. I'm starting to realize that having the trailing stop is causing me to loose some more profitable trades by closing to early.