Text/Arrow Overlaps after changing

 

What I'm doing wrong? When text or arrow (Wingdings) is changing, it overlaps to last one like on picture.


You can see it on first arrow. Code is simple ..

       if(iClose(Symbol(),IsPeriod[x],1) > 
          iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMAUP + "1" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 95, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "1", CharToStr(236), "Wingdings", Green, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < 
               iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMADOWN + "1", CharToStr(234), "Wingdings", Red, EMAtX[x], 92, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "1", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
 
  1. I assume WriteText creates objects and the first parameter is the name. Always post all relevant code (using SRC).
         How To Ask Questions The Smart Way. 2004
              Be precise and informative about your problem

  2. You create many
    del + EMAUP + "1" + IntegerToString(x)
    objects
  3. You create only one
    del + EMADOWN + "1"
    You try to create two
    del + EMAFLAT + "1"

 
//+------------------------------------------------------------------+
//|                                              mrrDboard(Mine).mq4 |
//|                                          Copyright 2020, Mr-Roma |
//|                             https://www.forexfactory.com/mr-roma |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Mr-Roma"
#property link      "https://www.forexfactory.com/mr-roma"
#property version   "1.00"
#property strict
#property indicator_chart_window

double      pnt;
string      del      = "+";

////////////// Technical Indicators
sinput string   ___Indicators___    = "- Set Parameters For Indicators -";
sinput string   MovingAverage___ = "> EMA Parameters";
extern int   EMA1         = 14;
extern int   EMA2         = 50;
extern int   EMA3         = 100;
extern int   EMA4         = 200;
sinput string   STOCH___         = "> Stochastic Parameters";
extern int   StochasticK  = 9;
extern int   StochasticD  = 6;
extern int   StochasticS  = 3;
sinput string   MACD___          = "> MACD Parameters";
extern int   MacdFast     = 12;
extern int   MacdSlow     = 26;
extern int   MacdSignal   = 9;
sinput string   RSI___           = "> RSI Parameters";
extern int   RSIPeriod    = 14;

int    IsPeriod [7] ={5,15,30,60,240,1440,10080};

int    EMAtX    [7] ={285, 315, 350, 380, 405, 430, 455};
string EMATi    [7] ={"M5", "M15", "M30", "H1", "H4", "D1", "W1"};
int    EMA1A    [7] ={285, 315, 350, 380, 405, 430, 459};
int    EMA2A    [7] ={285, 315, 350, 380, 405, 430, 455};
int    EMA3A    [7] ={285, 315, 350, 380, 405, 430, 455};
int    EMA4A    [7] ={285, 315, 350, 380, 405, 430, 455};
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int deinit() {
   ObjectsDeleteAll(0,del);
      
   return(0);
}

//+------------------------------------------------------------------+
int start() {

///////////////////// - Profit Tracker -
   DrawObject (del + "ProfitTracker_Back", Black, 203, 122, 270, 121, LightGray, "\n", FALSE, 2); 
   
   string EMATitle, EMAUP, EMADOWN, EMAFLAT;
   for(int x = 0; x < 7; x ++) {
   EMATitle  = "EMATitle" + IntegerToString(x);
   EMAUP     = "EMA_UP"   + IntegerToString(x);
   EMADOWN   = "EMA_DOWN" + IntegerToString(x);
   EMAFLAT   = "EMA_FLAT" + IntegerToString(x);
   WriteText  (del + EMATitle, EMATi[x], "Arial", White, EMAtX[x], 112, "\n", 9, 2, ANCHOR_CENTER, FALSE);
   
  /////////// EMA1 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMAUP + "1", CharToStr(233), "Wingdings", Lime, EMAtX[x], 95, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "1", CharToStr(236), "Wingdings", Green, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMADOWN + "1", CharToStr(234), "Wingdings", Red, EMAtX[x], 92, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "1", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
          
  /////////// EMA2 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMAUP + "2" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 79, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "2", CharToStr(236), "Wingdings", Green, EMAtX[x], 76, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMADOWN + "2", CharToStr(234), "Wingdings", Red, EMAtX[x], 76, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "2", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 76, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
  /////////// EMA3 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMAUP + "3" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 63, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "3", CharToStr(236), "Wingdings", Green, EMAtX[x], 60, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMADOWN + "3", CharToStr(234), "Wingdings", Red, EMAtX[x], 60, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "3", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 60, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
  /////////// EMA4 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMAUP + "4" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 48, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "4", CharToStr(236), "Wingdings", Green, EMAtX[x], 45, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMADOWN + "4", CharToStr(234), "Wingdings", Red, EMAtX[x], 45, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMAFLAT + "4", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 45, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
   }
   
   WriteText  (del + "EMA1", "EMA" + IntegerToString(EMA1), "Arial", Orange, 205, 86, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA2", "EMA" + IntegerToString(EMA2), "Arial", Orange, 205, 70, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA3", "EMA" + IntegerToString(EMA3), "Arial", Orange, 205, 54, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA4", "EMA" + IntegerToString(EMA4), "Arial", Orange, 205, 38, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   
   return(0);
}

  void DrawObject(string name, color backcolor, int xdistance, int ydistance, int xsize, int ysize, color bordercolor, string tooltip, int objback, int corner)
  {
  if (ObjectFind(name)<0) ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0, 0);
  ObjectSetInteger (0, name, OBJPROP_BGCOLOR     , backcolor);
  ObjectSetInteger (0, name, OBJPROP_XDISTANCE   , xdistance);
  ObjectSetInteger (0, name, OBJPROP_YDISTANCE   , ydistance);
  ObjectSetInteger (0, name, OBJPROP_XSIZE       , xsize);
  ObjectSetInteger (0, name, OBJPROP_YSIZE       , ysize);
  ObjectSetInteger (0, name, OBJPROP_COLOR       , bordercolor);
  ObjectSetInteger (0, name, OBJPROP_BORDER_TYPE , BORDER_FLAT);
  ObjectSetString  (0, name, OBJPROP_TOOLTIP     , tooltip);
  ObjectSetInteger (0, name, OBJPROP_BACK        , objback);
  ObjectSetInteger (0, name, OBJPROP_CORNER      , corner);
  }

  void WriteText(string name, string text, string fontName, color Color, int xDistance, int yDistance, string tooltip, int fontSize, int corner, int anchor, int objBack)
  {
  if (ObjectFind(name)<0) ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
  ObjectSetText     (name, text, fontSize, fontName);
  ObjectSet         (name, OBJPROP_COLOR         , Color);
  ObjectSet         (name, OBJPROP_XDISTANCE     , xDistance);
  ObjectSet         (name, OBJPROP_YDISTANCE     , yDistance);
  ObjectSet         (name, OBJPROP_CORNER        , corner);
  ObjectSet         (name, OBJPROP_ANCHOR        , anchor);
  ObjectSet         (name, OBJPROP_FONTSIZE      , fontSize);
  ObjectSet         (name, OBJPROP_BACK          , objBack);
  ObjectSetInteger  (0, name, OBJPROP_HIDDEN     , TRUE);
  ObjectSetInteger  (0, name, OBJPROP_SELECTABLE , FALSE);
  ObjectSetString   (0, name, OBJPROP_TOOLTIP    , tooltip);
}
 

OK, I found the problem. As you said I was creating too much Arrows instead of creating one and using it for other if else parameters.

//+------------------------------------------------------------------+
//|                                              mrrDboard(Mine).mq4 |
//|                                          Copyright 2020, Mr-Roma |
//|                             https://www.forexfactory.com/mr-roma |
//+------------------------------------------------------------------+
#property copyright "Copyright 2020, Mr-Roma"
#property link      "https://www.forexfactory.com/mr-roma"
#property version   "1.00"
#property strict
#property indicator_chart_window

double      pnt;
string      del      = "+";

////////////// Technical Indicators
sinput string   ___Indicators___    = "- Set Parameters For Indicators -";
sinput string   MovingAverage___ = "> EMA Parameters";
extern int   EMA1         = 14;
extern int   EMA2         = 50;
extern int   EMA3         = 100;
extern int   EMA4         = 200;
sinput string   STOCH___         = "> Stochastic Parameters";
extern int   StochasticK  = 9;
extern int   StochasticD  = 6;
extern int   StochasticS  = 3;
sinput string   MACD___          = "> MACD Parameters";
extern int   MacdFast     = 12;
extern int   MacdSlow     = 26;
extern int   MacdSignal   = 9;
sinput string   RSI___           = "> RSI Parameters";
extern int   RSIPeriod    = 14;

int    IsPeriod [7] ={5,15,30,60,240,1440,10080};

int    EMAtX    [7] ={285, 315, 350, 380, 405, 430, 455};
string EMATi    [7] ={"M5", "M15", "M30", "H1", "H4", "D1", "W1"};
int    EMA1A    [7] ={285, 315, 350, 380, 405, 430, 459};
int    EMA2A    [7] ={285, 315, 350, 380, 405, 430, 455};
int    EMA3A    [7] ={285, 315, 350, 380, 405, 430, 455};
int    EMA4A    [7] ={285, 315, 350, 380, 405, 430, 455};
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int deinit() {
   ObjectsDeleteAll(0,del);
      
   return(0);
}

//+------------------------------------------------------------------+
int start() {

///////////////////// - Profit Tracker -
   DrawObject (del + "ProfitTracker_Back", Black, 203, 122, 270, 121, LightGray, "\n", FALSE, 2); 
   
   string EMATitle, EMACandleCros;
   for(int x = 0; x < 7; x ++) {
   EMATitle      = "EMATitle"   + IntegerToString(x);
   EMACandleCros = "EMACandleCross_"  + IntegerToString(x) + "_";
   WriteText  (del + EMATitle, EMATi[x], "Arial", White, EMAtX[x], 112, "\n", 9, 2, ANCHOR_CENTER, FALSE);
   
  /////////// EMA1 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMACandleCros + "1", CharToStr(233), "Wingdings", Lime, EMAtX[x], 95, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "1", CharToStr(236), "Wingdings", Green, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "1", CharToStr(234), "Wingdings", Red, EMAtX[x], 92, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA1, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "1", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 92, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
          
  /////////// EMA2 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMACandleCros + "2" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 79, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "2", CharToStr(236), "Wingdings", Green, EMAtX[x], 76, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "2", CharToStr(234), "Wingdings", Red, EMAtX[x], 76, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "2", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 76, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
  /////////// EMA3 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMACandleCros + "3" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 63, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "3", CharToStr(236), "Wingdings", Green, EMAtX[x], 60, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "3", CharToStr(234), "Wingdings", Red, EMAtX[x], 60, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA3, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "3", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 60, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
  /////////// EMA4 Parameters
       if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
              WriteText (del + EMACandleCros + "4" + IntegerToString(x), CharToStr(233), "Wingdings", Lime, EMAtX[x], 48, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "4", CharToStr(236), "Wingdings", Green, EMAtX[x], 45, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) < iMA(Symbol(), IsPeriod[x], EMA2, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "4", CharToStr(234), "Wingdings", Red, EMAtX[x], 45, "\n", 10, 2, ANCHOR_CENTER, FALSE);
          }
       else if(iClose(Symbol(),IsPeriod[x],1) > iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0) &&
               iClose(Symbol(),IsPeriod[x],0) < iMA(Symbol(), IsPeriod[x], EMA4, 0, MODE_EMA, PRICE_CLOSE, 0)){
               WriteText (del + EMACandleCros + "4", CharToStr(238), "Wingdings", OrangeRed, EMAtX[x], 45, "\n", 11, 2, ANCHOR_CENTER, FALSE);
          }
   }
   
   WriteText  (del + "EMA1", "EMA (" + IntegerToString(EMA1) + ")", "Arial", Orange, 205, 86, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA2", "EMA (" + IntegerToString(EMA2) + ")", "Arial", Orange, 205, 70, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA3", "EMA (" + IntegerToString(EMA3) + ")", "Arial", Orange, 205, 54, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "EMA4", "EMA (" + IntegerToString(EMA4) + ")", "Arial", Orange, 205, 38, "\n", 9, 2, ANCHOR_LEFT_LOWER, FALSE);
   /*
   WriteText  (del + "trddt", "EMA200", "Arial", Orange, 205, 88, "\n", 8, 2, ANCHOR_LEFT_LOWER, FALSE);
   WriteText  (del + "trddts", CharToStr(233), "Wingdings", White, 453, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   WriteText  (del + "trddtrs", CharToStr(234), "Wingdings", White, 428, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   WriteText  (del + "trddtrs1", CharToStr(235), "Wingdings", White, 403, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   WriteText  (del + "trddtrs2", CharToStr(236), "Wingdings", White, 378, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   WriteText  (del + "trddtrs3", CharToStr(237), "Wingdings", White, 353, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   WriteText  (del + "trddtrs4", CharToStr(238), "Wingdings", White, 328, 88, "\n", 10, 2, ANCHOR_CENTER, FALSE);
   */
   
   
   return(0);
}

  void DrawObject(string name, color backcolor, int xdistance, int ydistance, int xsize, int ysize, color bordercolor, string tooltip, int objback, int corner)
  {
  if (ObjectFind(name)<0) ObjectCreate(0, name, OBJ_RECTANGLE_LABEL, 0, 0, 0, 0);
  ObjectSetInteger (0, name, OBJPROP_BGCOLOR     , backcolor);
  ObjectSetInteger (0, name, OBJPROP_XDISTANCE   , xdistance);
  ObjectSetInteger (0, name, OBJPROP_YDISTANCE   , ydistance);
  ObjectSetInteger (0, name, OBJPROP_XSIZE       , xsize);
  ObjectSetInteger (0, name, OBJPROP_YSIZE       , ysize);
  ObjectSetInteger (0, name, OBJPROP_COLOR       , bordercolor);
  ObjectSetInteger (0, name, OBJPROP_BORDER_TYPE , BORDER_FLAT);
  ObjectSetString  (0, name, OBJPROP_TOOLTIP     , tooltip);
  ObjectSetInteger (0, name, OBJPROP_BACK        , objback);
  ObjectSetInteger (0, name, OBJPROP_CORNER      , corner);
  }

  void WriteText(string name, string text, string fontName, color Color, int xDistance, int yDistance, string tooltip, int fontSize, int corner, int anchor, int objBack)
  {
  if (ObjectFind(name)<0) ObjectCreate(name, OBJ_LABEL, 0, 0, 0);
  ObjectSetText     (name, text, fontSize, fontName);
  ObjectSet         (name, OBJPROP_COLOR         , Color);
  ObjectSet         (name, OBJPROP_XDISTANCE     , xDistance);
  ObjectSet         (name, OBJPROP_YDISTANCE     , yDistance);
  ObjectSet         (name, OBJPROP_CORNER        , corner);
  ObjectSet         (name, OBJPROP_ANCHOR        , anchor);
  ObjectSet         (name, OBJPROP_FONTSIZE      , fontSize);
  ObjectSet         (name, OBJPROP_BACK          , objBack);
  ObjectSetInteger  (0, name, OBJPROP_HIDDEN     , TRUE);
  ObjectSetInteger  (0, name, OBJPROP_SELECTABLE , FALSE);
  ObjectSetString   (0, name, OBJPROP_TOOLTIP    , tooltip);
}

Thanks for your help.

 
Hmm, it still overlaps when new candle opens ...
 

In this case it is not needed to keep creating new objects.

You can simply modify the ones that are already there.

ObjectSetString(.... OBJ_TEXT

See here

Or you can use the standard functions.

This one uses price and time coordinates but it gives an example on assigning a new arrow to an existing object.

//+------------------------------------------------------------------+ 
//| Create the arrow                                                 | 
//+------------------------------------------------------------------+ 
bool ArrowCreate(const long              chart_ID=0,           // chart's ID 
                 const string            name="Arrow",         // arrow name 
                 const int               sub_window=0,         // subwindow index 
                 datetime                time=0,               // anchor point time 
                 double                  price=0,              // anchor point price 
                 const uchar             arrow_code=252,       // arrow code 
                 const ENUM_ARROW_ANCHOR anchor=ANCHOR_BOTTOM, // anchor point position 
                 const color             clr=clrRed,           // arrow color 
                 const ENUM_LINE_STYLE   style=STYLE_SOLID,    // border line style 
                 const int               width=3,              // arrow size 
                 const bool              back=false,           // in the background 
                 const bool              selection=true,       // highlight to move 
                 const bool              hidden=true,          // hidden in the object list 
                 const long              z_order=0)            // priority for mouse click 
  { 
//--- set anchor point coordinates if they are not set 
   ChangeArrowEmptyPoint(time,price); 
//--- reset the error value 
   ResetLastError(); 
//--- create an arrow 
   if(!ObjectCreate(chart_ID,name,OBJ_ARROW,sub_window,time,price)) 
     { 
      Print(__FUNCTION__, 
            ": failed to create an arrow! Error code = ",GetLastError()); 
      return(false); 
     } 
//--- set the arrow code 
   ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,arrow_code); 
//--- set anchor type 
   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor); 
//--- set the arrow color 
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr); 
//--- set the border line style 
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style); 
//--- set the arrow's size 
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width); 
//--- display in the foreground (false) or background (true) 
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back); 
//--- enable (true) or disable (false) the mode of moving the arrow by mouse 
//--- when creating a graphical object using ObjectCreate function, the object cannot be 
//--- highlighted and moved by default. Inside this method, selection parameter 
//--- is true by default making it possible to highlight and move the object 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection); 
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection); 
//--- hide (true) or display (false) graphical object name in the object list 
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden); 
//--- set the priority for receiving the event of a mouse click in the chart 
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order); 
//--- successful execution 
   return(true); 
  } 
//+------------------------------------------------------------------+ 


//+------------------------------------------------------------------+ 
//| Change the arrow code                                            | 
//+------------------------------------------------------------------+ 
bool ArrowCodeChange(const long   chart_ID=0,   // chart's ID 
                     const string name="Arrow", // object name 
                     const uchar  code=252)     // arrow code 
  { 
//--- reset the error value 
   ResetLastError(); 
//--- change the arrow code 
   if(!ObjectSetInteger(chart_ID,name,OBJPROP_ARROWCODE,code)) 
     { 
      Print(__FUNCTION__, 
            ": failed to change the arrow code! Error code = ",GetLastError()); 
      return(false); 
     } 
//--- successful execution 
   return(true); 
  } 
//+------------------------------------------------------------------+ 
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...