Errors, bugs, questions - page 279

 
Rosh:
No.
that's why simultaneous access cannot be organised:(((
 
Olegts:
that is why simultaneous access cannot be organised:(((.

You can, the file opened in MT5 with the share flag will also be available for any other programme, including MT4.

See how it is done here.

i.e. if the file is already open in MT4, the Shaare flag will allow it to be opened by MT5 without problems. It turns out that MT4 works as usual, while MT5 can allow other programs to use a file already opened by it, or open a file that is opened by someone else without the flag of shahre.

 
Urain:

You can, the file opened in MT5 with the share flag will also be available for any other programme, including MT4.

See how it is done here.

Thank you, I'll have a look now...
 
Olegts:
Thanks, I'll have a look now...
I looked, MT5 writes and MT4 reads, it works, but if MT4 writes, MT5 cannot read because the file is blocked, at least it didn't work for me...
 
The help section in data type description says:
<br / translate="no">

Because of this, it is categorically not recommended to compare two real numbers to each other for equality, as such a comparison is not correct.

And a special comparison method is suggested.

If you still need to compare two real numbers for equality, you can...

But then a logical conclusion follows that it is not recommended to compare real numbers even by means of greater/smaller operations because such operation, in the sense of the above mentioned, is correct only when a special method first correctly establishes that checked values are not equal in terms of machine zero.

I.e. it turns out that the > and < operators for real numbers cannot be used in pure form either. Did I get it right, and if so, why don't I add a corresponding comment to the help?


But, if the operation, for example, >, can be used only after a correct check for inequality, then how to organize the check for >=? Is it necessary to complicate the algorithm even more, i.e. to check for equality first with a special function, and then with a special function for inequality (before using >)?


Perhaps someone has already developed a library for all comparison cases for both double and float types? I've sketched out something for double type - I don't know if it is correct:

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на равенство двух вещественных чисел типа double
bool EqualDoubles(const double d1, const double d2)
   {  
      const double epsilon=2.2204460492503131 e-016;//DBL_EPSILON
      if(d1-d2>epsilon) return false;
      if(d1-d2<-epsilon) return false;
      return true;
   }
// Конец функции проверки на равенство двух вещественных чисел типа double
//+++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на неравенство двух вещественных чисел типа double
bool NotEqualDoubles(const double d1, const double d2)
   {      
      return !EqualDoubles(d1, d2);
   }
// Конец функции проверки на неравенство двух вещественных чисел типа double
//+++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на меньшинство первого из двух вещественных чисел типа double
bool LessDoubles(const double d1, const double d2)
   {  
      if (NotEqualDoubles(d1, d2)&&(d1<d2))
      {
         return true;
      }
      return false;
   }
// Конец функции проверки на меньшинство первого из двух вещественных чисел типа double
//+++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на большинство первого из двух вещественных чисел типа double
bool GreaterDoubles(const double d1, const double d2)
   {  
      if (NotEqualDoubles(d1, d2)&&(d1>d2))
      {
         return true;
      }
      return false;
   }
// Конец функции проверки на большинство первого из двух вещественных чисел типа double
//+++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на меньшинство первого или равенство двух вещественных чисел типа double
bool LessEqualDoubles(const double d1, const double d2)
   {  
      if (LessDoubles(d1, d2)||EqualDoubles(d1, d2))
      {
         return true;
      }
      return false;
   }
// Конец функции проверки на меньшинство первого или равенство двух вещественных чисел типа double
//+++++++++++++++++++++++++++++++++++++++++++++++++
// Функция проверки на большинство первого или равенство двух вещественных чисел типа double
bool GreaterEqualDoubles(const double d1, const double d2)
   {  
      if (GreaterDoubles(d1, d2)||EqualDoubles(d1,d2))
      {
         return true;
      }
      return false;
   }
// Конец функции проверки на большинство первого или равенство двух вещественных чисел типа double

P.S. If prevcalculated==0 works as usual again. Floating bug?

 

Good afternoon!

I need to use a custom indicator in the trading signals module.

For this, as far as I understand, I need to add a pointer to this indicator object in "collection of indicators(timeseries?)" as it is done in the example:

indicators.Add(GetPointer(m_MA)))

where m_MA is an object of the CiMA class.

The iCustom and IndicatorCreate functions return the integer value of a handle of the created indicator, but I need an object of this indicator, as I understand it.

Please, advise how to get out of this situation?

Переход на новые рельсы: пользовательские индикаторы в MQL5
Переход на новые рельсы: пользовательские индикаторы в MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
Я не буду перечислять все новые возможности и особенности нового терминала и языка. Их действительно много, и некоторые новинки вполне достойны освещения в отдельной статье. Вы не увидите здесь кода, написанного по принципам объектно-ориентированного программирования — это слишком серьезная тема для того, чтобы просто быть упомянутой в контексте как дополнительная вкусность для кодописателей. В этой статье остановимся подробней на индикаторах, их строении, отображении, видах, а также особенностях их написания по сравнению с MQL4.
 
lVlaxim:

Good afternoon!

I need to use a custom indicator in the trading signals module.

For this, as far as I understand, I need to add a pointer to this indicator object in "collection of indicators(timeseries?)" as it is done in the example:

where m_MA is an object of the CiMA class.

The iCustom and IndicatorCreate functions return the integer value of a handle of the created indicator, but I need an object of this indicator, as I understand it.

Please, advise how to get out of this situation?

As far as I understand, I should write my own indicator object based on CiCustom (similar to how CiMA is written).

I can not advise in details, because I have not worked with induks, but I think you will understand or people will tell you the right realization.

PS

By the way, developers, please add examples to the section on CiCustom...

 
-Alexey-:

And a special comparison method is suggested.

But then it follows logically that it is not recommended to compare real numbers even by means of greater/smaller operations, because such an operation, in the sense of the above, is only correct if it is correctly established beforehand, using a special method, that the values being checked are not equal in the sense of machine zero.

Maybe I haven't quite understood the point, but if two real numbers are being compared, say, with the help of the "<" operation and the real numbers being checked are "equal in the sense of machine zero", the "<" operation will simply return false. Which means "the first real number is not less than the second real number".
 
lVlaxim:

Good afternoon!

I need to use a custom indicator in the trading signals module.

For this, as far as I understand, I need to add a pointer to this indicator object in "collection of indicators(timeseries?)" as it is done in the example:

where m_MA is an object of the CiMA class.

The iCustom and IndicatorCreate functions return the integer value of a handle of the created indicator, but I need an object of this indicator, as I understand it.

Please, advise how to get out of this situation?

For now, take this file as an example.

The CSignalCustomMACD class is absolutely identical to CSignalMACD, except for the fact that it is based on the "custom" version of the indicator from the standard delivery.

Do not forget to add a line in the source code of the Expert Advisor:

#property tester_indicator "Examples\MACD.ex5"

otherwise it will not work in the tester.

If there is no MACD.ex5 file in the Indicators\Examples folder, the indicator must be compiled.

An example in the help will be added in the near future.

Files:
 
Yedelkin:
Maybe I don't quite understand the problem, but if two real numbers are compared using, say, "<" operation, and the real numbers being checked are "equal in the sense of machine zero", then "<" operation will just return false, and that's it. Which would mean "the first real number is not less than the second real number".
This would be logical, but now the operation ">" ("<" didn't check) may return true for such numbers "equal in the sense of machine zero". The effect was detected because the result of the numerical calculation was larger than theoretically possible as a result of this effect, but after using the special functions above it became true. That is why I propose an addition to the help.
Reason: