Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 561

 
Vladon:

calculate the number of characters, + font size, like this?

The font size doesn't give you the knowledge you need. You need to draw several objects one on top of the other. Only the first object has an anchor point. How to get the anchor point of the 2nd and subsequent objects?
 
Vladon:


Forced completion of EA in case of user unloads EA.

it is better to record the data directly at the start.

It is not working through start. Same picture.
----------------------------------------------------
stringo 25.03.2014 13:28

The deinit run time is limited to 10 seconds.

In tester at normal completion stop flag is not set, so deinit is quietly completed.

----------------------------------------------------

Maybe a 10 second limit is imposed on the operation of any function?
 
Hello! When studying MQL4 a small question has arisen. The problem is posted in the tutorial on this site. Here is the condition: Task 25. Create a program that realizes the following conditions: if exchange rate has risen above the specified level, then give a message, in which words indicate that the rate has exceeded the level (up to 100 points); in other cases, give a message that the rate does not exceed the specified level.
And here is the proposed solution:
//--------------------------------------------------------------------
extern double Level=1.3200;                     // Заданный уровень 
string Text[101];                               // Объявление массива
//--------------------------------------------------------------------
int init()                                      // Спец. ф-ия init()
  {                                             // Присвоение значений
   Text[1]="один ";            Text[15]="пятнадцать ";
   Text[2]="два ";             Text[16]="шестнадцать ";
   Text[3]="три ";             Text[17]="семнадцать ";
   Text[4]="четыре ";          Text[18]="восемнадцать ";
   Text[5]="пять ";            Text[19]="девятнадцать ";
   Text[6]="шесть ";           Text[20]="двадцать ";
   Text[7]="семь ";            Text[30]="тридцать ";
   Text[8]="восемь ";          Text[40]="сорок ";
   Text[9]="девять ";          Text[50]="пятьдесят ";
   Text[10]="десять ";         Text[60]="шестьдесят";
   Text[11]="одиннадцать ";    Text[70]="семьдесят ";
   Text[12]="двенадцать ";     Text[80]="восемьдесят ";
   Text[13]="тринадцать ";     Text[90]="девяносто";
   Text[14]="четырнадцать ";   Text[100]= "сто";
   // Вычисление значений
   for(int i=20; i<=90; i=i+10)                // Цикл по десяткам
     {
      for(int j=1; j<=9; j++)                  // Цикл по единицам
         Text[i+j]=Text[i] + Text[j];          // Вычисление значения   
     }
   return;                                     // Выход из init()
  }
//--------------------------------------------------------------------
int start()                                     // Спец. ф-ия start()
  {
   int Delta=NormalizeDouble((Bid-Level)/Point,0);// Превышение 
//--------------------------------------------------------------------
   if (Delta>=0)                                // Цена не выше уровня
     {
      Alert("Цена ниже уровня");                // Сообщение
      return;                                   // Выход из start()
     }
//--------------------------------------------------------------------
   if (Delta<100)                               // Цена более 100
     {
      Alert("Более ста пунктов");               // Сообщение
      return;                                   // Выход из start()
     }
//--------------------------------------------------------------------
   Alert("Плюс ",Text[Delta],"pt.");            // Вывод на экран
   return;                                      // Выход из start()
  }
//---------------------------------------------------------------------
По-моему в условных операторах неправильно проставлены знаки сравнения. Они должны быть с точностью до наоборот. Скажите прав ли я? И если нет, то почему так?  
 
Vladon:

Why did you think it was the indicator's fault?

For example, I optimised AMA, it is much faster optimising, although the indicator is complex.

I will not say for sure that it is the indicator's fault. I do not have much experience in it yet.

But how can I speed it up? Have I done everything right here or can I change something?

In principle, it is enough for the indicator to be calculated using the last 100 bars, but if I set the number 100 instead of 500, the values disappear.

extern int Limit=70;

if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
 
   limit1=Bars-counted_bars-1;
   if (limit1>Limit && Limit>0) limit1=Limit;
   limit2=limit1;
   limit3=limit2;
   limit4=limit3;
   if(limit1>0) 
     {
      limit1=500-Period_MA_1-1;
      limit2=limit1-p2;
      limit3=limit2-p3;
      limit4=limit3-p4;
     }
If you carry out optimization at this speed, its completion beard will grow to the floor and the earned mullens will not be useful) Well, or the market will be completely different.
 
alxm:
Good afternoon. Can you tell me if it's possible to programmatically define or calculate the width/height on a chart of an OBJ_TEXT object?

Text probably not, but label please

docs.mql4.com/en/constants/objectconstants/enum_object_property

OBJPROP_XSIZE and OBJPROP_YSIZE properties

 
Vladon:


Thanks for the help with the loop operator, it all worked out fine.
 
Forexman77:



But, how to speed it up? Did I do everything right here or is there something I can change?



Well, you can immediately see that the calculation is flawed, e.g. a bar has been added.

limit1=Bars-counted_bars-1;

limit1 will be two... And then

 if(limit1>0) 
     {
      limit1=500-Period_MA_1-1;

Anyway, the recalculation is completely wrong...

 
Vladon:



Thank you very much, have a good day :) >)
 
splxgf:


Well here you can immediately see that the recalculation screwed up, for example a bar was added.

limit1 will be two... And then

Anyway, the recalculation is completely wrong...

What's the right way to do it? That's why I'm asking. I don't really know how to count indicators.

I'm going to guess:
limit1=Bars-counted_bars;

should it be like this?

I don't know what's going on here.

if(limit1>0) 
     {
      limit1=500-Period_MA_1-1;
If in general, it is enough for me to have the indicator calculated on the last 100 bars.
 
Vladon:


function must be set variable

e.g. bool closee=OrderClose...........

  • return value of 'OrderSelect' should be checked
  • return value of 'OrderDelete' should be checked
  • return value of 'OrderSend' should be checked
  • return value of 'OrderClose' should be checked
  • return return value of 'OrderModify' should be checked


To avoid such warnings, return to the variable must be specified explicitly
like this:
  • bool select1=OrderSelect..........
  • bool delete1=OrderDelete..........
  • bool close1=OrderClose..........
  • bool modify1=OrderModify..........
  • int send1=OrderSend..........


along the way solving another problem thanks again!!!