[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 192

 

NewBar() is called; but if you look long enough, you won't make things worse for yourself :)

 

newbar https://book.mql4.com/ru/variables/arrays

Conceptually, it's no different.

void Fun_New_Bar()                              // Ф-ия обнаружения ..
  {                                             // .. нового бара
   static datetime New_Time=0;                  // Время текущего бара
   New_Bar=false;                               // Нового бара нет
   if(New_Time!=Time[0])                        // Сравниваем время
     {
      New_Time=Time[0];                         // Теперь время такое
      New_Bar=true;                             // Поймался новый бар
     }
  }

 
splxgf:

newbar https://book.mql4.com/ru/variables/arrays

Conceptually, it's no different.


Not conceptually, but it won't work - sorry about that.
 
On the ADX indicator is written a lot, but there is a feature which I would like to take into account, here in short....And you can make the bars colored in this algorithm: if the current value of ADX is greater than the previous ADX and + (plus line) above the minus line, the bar is painted in green, but if the current value of ADX less than the previous value, the bar is painted in gray (there is no matter where the plus line), and finally if the current value ADX greater than the previous ADX and - (minus line) above the plus line, the bar is painted in red. Or, if I wanted to change the ADX value, I could just set it to a value above which arrows will not be drawn.
 
splxgf:
double OpenBar=0; 
 
int start()
   {
    //Проверка на начало нового бара
    if (OpenBar==Time[0]) return; else OpenBar=Time[0];
   }

I wouldn't play around with a variable of the double type here! You need more memory! ;)))

And when conversion of int type to target type double occurs, I understand, there will be no extra digits after decimal point? I personally have not come across such cases. But it's worth asking.


tara:

Conceptually - nothing, but it won't work, sorry.
Which code won't work and why?
 

The one you quoted will miss some of the bars.

 
tara:

The one you quoted will miss some of the bars.


Suggest your own variant and explain why it is better. So far it's just words.
 

1. Missing part of the bars will be, because the result of comparison double==int depends on the particular int value that was previously placed in double. This is exactly what happens here: time (int) is written in double - for all numbers that are not degrees of two there is a loss of precision, which results in double3 != int3, although double4 == int4.

2. I understand that this is just someone's technical mistake, then repeatedly propagated. Actually you should just correct the OpenBar type to datetime or int. But - slumber of the mind spawns monsters: it's easier just to repeat someone else's code and close your eyes :)

3. Incorrect solution in terms of memory allocation: a local variable static is enough here, extra global variable is useless - software rubbish, although it's a trifle :(

 
tara:

1. Missing part of the bars will be, because the result of comparison double==int depends on the particular int value that was previously placed in double. This is exactly what happens here: time (int) is written in double - for all numbers that are not degrees of two there is a loss of precision, which results in double3 != int3, although double4 == int4.

2. I understand that this is just someone's technical mistake, then repeatedly propagated. Actually you just should fix the OpenBar type on double. But sleep of reason breeds beasts: it's easier just to repeat somebody else's code and close your eyes :)

3. Incorrect solution in terms of memory allocation: a local variable static is enough here, extra global variable is useless - program rubbish, although it is a trifle :(


There is still some code to be cited. I'm just tired of repeating the same thing five pages later. Especially since the right solution is easy to find through a search
 

Good day everyone!

Question about EAs. Looking through a lot of EAs, I want to understand how trades are automatically made. I think I have set everything correctly, I allow the EA to trade, I understand the idea, but there are no trades for some reason. Perhaps, it is applied to a certain symbol? Or a timeframe? How can I find out?

Reason: