bug moving object

 
Someone had the experience to try to move object and it not obey and return success?

The follow expert do not move the lines... how to report a bug to metaquotes? HLineCreate and HLineMove has been based on the documentation page of OBJ_HLINE. Metatrader version is from april 4 2023.
string ativo=_Symbol;
//+-------------------------------------------/-----------------------+
int OnInit()
  {   
   HLineCreate("EATTT_ZERO", iOpen(NULL, PERIOD_D1, 0), clrBlack);
   HLineCreate("EATTT_SUPORTE", iOpen(NULL, PERIOD_D1, 0), clrBlue);
   HLineCreate("EATTT_RESISTENCIA", iOpen(NULL, PERIOD_D1, 0), clrRed);
   EventSetTimer(1);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   EventKillTimer();
   ObjectsDeleteAll(0, "EATTT_");
   Comment("");
  }
//+------------------------------------------------------------------+
void OnTimer(void)
  {
   datetime today = iTime(ativo, PERIOD_D1, 0);
   int pbars = iBarShift(ativo, PERIOD_CURRENT, today) + 0;
   double hp = iHigh(ativo, PERIOD_CURRENT, pbars);
   double lp = iLow(ativo, PERIOD_CURRENT, pbars);
   double mi = (hp + lp)/2.0;
   Comment("*"+(string)pbars+","+(string)lp+","+(string)mi+","+(string)hp,(string)TimeTradeServer());
   HLineMove("EATT_ZERO", mi);
   HLineMove("EATT_RESISTENCIA", hp);
   HLineMove("EATT_SUPORTE", lp);
  }
//+------------------------------------------------------------------+
bool HLineCreate(const string          name="HLine",      // nome da linha
                 double                price=0,           // line price
                 const color           clr=clrRed,        // cor da linha
                 const ENUM_LINE_STYLE style=STYLE_SOLID, // estilo da linha
                 const int             width=1,           // largura da linha
                 const long            chart_ID=0,        // ID de gráfico
                 const int             sub_window=0,      // índice da sub-janela
                 const bool            back=false,        // no fundo
                 const bool            selection=false,   // destaque para mover
                 const bool            hidden=false,      //ocultar na lista de objetos
                 const long            z_order=0)         // prioridade para clique do mouse
  {
//--- se o preço não está definido, defina-o no atual nível de preço Bid
   if(!price)
      price=SymbolInfoDouble(Symbol(),SYMBOL_BID);
//--- redefine o valor de erro
   ResetLastError();
//--- criar um linha horizontal
   if(!ObjectCreate(chart_ID,name,OBJ_HLINE,sub_window,0,price))
     {
      Print(__FUNCTION__,
            ": falha ao criar um linha horizontal! Código de erro = ",GetLastError());
      return(false);
     }
//--- definir cor da linha
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- definir o estilo de exibição da linha
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- definir a largura da linha
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- exibir em primeiro plano (false) ou fundo (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- habilitar (true) ou desabilitar (false) o modo do movimento da seta com o mouse
//--- ao criar um objeto gráfico usando a função ObjectCreate, o objeto não pode ser
//--- destacado e movimentado por padrão. Dentro deste método, o parâmetro de seleção
//--- é verdade por padrão, tornando possível destacar e mover o objeto
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- ocultar (true) ou exibir (false) o nome do objeto gráfico na lista de objeto
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- definir a prioridade para receber o evento com um clique do mouse no gráfico
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);
//--- sucesso na execução
   return(true);
  }
//+------------------------------------------------------------------+
//| Mover linha horizontal                                           |
//+------------------------------------------------------------------+
bool HLineMove(const string name="HLine", // nome da linha
               double       price=0,      // preço da linha
               const long   chart_ID=0)   // ID do gráfico
  {
//--- se o preço não está definido, defina-o no atual nível de preço Bid
   if(!price)
   {
      //Print(__FUNCTION__,": preco sendo alterado pro bid -- ", GetLastError());
      price=SymbolInfoDouble(ativo,SYMBOL_BID);
   }
//--- redefine o valor de erro
   ResetLastError();
//--- mover um linha horizontal
   if(!ObjectMove(chart_ID, name, 0, 0, price))
     {
      Print(__FUNCTION__,
            ": falha ao mover um linha horizontal! Código de erro = ",GetLastError());
      return(false);
     }
//--- sucesso na execução
   //Print(__FUNCTION__, ": sucesso!");
   return(true);
  }
//+------------------------------------------------------------------+
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Object Types - Objects Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Please don't post randomly in any section. Topic has been moved to the section: Expert Advisors and Automated Trading.
 
  1. How To Ask Questions The Smart Way. (2004)
              Don't rush to claim that you have found a bug.
    Questions Not To Ask
              My program doesn't work. I think system facility X is broken.

    It is almost always your code.

  2.    datetime today = iTime(ativo, PERIOD_D1, 0);
       int pbars = iBarShift(ativo, PERIOD_CURRENT, today) + 0;
       double hp = iHigh(ativo, PERIOD_CURRENT, pbars);
       double lp = iLow(ativo, PERIOD_CURRENT, pbars);
       double mi = (hp + lp)/2.0;

    You are moving the lines to the H/L/mid of the first bar (current timeframe) of the day. They will never move after that.

  3. Perhaps you meant the highest high/the lowest low of the day; which you can get from the D1 bar zero H/L.

    On MT4: Unless the current chart is that specific symbol(s)/TF(s) referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - MQL4 programming forum - Page 3 #26.4 (2019)

    On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
              Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
              Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
              Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
              Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
              SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)

  4. Why are you using OnTimer? Nothing has changed, nothing needs to update until a new tick arrives.

 
William Roeder #:
  1. How To Ask Questions The Smart Way. (2004)
              Don't rush to claim that you have found a bug.
    Questions Not To Ask
              My program doesn't work. I think system facility X is broken.

    It is almost always your code.

  2. You are moving the lines to the H/L/mid of the first bar of the day. They will never move after that.

  3. Perhaps you meant the highest high/the lowest low of the day; which you can get from the D1 bar zero H/L.

William, i have tried this code before and it move the lines to the open of the bar on OnInit as expected, and after it I expected it will move to the high, low and middle point of the bar. The problem is that the three objects stay on the open of the bar. Do you have a suggest to fix?

Also, I tested changing pbars to zero and it do nothing after the OnInit code.
 
Ricardo Rodrigues Lucca #:

William, i have tried this code before and it move the lines to the open of the bar on OnInit as expected, and after it I expected it will move to the high, low and middle point of the bar. The problem is that the three objects stay on the open of the bar. Do you have a suggest to fix?

Also, I tested changing pbars to zero and it do nothing after the OnInit code.
I saw right now when I was reviewing the code that I had a typo on the name of the objects on OnTimer, it is missing a T . Thank you.
Reason: