Errors, bugs, questions - page 280

 

-Alexey-:
Это было бы логично, но сейчас операция ">" ("<" не проверял) может возвращать результ true для таких чисел "равных в смысле машинного нуля". Обнаружился эффект т.к. результат  численного расчета получился больше теоретически возможного в результате такого эффекта, а после использования спец. функций, что выше - стал правильным. Поэтому и предлагаю ввести дополнение в справку.

My knowledge of the subject is superficial, so I can't assess what you have said. Write to Service Desk and they will look into the matter.

 

Developerc - Thanks for the work done - mt5 is a good tool,

I would like to add more examples of working with functions,

classes etc. Of course to do it in the help - ideal, but here too

But here it would be good.


A special thanks to those who write articles with examples. Thank you very much.

 
uncleVic:

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:

otherwise it will not work in the tester.

If the folder Indicators\Examples does not contain the MACD.ex5 file, the indicator should be compiled.

An example will be added to the help in the nearest future.

Thank you very much, it works!
 
-Alexey-:
This would make sense, 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.

Just use DBL_EPSILON in all comparisons, it's not difficult:

if ( a - b > DBL_EPSILON ) // a > b
if ( b - a > DBL_EPSILON ) // a < b
if ( MathAbs( a - b ) < DBL_EPSILON ) // a == b


If you work with prices, normalise them after any calculations and use Point/2.0 instead of DBL_EPSILON:

price_1 = NormalizeDouble( Ask + 25 * Point, Digits );
price_2 = NormalizeDouble( indicator_value, Digits );

if ( price_1 - price_2 > Point/2.0 ) // price_1 > price_2
if ( price_2 - price_1 > Point/2.0 ) // price_1 < price_2
if ( MathAbs( price_1 - price_2 ) < Point/2.0 ) // price_1 == price_2
Документация по MQL5: Проверка состояния / Point
Документация по MQL5: Проверка состояния / Point
  • www.mql5.com
Проверка состояния / Point - Документация по MQL5
 
Thank you.
 

For some reason, reading an array via the FileReadArray function doesn't work , although the file is opened, contains data, etc:

string   filename="equity FileWrite23.txt";
int      handle;
int      NumberCopyElements;
string   common_folder;
string   Array[];

void OnInit(){
   common_folder=TerminalInfoString(TERMINAL_COMMONDATA_PATH);
   handle=FileOpen(filename,FILE_READ|FILE_COMMON);
   if(handle!=INVALID_HANDLE)
      Print("Equity FileWrite23 - OnInit(): Удалось открыть файл ",filename,".  Ошибка ",GetLastError());
      else
      Print("Equity FileWrite23 - OnInit(): Не удалось открыть файл ",filename,".  Ошибка ",GetLastError());

   NumberCopyElements = FileReadArray(handle,Array,0,WHOLE_ARRAY);
      PrintFormat("Equity FileWrite23 - OnInit(): Записано %d байт в общую папку всех терминалов - %s",NumberCopyElements,common_folder);
   FileClose(handle);

}





















2011.01.26 16:27:00     Core 1  connect closed
2011.01.26 16:27:00     Core 1  log file "C:\Program Files\MetaTrader 5\Tester\Agent-127.0.0.1-3000\logs\20110126.log" written
2011.01.26 16:27:00     Core 1  EURUSD,H1: 5516 ticks (23 bars) generated within 15 ms (total bars in history 6419, total time 218 ms)
2011.01.26 16:27:00     Core 1  OnTester result 0
2011.01.26 16:27:00     Core 1  2011.01.14 00:00:00   Equity FileWrite23 - OnInit(): Записано 0 байт в общую папку всех терминалов - C:\Documents and Settings\All Users\Application Data\MetaQuotes\Terminal\Common
2011.01.26 16:27:00     Core 1  2011.01.14 00:00:00   Equity FileWrite23 - OnInit(): Удалось открыть файл equity FileWrite23.txt.  Ошибка 0
2011.01.26 16:27:00     Core 1  EURUSD,H1: testing of Experts\_My\Experts\Expert1\Expert Small FileWriteEquity.ex5 from 2011.01.14 00:00 to 2011.01.15 00:00 started
2011.01.26 16:27:00     Core 1  EURUSD,H1 (Alpari-Demo): 1 minutes OHLC ticks generating. OnTick executed on the bar begin only
2011.01.26 16:27:00     Core 1   Intel Pentium 4  3.40 GHz, 3063 MB, PR39
2011.01.26 16:27:00     Core 1  4255 bytes of total initialization data received
2011.01.26 16:27:00     Core 1  successfully initialized
2011.01.26 16:27:00     Core 1  initial deposit 10000.00 USD, leverage 1:100
2011.01.26 16:27:00     Core 1  expert file added: Experts\_My\Experts\Expert1\Expert Small FileWriteEquity.ex5. 4106 bytes loaded
2011.01.26 16:27:00     Core 1  common synchronization completed
2011.01.26 16:27:00     Tester  EURUSD,H1 (Alpari-Demo): testing of Experts\_My\Experts\Expert1\Expert Small FileWriteEquity.ex5 from 2011.01.14 00:00 to 2011.01.15 00:00 to be started2011.01.26 16:27:00     Core 1  authorized (agent build 384)
2011.01.26 16:27:00     Core 1  connected
2011.01.26 16:27:00     Core 1  connecting to 127.0.0.1:3000


 
DV2010:

For some reason, reading an array via FileReadArray function doesn't work , although the file is opened, contains data, etc.:

You first write data to the file in the same way, see the format...

And then read...

 
AlexSTAL:

You first write the data to a file in the same way, see the format...

And then read...

I write data one line at a time in OnCalculated indicator or OnInit of the Expert Advisor via FileWrite.

As a result, the file is a list of numbers:

10000
10000
9996.85
10005.25
10023.4
10029.7

Of course, we could write the array as a whole too, but why should we make unnecessary steps and what is the error here?

I couldn't find any restrictions on this in the documentation.

 
DV2010:

I write data line by line to OnCalculated indicator or OnInit of Expert Advisor via FileWrite.

As a result, the file is a list of numbers:

10000
10000
9996.85
10005.25
10023.4
10029.7

Of course, you can also write the array as a whole, but why do I need to do unnecessary things and what is the error here?

I did not find any limitations concerning this subject in the documentation.

First try and look at the formats of both files before discussing
 
DV2010:

For some reason, reading an array via the FileReadArray function doesn't work , although the file is opened, contains data, etc:


From the help:

FileReadArray

Reads arrays of any type, except string arrays (can be an array of structures containing no strings and dynamic arrays), from a binary file from the current position of the file pointer.

Reason: