Errors, bugs, questions - page 2533

 
Georgiy Merts:

In your case, organise a while() loop rather than a for() loop.

Check for some sign of end of blinking.

But about "blinking with variable frequency" - something strange... I don't see any errors on the fly, it should be flashing quite frequently.

Admittedly, I doubt it's wise to create and delete graphic objects instead of making them invisible. But, it seems you can't make an object invisible... So that leaves only deleting.

Thanks for the reply, it works now. But the blinking is just as chaotic, recorded how it happens. And I replaced the removal with changing the LABEL colour to black.



int i = 1;
   while(i > 0)  //true?
   {      
      if(!ObjectCreate(0,"Blink",OBJ_LABEL,0,0,0))
   {
      Print("Not Create! Error - ",GetLastError());
   }
   ObjectSetInteger(0,"Blink",OBJPROP_XDISTANCE,50+i);
   ObjectSetInteger(0,"Blink",OBJPROP_YDISTANCE,50);
   ObjectSetInteger(0,"Blink",OBJPROP_CORNER,CORNER_RIGHT_UPPER);
   ObjectSetString(0,"Blink",OBJPROP_TEXT,"Test");
   ObjectSetString(0,"Blink",OBJPROP_FONT,"Arial");
   ObjectSetInteger(0,"Blink",OBJPROP_FONTSIZE,18);
   ObjectSetDouble(0,"Blink",OBJPROP_ANGLE,0);
   ObjectSetInteger(0,"Blink",OBJPROP_ANCHOR,ANCHOR_RIGHT_UPPER);
   ObjectSetInteger(0,"Blink",OBJPROP_COLOR,Red);
   ObjectSetInteger(0,"Blink",OBJPROP_BACK,false);
   ObjectSetInteger(0,"Blink",OBJPROP_SELECTABLE,true);
   ObjectSetInteger(0,"Blink",OBJPROP_SELECTED,false);
   ObjectSetInteger(0,"Blink",OBJPROP_HIDDEN,true);
   ObjectSetInteger(0,"Blink",OBJPROP_ZORDER,0);
   
   Sleep(200);
   
   ObjectSetInteger(0,"Blink",OBJPROP_COLOR,Black);
   
   Sleep(200);
   } 
 
Влад:

Thanks for the reply, it's working now. But the blinking is the same chaotic, recorded how it happens. And I replaced the deletion with changing the LABEL colour to black.


You can see it depends on the tick. This code should be done in OnTimer(), not in OnTick().

And you don't have to color it black - objects have a visibility property(OBJPROP_TIMEFRAMES) - you just need to manage its visibility.

The values for the timeframes, at which the object must be visible, are set by a set of flags. In your case, you need to set 0(OBJ_NO_PERIODS) - the object is not visible anywhere, and OBJ_ALL_PERIODS - visible everywhere. And don't forget to update chart with ChartRedraw() after the property value has changed.

Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Видимость объектов
Документация по MQL5: Константы, перечисления и структуры / Константы объектов / Видимость объектов
  • www.mql5.com
Комбинация флагов видимости объекта определяет таймфреймы графика, на которых объект отображаем. Для установки/получения значения свойства OBJPROP_TIMEFRAMES можно использовать функции ObjectSetInteger()/ObjectGetInteger...
 
Влад:

Thanks for the reply, it's working now. But the blinking is the same chaotic, recorded how it happens. And I replaced the deletion by changing the LABEL colour to black.

I don't think you have much to lose yet, try using my script code, it works, it's shorter

#property copyright "IgorM"
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict

#include <ChartObjects\ChartObjectsTxtControls.mqh>
CChartObjectLabel Label;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   Label.Create(0,"tst",0,0,50);
   Label.Description("Hello word!");
   Label.FontSize(14);
   bool show=true;
   while(!IsStopped())
     {
      color col=show ? clrRed : clrNONE;
      Label.Color(col);
      show=!show;
      ChartRedraw();
      Sleep(1000);
     }
  }
//+------------------------------------------------------------------+

it's in the script folder!

 
Igor Makanu:

I don't think you have much to lose yet, try using my script code, it works, it's shorter

It's in the srift folder!

Igor, I understand it's written in MQL5 and I have Metatrader 4 unfortunately.

 
Влад:

Igor, I understand it's written in MQL5, and I have Metatrader 4 unfortunately.

this is MQL4... could have tried it already ))))

 
Oh, man, that's right.) I apologize for the impudence, but is it possible to use an indicator instead of a script? I've copied the guts of the indicator template and it is OK when I switch TFs. I have copied it to indicator template and it compiles well. But when I paste it to the chart, the terminal hangs up.
 
Please advise if you know how to get a forward optimization result in an MQL5 Expert Advisor under test? This question was posted in this thread. Maybe it will be answered here.
 
Влад:
Oh, man, that's right.) Thanks a lot, Igor! Sorry for the impudence, but is it possible to use an indicator instead of a script? I've copied the guts of the indicator template and it is OK when I switch TFs. I have copied it to the indicator template, it compiles well but when I paste it on the chart, the terminal hangs up.
Files:
Blink.mq4  3 kb
 
Igor Makanu:

Thank you very much! )

 

For site administrators:

I couldn't find where, I'm writing here.

I need to change the details of the seller in the profile.

how to do this ?

I wrote a message a long time ago in the seller's area, but there is no answer.

maybe there is another way ?