O tralling Stop do meu robo nao esta funcionando! Alguem poderia indentificar o problema por favor? O codigo esta abaixo

 
P L E A S E   -   D O    N O T    D E L E T E    T H I S   H E A D E R ! ! !
//  D E L E T I N G   T H I S   H E A D E R   I S   C O P Y R I G H T   I N F R I G H M E N T            

// 01110100 01110010 01100001 01100100 01100101 01000000 01100011 01101000 01100101 01100011 01101000 01101111 00101110 01100011 01101111 01101101

//|   _______  __   __  _______  _______  __   __  _______ 
//|  |       ||  | |  ||       ||       ||  | |  ||       |
//|  |       ||  |_|  ||    ___||       ||  |_|  ||   _   |
//|  |       ||       ||   |___ |       ||       ||  | |  |
//|  |      _||       ||    ___||      _||       ||  |_|  |
//|  |     |_ |   _   ||   |___ |     |_ |   _   ||       |
//|  |_______||__| |__||_______||_______||__| |__||_______|
//|

//|     _                         _           / __ \           _                       _                                              
//|    | |_      _ _   __ _    __| |    ___  / / _` |   __    | |_      ___     __    | |_      ___             __      ___    _ __   
//|    |  _|    | '_| / _` |  / _` |   / -_) \ \__,_|  / _|   | ' \    / -_)   / _|   | ' \    / _ \     _     / _|    / _ \  | '  \  
//|    _\__|   _|_|_  \__,_|  \__,_|   \___|  \____/   \__|_  |_||_|   \___|   \__|_  |_||_|   \___/   _(_)_   \__|_   \___/  |_|_|_| 
//|  _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| 
//|  "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'

//|
//| kgtMartingale EA.mq4
//|
//| Version history:
//|
//| V1.0: First Release
//|      - by checho trade@checho.com
//|      - 03-07-2018
//|

//|  01110100 01110010 01100001 01100100 01100101 01000000 01100011 01101000 01100101 01100011 01101000 01101111 00101110 01100011 01101111 01101101

#property copyright "Copyright 2018, checho"
#property link      "https://www.mql5.com/en/users/seemore"

#property description "              ,,,,,    "    
#property description "           /(o o)\\     "  
#property description "     ooO--(_)--Ooo  "
#property description "____"
#property description "Have Fun and Happy Pips!"
#property description "____"
#property description "Checho"
#property description "____"

#property version   "1.7"
#property strict


extern string t="-----------------------------------";  //-----------------------------------
extern string ta="";            // TRADE SETTINGS
extern string ts="-----------------------------------";  //-----------------------------------
extern int MagicN=2018821; // Magic number
input bool TradeInBothDir=true; // Trade in both directions
extern double Lots=0.01; // Lot Size 
extern double Gap  = 10.0; // Distance of the pending order Trail
input double DistanceOrder=10.0; // Distance between the orders
extern double LotMultiplier=1.3; // Lot Multiplier
extern int MaxOrders = 99; // Max Orders
extern double TP=5; // Take Profit
input bool UseHiddenSL = false; // Use Hidden SL/TP
extern double TrailStop=10.0; // Trailing stop Market Orders
input bool Use_SPREAD=false; // Use Spread Filter for new grid
input int MaxSpread=30; // Max Spread (pips)
input int MaxSlippage=50; // max Slippage
extern string in="-----------------------------------"; //-----------------------------------
extern string indi="";                               // INDICATOR SETTINGS
extern string in2="-----------------------------------"; //-----------------------------------

input int bb_period=20;  // BB Period
input double bb_deviation=2;  // BB Deviation
input int bb_shift=0; // BB Shift
input ENUM_APPLIED_PRICE bb_Applied_Price=PRICE_CLOSE; //BB Applied Price

double Pip;

int bars;
int barComment;
string filename;
double ho;
double lo;
bool slippageWritten=false;
double LotStep;
double HiddenTrailSL;
int ordersTotal;
int spread;
string label_name_spread="label_spread";
double SL=0;

bool range=false;
int tickBUYSTOP=0,tickSELLSTOP=0;
int dealDirection = -1;
int MinStopLevel=0;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
//----
   Pip=Point()*10;
//   Print("PIP ", Pip);
   LotStep=MarketInfo(Symbol(),MODE_LOTSTEP);
   ordersTotal=0;
   double dStopLevel=(MathMax(MarketInfo(_Symbol,MODE_STOPLEVEL),MarketInfo(_Symbol,MODE_FREEZELEVEL))*Pip);
   if(Gap<dStopLevel) Gap=dStopLevel;
   if(TP > 0 && TP < dStopLevel) TP = dStopLevel;
   if(SL > 0 && SL < dStopLevel) SL = dStopLevel;
   if(TrailStop>0 && TrailStop<dStopLevel) TrailStop=dStopLevel;
   spread=(int)MathAbs((Ask-Bid)/Point());

   MinStopLevel=(int) MarketInfo(Symbol(),MODE_STOPLEVEL);
   if(MinStopLevel==0)
      MinStopLevel=spread*2;
         
   start();
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   ObjectDelete(0,label_name_spread);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {

   int result=0;
   int orderType=-1;
   int orderTotal=OrdersTotal();
   int marketOrders=0;
   int countBUYs=0;
   int countSELLs=0;
   double price;
   double sl=0,tp=0;
   double sp= Ask-Bid;
   double WorkLots=Lots;
   double lastLotSize = Lots;
   double OrderPrceBUY=0;
   double OrderPrceSELL=0;
   double lotsXopenprice=0;
   double averageLots=0;

   spread=(int)MathAbs((Ask-Bid)/Point());
   LabelCreate(0,label_name_spread,0,160,30,CORNER_RIGHT_LOWER,"Curr. Spread: "+IntegerToString(spread),"Arial",12,clrLime);

   if(range && TradeInBothDir)
     {
      checkRangePending();
      return -1;
     }

   Comment("\n ËQUITY "+DoubleToString(AccountEquity(),2));
   int orders=0;
   for(int o=0;o<orderTotal;o++)
     {
      if(!OrderSelect(o,SELECT_BY_POS,MODE_TRADES)) continue;
      if(OrderSymbol()!=Symbol()) continue;
      if(OrderMagicNumber()==MagicN)
        {
         orders++;
        }
     }

   if(orders==0 && Use_SPREAD && spread>=MaxSpread)
     {
      Comment("Spread filter blocked new trades");
      Print("Spread filter blocked new trades");
      return -1;
     }

   for(int i=0;i<orderTotal;i++)
     {
      if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN)
        {
         RefreshRates();
         sp=Ask-Bid;
         orderType=OrderType();
         if(orderType==OP_BUY)
           {
            if(OrderStopLoss()==0 && SL>0)
              {
               //if(TP > 0) tp = NormalizeDouble(Ask + TP * Pip, Digits);
               if(SL > 0) sl = NormalizeDouble(Ask - SL * Pip, Digits);
               if(!OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrRed))
                 {
                  Alert("Error setting initial SL/TP on buy order ticket="+(string)OrderTicket()+" Error="+(string)GetLastError());
                  return(0);
                 }
              }
            if(orders==1 && UseHiddenSL)
              {
               if(HiddenTrailSL==0 && Bid-OrderOpenPrice()>TrailStop*Pip)
                 {
                  HiddenTrailSL=NormalizeDouble((Bid-(TrailStop*Pip)),Digits);
                 }
               if(HiddenTrailSL>0 && Bid-HiddenTrailSL>TrailStop*Pip)
                 {
                  HiddenTrailSL=NormalizeDouble((Bid-(TrailStop*Pip)),Digits);
                 }
               if(HiddenTrailSL>=Bid)
                 {
                  while(IsTradeContextBusy()) Sleep(100);
                  result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),1,CLR_NONE);
                  if(!result)
                    {
                     int err=GetLastError();
                     Print("Stop loss hit. Close of ",OrderSymbol()," ticket no ",OrderTicket()," failed with error (",err,"): ");
                    }
                  else HiddenTrailSL=0;
                 }
              }
            OrderPrceBUY=OrderOpenPrice();
            result=result+1000;
            marketOrders++;
            countBUYs++;
            lastLotSize = OrderLots();
            averageLots+= OrderLots();
            lotsXopenprice+=OrderLots()*OrderOpenPrice();
            continue;
           }
         if(orderType==OP_SELL)
           {
            if(OrderStopLoss()==0 && SL>0)
              {
              // if(TP > 0) tp = NormalizeDouble(Bid - TP * Pip, Digits);
               if(SL > 0) sl = NormalizeDouble(Bid + SL * Pip, Digits);
               if(!OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,clrRed))
                 {
                  Alert("Error setting initial SL/TP on sell order "+(string)GetLastError());
                  return(0);
                 }
              }
            if(orders==1 && UseHiddenSL)
              {
               if(HiddenTrailSL==0 && OrderOpenPrice()-Ask>TrailStop*Pip)
                 {
                  HiddenTrailSL=NormalizeDouble((Ask+(TrailStop*Pip)),Digits);
                 }
               if(HiddenTrailSL>0 && HiddenTrailSL-Ask>Pip*Point)
                 {
                  HiddenTrailSL=NormalizeDouble((Ask+(TrailStop*Pip)),Digits);
                 }
               if(HiddenTrailSL<Ask && HiddenTrailSL>0)
                 {
                  while(IsTradeContextBusy()) Sleep(100);
                  result=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),1,CLR_NONE);
                  if(!result)
                    {
                     int err=GetLastError();
                     Print("Stop loss hit. Close of ",OrderSymbol()," ticket no ",OrderTicket()," failed with error (",err,"): ");
                    }
                  else HiddenTrailSL=0;
                 }
              }
            OrderPrceSELL=OrderOpenPrice();
            result=result+100;
            marketOrders++;
            countSELLs++;
            lastLotSize = OrderLots();
            averageLots+= OrderLots();
            lotsXopenprice+=OrderLots()*OrderOpenPrice();
            continue;
           }
         if(orderType==OP_BUYSTOP)
           {
            result=result+10;
            if(OrderOpenPrice()-Ask>Gap*Pip*2 /*|| OrderStopLoss() == 0*/)
              {
               price=Ask+Gap*Pip;
               if(TP > 0) tp = NormalizeDouble(price + TP * Pip, Digits);
               if(SL > 0) sl = NormalizeDouble(price - SL * Pip, Digits);
               if(!OrderModify(OrderTicket(),NormalizeDouble(price,Digits),sl,tp,0,clrRed))
                 {
                  Alert("Error move buy pending order "+(string)GetLastError());
                  return(0);
                 }
              }
            continue;
           }
         if(orderType==OP_SELLSTOP)
           {
            result=result+1;
            if(Bid-OrderOpenPrice()>Gap*Pip*2 /*|| OrderStopLoss() == 0*/)
              {
               price=Bid-Gap*Pip;
               if(TP > 0) tp = NormalizeDouble(price - TP * Pip, Digits);
               if(SL > 0) sl = NormalizeDouble(price + SL * Pip, Digits);
               if(!OrderModify(OrderTicket(),NormalizeDouble(price,Digits),sl,tp,0,clrRed))
                 {
                  Alert("Error move sell pending order "+(string)GetLastError());
                  return(0);
                 }
              }
           }
        }
     }

   if(marketOrders>1)
     {
      //WorkLots = MathFloor(MathMax(lastLotSize*LotMultiplier,Lots+LotStep) / LotStep) * LotStep;
      WorkLots=RoundNumber(MathMax(lastLotSize*LotMultiplier,Lots+LotStep),2);
      //Print("r "+(lastLotSize*LotMultiplier);
     }
   else
     {
      if(marketOrders==1) WorkLots=lastLotSize*LotMultiplier;
     }
//
//

   double averagePrice=0;
   if(averageLots>0) averagePrice=lotsXopenprice/averageLots;
   if(countBUYs>1 && UseHiddenSL)
     {
      if(Bid>averagePrice+TP*Pip)
        {
         CloseAll();
         Print("Closed All");
         return(0);
        }
     }
   if(countSELLs>1 && UseHiddenSL)
     {
      if(Ask<averagePrice-TP*Pip)
        {
         CloseAll();
         Print("Closed All");
         return(0);
        }
     }
//
// 
//HideTestIndicators(true);    
//double dotdown = iCustom(NULL, PERIOD_CURRENT, "Semafor123Triangles", 4, 0);
//double dotup   = iCustom(NULL, PERIOD_CURRENT, "Semafor123Triangles", 5, 0);

   double BBtop=iBands(NULL,0,bb_period,bb_deviation,bb_shift,bb_Applied_Price,MODE_UPPER,0);
   double BBbottom=iBands(NULL,0,bb_period,bb_deviation,bb_shift,bb_Applied_Price,MODE_LOWER,0);
//HideTestIndicators(false);

   if(result==0 /*&& bars != Bars*/)
     {
      ho = 0;
      lo = 0;
      HiddenTrailSL=0;

      if(Close[0]<NormalizeDouble(BBbottom,Digits) /*&& dotdown != 0*/)
        {
         ho=NormalizeDouble(Ask+(Gap*Pip)+sp, Digits());
         //if (ho < Ask+(MinStopLevel*Point)) ho=Ask+(MinStopLevel*Point); //Ensure orders are MinStopLevel away but only if necessary
         if(OrderSend(Symbol(),OP_BUYSTOP,WorkLots,ho,MaxSlippage,0,0,"kgtMartingale",MagicN,0,clrGreen)==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
         bars=Bars;
        }
      else
      if(Close[0]>BBtop && BBtop>0 /*&& dotup != 0*/)
        {
         lo=NormalizeDouble(Bid -(Gap*Pip), Digits());
         //if (lo > Bid-(MinStopLevel*Point)) lo=Bid-(MinStopLevel*Point); //Ensure orders are MinStopLevel away but only if necessary
         if(OrderSend(Symbol(),OP_SELLSTOP,WorkLots,lo,MaxSlippage,0,0,"kgtMartingale",MagicN,0,clrGreen)==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
         bars=Bars;
        }
      else if(TradeInBothDir)
        {
         ho =NormalizeDouble( Ask + (Gap * Pip) + sp, Digits());
         lo =NormalizeDouble( Bid - (Gap * Pip), Digits());
         double price1=0;
         double tpN=0;
         if(TP>0)
           {
            price1=Ask+Gap*Pip;
            tpN=NormalizeDouble(price1+TP*Pip,Digits);
           }
         tickBUYSTOP=OrderSend(Symbol(),OP_BUYSTOP,WorkLots,ho,MaxSlippage,0,tpN,"kgtMartingale",MagicN,0,clrGreen);
         if(TP>0)
           {
            price1=Bid-Gap*Pip;
            tpN=NormalizeDouble(price1-TP*Pip,Digits);
           }
         tickSELLSTOP=OrderSend(Symbol(),OP_SELLSTOP,WorkLots,lo,MaxSlippage,0,tpN,"kgtMartingale",MagicN,0,clrGreen);
         if(tickBUYSTOP==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
         if(tickSELLSTOP==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
         bars=Bars;
         range=true;
        }
     }
   else
     {
      // double pipTriger = iATR(_Symbol, 60, 3, 1);
      // if (countBUYs > 0 && Bid <= OrderPrceBUY - pipTriger - sp) 
      if(countBUYs>0 && Bid<=NormalizeDouble(OrderPrceBUY-Pip*DistanceOrder,Digits()))
        {
         if(OrderSend(Symbol(),OP_BUY,WorkLots,Ask,MaxSlippage,0,0,"kgtMartingale",MagicN,0,clrGreen)==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
         retraceTP();  
        }
      //if (countSELLs > 0 && Ask >= OrderPrceSELL + pipTriger + sp)     
      if(countSELLs>0 && Ask>=NormalizeDouble(OrderPrceSELL+Pip*DistanceOrder,Digits()))
        {
         if(OrderSend(Symbol(),OP_SELL,WorkLots,Bid,MaxSlippage,0,0,"kgtMartingale",MagicN,0,clrGreen)==-1)
           {
            Alert("Error opening buystop "+(string)GetLastError());
            return(0);
           }
          retraceTP(); 
        }
     }

   barComment=Bars;
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double RoundNumber(double number,int digits)
  {
   number=MathFloor((number*MathPow(10,digits))+0.4);
   return (number * MathPow(10, -digits));
  }
//+------------------------------------------------------------------+
void checkRangePending()
  {
   if(OrderSelect(tickBUYSTOP,SELECT_BY_TICKET))
     {
      if(OrderType()==OP_BUY)
        {
         range=false;
         if(OrderDelete(tickSELLSTOP))
           {
            Print("Error delete Pending order");
           }
         tickBUYSTOP=0;
         tickSELLSTOP=0;
        }
     }
   if(OrderSelect(tickSELLSTOP,SELECT_BY_TICKET))
     {
      if(OrderType()==OP_SELL)
        {
         range=false;
         if(OrderDelete(tickBUYSTOP))
           {
            Print("Error delete Pending order");
           }
         tickBUYSTOP=0;
         tickSELLSTOP=0;
        }
     }
  }
//+------------------------------------------------------------------+
void CloseAll()
  {
   int i;
   bool something_closed=true;
   while(something_closed)
     {
      something_closed=false;
      int total= OrdersTotal();
      for(int n=0; n<total; n++)
        {
         if(!OrderSelect(n,SELECT_BY_POS,MODE_TRADES)) continue;
         if(OrderSymbol()!=Symbol()) continue;
         if(OrderCloseTime()!=0) continue;
         if(OrderMagicNumber()!=MagicN) continue;
         if(OrderType()==OP_BUY || OrderType()==OP_SELL)
           {
            for(i=0; i<5; i++)
              {
               RefreshRates();
               if(!OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),1))
                 {
                  Sleep(100);
                 }
               else
                 {
                  something_closed=true;
                  break;
                 }
              }
            if(something_closed) break;
           }
         if(OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_SELLLIMIT)
           {
            for(i=0;i<5;i++)
              {
               RefreshRates();
               if(!OrderDelete(OrderTicket()))
                 {
                  Sleep(100);
                 }
               else
                 {
                  something_closed=true;
                  break;
                 }
              }
            if(something_closed) break;
           }
        }
     }
  }
  
///////////////////////////////////////////////////////////NEW PART/////////////////////////////////////////////  

//+------------------------------------------------------------------+
double GetPPP()
  {
   return (MarketInfo(Symbol(),MODE_TICKVALUE));
  }
//+------------------------------------------------------------------+  
int getPipsFromMoney(double money,double lots)
  {
   int res=0;

   res=(int)MathRound(money/(GetPPP()*lots));

   return res;
  }  
//+------------------------------------------------------------------+
int getBELevel()
  {
   int res=0;
   double profit=0;
   double lots=0;
   for(int i=0; i<OrdersTotal(); i++)
     {
      if(OrderSelect(i,SELECT_BY_POS))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN && (OrderType()==OP_BUY || OrderType()==OP_SELL))
           {
            profit+=OrderProfit()+OrderCommission()+OrderSwap();
            lots+=OrderLots();
           }
        }
     }
   res=getPipsFromMoney(MathAbs(profit),lots);
   return res;
  }  
//+------------------------------------------------------------------+
int getLastOpenDeal()
  {
   int ticket=0;
   datetime lastDealTime=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN && (OrderType()==OP_BUY || OrderType()==OP_SELL))
           {
            if(OrderOpenTime()>lastDealTime)
              {
               lastDealTime=OrderOpenTime();
               ticket=OrderTicket();
               dealDirection=OrderType();
              }
           }
        }
     }

   return ticket;
  }  
//+------------------------------------------------------------------+
int dealsCount()
  {
   int res=0;
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN && (OrderType()==OP_BUY || OrderType()==OP_SELL))
           {
            dealDirection=OP_SELL;
            if(OrderType()==OP_BUY)
             dealDirection=OP_BUY;
            res++;
           }
        }
     }
   return res;
  }
//+------------------------------------------------------------------+
void moveTP(double newTP)
  {
   for(int pos=0;pos<OrdersTotal();pos++)
     {
      if(OrderSelect(pos,SELECT_BY_POS))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicN && (OrderType()==OP_BUY || OrderType()==OP_SELL))
           {
            if(!OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),newTP,0))
               Print(" Error modify order #",GetLastError());
           }
        }
     }
  }  
//+------------------------------------------------------------------+
void retraceTP()
  {
   int deals=dealsCount();
   if(deals>0)
     {
     double LastDistance=DistanceOrder*10;
     int lastTicket=getLastOpenDeal();

      /// Подтяжка TP 
      if(dealDirection==OP_BUY)
        {
         double OpenPrice=Bid;
         double takeprofit=0;
         if(OrderSelect(lastTicket,SELECT_BY_TICKET))
            OpenPrice=OrderOpenPrice();
         double curBELevel=getBELevel();
         double BELevel=NormalizeDouble(OpenPrice+Point()*(curBELevel),Digits);
         double TP_=curBELevel+TP*10;
         if(TP_>0)
           {
            double min_takeprofit=NormalizeDouble(OpenPrice+Point()*MinStopLevel, Digits);
            double set_takeprofit=NormalizeDouble(OpenPrice+Point()*TP_, Digits);

            if(set_takeprofit<=min_takeprofit)
               takeprofit=min_takeprofit;
            else
               takeprofit=set_takeprofit;
           }

         moveTP(takeprofit);
        }
      if(dealDirection==OP_SELL)
        {
         double OpenPrice=Ask;
         double takeprofit=0;
         if(OrderSelect(lastTicket,SELECT_BY_TICKET))
            OpenPrice=OrderOpenPrice();

         int curBELevel=getBELevel();
         double BELevel=NormalizeDouble(OpenPrice-Point()*(curBELevel),Digits);
         double TP_=curBELevel+TP*10;

         if(TP_>0)
           {
            double min_takeprofit=NormalizeDouble(OpenPrice-Point()*MinStopLevel, Digits);
            double set_takeprofit=NormalizeDouble(OpenPrice-Point()*TP_, Digits);
            if(set_takeprofit>=min_takeprofit)
               takeprofit=min_takeprofit;
            else
               takeprofit=set_takeprofit;
           }

         moveTP(takeprofit);
        }
     }
  }  
