Trailing Stop Error: Invalid Stops

 

Hi guys, I've been having this error the entire day while trying to figure out a way to place trailing stops to my positions.  I'm getting an "invalid stops" error.  I've read through some of the previous posts about the invalid stops but nothing seems to work. Appreciate if anyone can kindly look at my code below and try to decipher where the problem is coming from:

if(Buy_opened==true)
    {
      if(SymbolInfoDouble(_Symbol,SYMBOL_ASK)-TtrailingStop*_Point >= myposition.StopLoss())
      { double newSLpoint=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK)+TrailingStop*_Point,_Digits);
        double newTPpoint=NormalizeDouble(myposition.TakeProfit(),_Digits);
        if(mytrade.PositionModify(_Symbol,newSLpoint,newTPpoint))  
        {
          //--- Request successfully completed    
         Alert("An opened position has been successfully modified!!");
         return;
        }
      else
        {
         Alert("The position modify request could not be completed - error: ",mytrade.ResultRetcodeDescription());
         return;
        }
      }
    }
    if(Sell_opened==true)
    {
      if(SymbolInfoDouble(_Symbol,SYMBOL_BID)+TrailingStop*_Point <= myposition.StopLoss())
      { double newSLpoint=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK)-TrailingStop*_Point,_Digits);
        double newTPpoint=NormalizeDouble(myposition.TakeProfit(),_Digits);
        
        if(mytrade.PositionModify(_Symbol,newSLpoint,newTPpoint))  
        {
          //--- Request successfully completed    
         Alert("An opened position has been successfully modified!!");
         return;
        }
      else
        {
         Alert("The position modify request could not be completed - error: ",mytrade.ResultRetcodeDescription());
         return;
        }
      }
    }
 

Here's a screenshot of the journal:

Invalid Stops Error

the stoploss and takeprofit modification seems to be correct... 

 

 
Hi guys, any suggestions?  
 
polymath:
Hi guys, any suggestions?  
Just change + to - in Buy and - to + in Sell order and verify.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Trade Orders in DOM - Documentation on MQL5
 
Hi askrsk, thanks for pointing out that very clumsy mistake of mine, hehe...Thanks a lot!
Reason: