diff --git a/MQL4/Experts/Trailing Stop on Profit.mq4 b/MQL4/Experts/Trailing Stop on Profit.mq4 index 3924e8d..44ed5ba 100644 --- a/MQL4/Experts/Trailing Stop on Profit.mq4 +++ b/MQL4/Experts/Trailing Stop on Profit.mq4 @@ -105,7 +105,7 @@ void TrailingStop() if (OrderType() == OP_BUY) { - if (NormalizeDouble(Bid - OrderOpenPrice(), _Digits) > NormalizeDouble(P, _Digits)) + if (NormalizeDouble(Bid - OrderOpenPrice(), _Digits) >= NormalizeDouble(P, _Digits)) { if ((TSTP != 0) && (OrderStopLoss() < NormalizeDouble(Bid - TSTP, _Digits))) { @@ -115,9 +115,9 @@ void TrailingStop() } else if (OrderType() == OP_SELL) { - if ((TSTP != 0) && (NormalizeDouble(OrderOpenPrice() - Ask, _Digits) > TSTP)) + if (NormalizeDouble(OrderOpenPrice() - Ask, _Digits) >= NormalizeDouble(P, _Digits)) { - if ((OrderStopLoss() > NormalizeDouble(Ask + TSTP, _Digits)) || (OrderStopLoss() == 0)) + if ((TSTP != 0) && ((OrderStopLoss() > NormalizeDouble(Ask + TSTP, _Digits)) || (OrderStopLoss() == 0))) { ModifyOrder(OrderTicket(), OrderOpenPrice(), NormalizeDouble(Ask + TSTP, _Digits), OrderTakeProfit()); } diff --git a/MQL5/Experts/Trailing Stop on Profit.mq5 b/MQL5/Experts/Trailing Stop on Profit.mq5 index 69e1ded..2ac8156 100644 --- a/MQL5/Experts/Trailing Stop on Profit.mq5 +++ b/MQL5/Experts/Trailing Stop on Profit.mq5 @@ -123,7 +123,7 @@ void TrailingStop() if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_BUY) { - if (NormalizeDouble(Bid - OpenPrice, _Digits) > NormalizeDouble(P, _Digits)) + if (NormalizeDouble(Bid - OpenPrice, _Digits) >= NormalizeDouble(P, _Digits)) { if ((TSTP != 0) && (StopLoss < NormalizeDouble(Bid - TSTP, _Digits))) { @@ -133,9 +133,9 @@ void TrailingStop() } else if (PositionGetInteger(POSITION_TYPE) == POSITION_TYPE_SELL) { - if ((TSTP != 0) && (NormalizeDouble(OpenPrice - Ask, _Digits) > TSTP)) + if (NormalizeDouble(OpenPrice - Ask, _Digits) >= NormalizeDouble(P, _Digits)) { - if ((StopLoss > NormalizeDouble(Ask + TSTP, _Digits)) || (StopLoss == 0)) + if ((TSTP != 0) && ((StopLoss > NormalizeDouble(Ask + TSTP, _Digits)) || (StopLoss == 0))) { ModifyPosition(ticket, OpenPrice, NormalizeDouble(Ask + TSTP, _Digits), TakeProfit); }