//+------------------------------------------------------------------+
bool LabelCreate(const long              chart_ID=0,
                 const string            name="Label",
                 const int               sub_window=0,
                 const int               x=0,
                 const int               y=0,
                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER,
                 const string            text="Label",
                 const string            font="Arial",
                 const int               font_size=10,
                 const color             clr=clrRed,
                 const double            angle=0.0,
                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER,
                 const bool              back=false,
                 const bool              selection=false,
                 const bool              hidden=true,
                 const long              z_order=0)
  {
   ResetLastError();
   ObjectDelete(0,name);
   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))
     {
      Print(__FUNCTION__,
            ": Error = ",GetLastError());
      return(false);
     }
   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);
   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);
   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);
   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);
   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);
   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);
   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
   return(true);
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| END                                                              |
//+------------------------------------------------------------------+

//              ('-. .-.   ('-.              ('-. .-.             
//             ( OO )  / _(  OO)            ( OO )  /             
//     .-----. ,--. ,--.(,------.   .-----. ,--. ,--. .-'),-----. 
//    '  .--./ |  | |  | |  .---'  '  .--./ |  | |  |( OO'  .-.  '
//    |  |('-. |   .|  | |  |      |  |('-. |   .|  |/   |  | |  |
//   /_) |OO  )|       |(|  '--.  /_) |OO  )|       |\_) |  |\|  |
//   ||  |`-'| |  .-.  | |  .--'  ||  |`-'| |  .-.  |  \ |  | |  |
//  (_'  '--'\ |  | |  | |  `---.(_'  '--'\ |  | |  |   `'  '-'  '
//     `-----' `--' `--' `------'   `-----' `--' `--'     `-----' 

Tzvetan Jordanov
Tzvetan Jordanov
  • www.mql5.com
IT Developer v.69.1 20+ yrs - Assembler, C#, C++, Delphi, Visual Basic, Java, Python 2/3, NET, PHP, MQL4, MQL5 .... Nothing is impossible in the IT world!
 

Primeiro: quando for inserir código utilize "Alt+S";

Segundo: entre em contato com o desenvolvedor do EA para solução do suposto problema. 

 

Caro @lfkiguti

seguindo as recomendações propostas pelo @Joscelino Celso de Oliveira, para alguém estudar o seu código inteiro seria improdutivo, neste caso o desenvolvedor é a melhor opção.

No entanto, dei uma rápida olhada e veja se habilitando a função "Use Hidden SL/TP" ele habilita o TS.