Problem with PositionModify

 
I have a problem with a function that should set SL to 1 pip over entry price (buy mt5).
In backtests it works perfect but in live trading sometimes not at all.
That what it looks like in the code. 

// newsl
         double nsl=NormalizeDouble(op+10*Point(),Digits()); 
    

           if(...)
            
                     {  
           
              if (!m_trade.PositionModify(_Symbol,nsl,m_position.TakeProfit())) Print("ERROR PositionModify=false, ResultRetcode=",m_trade.ResultRetcode());
               else Print("PositionModify=true, ResultRetcode=",m_trade.ResultRetcode());
               Print("mod bu pos new sl=",m_symbol.NormalizePrice(nsl));
               
                     }


Bid was 100 and more points over entry and with every tick over 5 minutes I got the same message and the SL wasn't changed:

ERROR PositionModify=false, ResultRetcode=10009
 
10009 means TRADE_RETCODE_DONE Request completed
 
So everything should be ok. Print shows the correct value for the new SL. 

 In the Journal is nothing.

Any idea what's the problem?
 
Heiko Kendziorra:
I have a problem with a function that should set SL to 1 pip over entry price (buy mt5).
In backtests it works perfect but in live trading sometimes not at all.
That what it looks like in the code. 



Bid was 100 and more points over entry and with every tick over 5 minutes I got the same message and the SL wasn't changed:

ERROR PositionModify=false, ResultRetcode=10009
 
10009 means TRADE_RETCODE_DONE Request completed
 
So everything should be ok. Print shows the correct value for the new SL. 

 In the Journal is nothing.

Any idea what's the problem?

Hi, Some brokers have a minimum stop distance that prevent your EA to modify your stop. Use this to find your minimum stop distance :

int stoplevel = (int) SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);

if (stoplevel!= 0)

   {

   PrintFormat("The minimum stop level is :" + stoplevel);

   }

 
Benbyaanda Silvere Henri Sedric Kabore #:

Hi, Some brokers have a minimum stop distance that prevent your EA to modify your stop. Use this to find your minimum stop distance :

int stoplevel = (int) SymbolInfoInteger(_Symbol,SYMBOL_TRADE_STOPS_LEVEL);

if (stoplevel!= 0)

   {

   PrintFormat("The minimum stop level is :" + stoplevel);

   }

Of course stoplevel and freeze are regarded in the code. I wrote above that Bid was 100 Points over entry price.

I finally set SL by hand to 60 Points profit - while the function could not even set 10 Points profit.

And in the backtest next day with the same broker on the same account SL was set as it should. 

But thanks anyway.