error Trailing Stop for Mql5

To add comments, please log in or register
Sabil Yudifera
30782
Sabil Yudifera  

 why this does not work ?

 

#include <Trade\Trade.mqh>

#include <Trade\OrderInfo.mqh>

CTrade a;

COrderInfo b;

int modif_stop_loss()
{
   int lockdown_lock = 30;
   int LockDown = 5;
   bool close=false;
   for(int TradeNumber = 0; TradeNumber < PositionsTotal(); TradeNumber++)
   {
      if(b.SelectByIndex(TradeNumber)==true)
      {
            if(StringCompare(b.Symbol(),_Symbol)==0)
            {
                  if(b.OrderType()==ORDER_TYPE_BUY&&(SymbolInfoDouble(_Symbol,SYMBOL_BID)-b.StopLoss()>_Point*(LockDown+lockdown_lock)))
                  {
                     close = a.OrderModify(b.Ticket(),SymbolInfoDouble(_Symbol,SYMBOL_BID),NormalizeDouble(b.StopLoss()+_Point*LockDown,_Digits),b.TakeProfit(),b.TypeTime(),0,0);
                  }
                  if(b.OrderType()==ORDER_TYPE_SELL&&(b.StopLoss()-SymbolInfoDouble(_Symbol,SYMBOL_ASK)>_Point*(LockDown+lockdown_lock)))
                  {
                     close = a.OrderModify(b.Ticket(),SymbolInfoDouble(_Symbol,SYMBOL_ASK),NormalizeDouble(b.StopLoss()-_Point*LockDown,_Digits),b.TakeProfit(),b.TypeTime(),0,0);
                  }
            }
      }
   }
   return 0;
}
Alain Verleyen
36160
Alain Verleyen  
Sabil Yudifera Daeng Pattah:

 why this does not work ?

 

Why don't you read the documentation ?
To add comments, please log in or register